Skip to content

Commit 7960899

Browse files
committed
Unify Type.isJavaMethod with MethodType.isJava
1 parent e55684f commit 7960899

File tree

5 files changed

+8
-11
lines changed

5 files changed

+8
-11
lines changed

compiler/src/dotty/tools/dotc/core/TypeErasure.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ class TypeErasure(isJava: Boolean, semiEraseVCs: Boolean, isConstructor: Boolean
398398
ctx.typeComparer.orType(this(tp1), this(tp2), erased = true)
399399
case tp: MethodType =>
400400
def paramErasure(tpToErase: Type) =
401-
erasureFn(tp.isJava, semiEraseVCs, isConstructor, wildcardOK)(tpToErase)
401+
erasureFn(tp.isJavaMethod, semiEraseVCs, isConstructor, wildcardOK)(tpToErase)
402402
val (names, formals0) =
403403
if (tp.paramInfos.exists(_.isPhantom)) tp.paramNames.zip(tp.paramInfos).filterNot(_._2.isPhantom).unzip
404404
else (tp.paramNames, tp.paramInfos)

compiler/src/dotty/tools/dotc/core/Types.scala

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -289,10 +289,7 @@ object Types {
289289
final def isAlias: Boolean = this.isInstanceOf[TypeAlias]
290290

291291
/** Is this a MethodType which is from Java */
292-
final def isJavaMethod: Boolean = this match {
293-
case mt: MethodType => mt.isJava
294-
case _ => false
295-
}
292+
def isJavaMethod: Boolean = false
296293

297294
/** Is this a MethodType which has implicit parameters */
298295
final def isImplicitMethod: Boolean = this match {
@@ -1329,7 +1326,7 @@ object Types {
13291326
case mt: MethodType if !mt.isDependent || ctx.mode.is(Mode.AllowDependentFunctions) =>
13301327
val formals1 = if (dropLast == 0) mt.paramInfos else mt.paramInfos dropRight dropLast
13311328
defn.FunctionOf(
1332-
formals1 mapConserve (_.underlyingIfRepeated(mt.isJava)), mt.resultType, mt.isImplicit && !ctx.erasedTypes)
1329+
formals1 mapConserve (_.underlyingIfRepeated(mt.isJavaMethod)), mt.resultType, mt.isImplicit && !ctx.erasedTypes)
13331330
}
13341331

13351332
/** The signature of this type. This is by default NotAMethod,
@@ -2697,15 +2694,15 @@ object Types {
26972694
def kind: MethodKind
26982695
final def companion: MethodTypeCompanion = MethodType.withKind(kind)
26992696

2700-
final def isJava: Boolean = kind is JavaKind
2697+
final override def isJavaMethod: Boolean = kind is JavaKind
27012698
final def isImplicit: Boolean = kind is ImplicitKind
27022699

27032700
val paramInfos = paramInfosExp(this)
27042701
val resType = resultTypeExp(this)
27052702
assert(resType.exists)
27062703

27072704
def computeSignature(implicit ctx: Context): Signature =
2708-
resultSignature.prepend(paramInfos, isJava)
2705+
resultSignature.prepend(paramInfos, isJavaMethod)
27092706

27102707
protected def prefixString = "MethodType"
27112708
}

compiler/src/dotty/tools/dotc/transform/ElimRepeated.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class ElimRepeated extends MiniPhaseTransform with InfoTransformer with Annotati
5454
val resultType1 = elimRepeated(resultType)
5555
val paramTypes1 =
5656
if (paramTypes.nonEmpty && paramTypes.last.isRepeatedParam) {
57-
val last = paramTypes.last.underlyingIfRepeated(tp.isJava)
57+
val last = paramTypes.last.underlyingIfRepeated(tp.isJavaMethod)
5858
paramTypes.init :+ last
5959
} else paramTypes
6060
tp.derivedLambdaType(paramNames, paramTypes1, resultType1)

compiler/src/dotty/tools/dotc/typer/Applications.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,7 @@ trait Applications extends Compatibility { self: Typer with Dynamic =>
557557
typedArgBuf.trimEnd(n)
558558
val elemtpt = TypeTree(elemFormal)
559559
val seqLit =
560-
if (methodType.isJava) JavaSeqLiteral(args, elemtpt)
560+
if (methodType.isJavaMethod) JavaSeqLiteral(args, elemtpt)
561561
else SeqLiteral(args, elemtpt)
562562
typedArgBuf += seqToRepeated(seqLit)
563563
}

compiler/src/dotty/tools/dotc/typer/ErrorReporting.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ object ErrorReporting {
116116
def dropJavaMethod(tp: Type): Type = tp match {
117117
case tp: PolyType =>
118118
tp.derivedLambdaType(resType = dropJavaMethod(tp.resultType))
119-
case tp: MethodType if tp.isJava =>
119+
case tp: MethodType if tp.isJavaMethod =>
120120
MethodType(tp.paramNames, tp.paramInfos, dropJavaMethod(tp.resultType))
121121
case tp => tp
122122
}

0 commit comments

Comments
 (0)