@@ -77,9 +77,7 @@ object Types {
7777 * +- GroundType -+- AndType
7878 * +- OrType
7979 * +- MethodOrPoly ---+-- PolyType
80- * +-- MethodType ---+- ImplicitMethodType
81- * +- ContextualMethodType
82- * | +- JavaMethodType
80+ * | +-- MethodType
8381 * +- ClassInfo
8482 * |
8583 * +- NoType
@@ -400,9 +398,6 @@ object Types {
400398 /** Is this an alias TypeBounds? */
401399 final def isTypeAlias : Boolean = this .isInstanceOf [TypeAlias ]
402400
403- /** Is this a MethodType which is from Java? */
404- def isJavaMethod : Boolean = false
405-
406401 /** Is this a Method or PolyType which has implicit or contextual parameters? */
407402 def isImplicitMethod : Boolean = false
408403
@@ -1725,35 +1720,22 @@ object Types {
17251720 * @param dropLast The number of trailing parameters that should be dropped
17261721 * when forming the function type.
17271722 */
1728- def toFunctionType (dropLast : Int = 0 )(using Context ): Type = this match {
1723+ def toFunctionType (isJava : Boolean , dropLast : Int = 0 )(using Context ): Type = this match {
17291724 case mt : MethodType if ! mt.isParamDependent =>
17301725 val formals1 = if (dropLast == 0 ) mt.paramInfos else mt.paramInfos dropRight dropLast
17311726 val isContextual = mt.isContextualMethod && ! ctx.erasedTypes
17321727 val isErased = mt.isErasedMethod && ! ctx.erasedTypes
17331728 val result1 = mt.nonDependentResultApprox match {
1734- case res : MethodType => res.toFunctionType()
1729+ case res : MethodType => res.toFunctionType(isJava )
17351730 case res => res
17361731 }
17371732 val funType = defn.FunctionOf (
1738- formals1 mapConserve (_.translateFromRepeated(toArray = mt.isJavaMethod )),
1733+ formals1 mapConserve (_.translateFromRepeated(toArray = isJava )),
17391734 result1, isContextual, isErased)
17401735 if (mt.isResultDependent) RefinedType (funType, nme.apply, mt)
17411736 else funType
17421737 }
17431738
1744- final def dropJavaMethod (using Context ): Type = this match
1745- case pt : PolyType => pt.derivedLambdaType(resType = pt.resType.dropJavaMethod)
1746-
1747- case mt : MethodType =>
1748- if mt.isJavaMethod then
1749- MethodType .apply(mt.paramNames, mt.paramInfos, mt.resType.dropJavaMethod)
1750- else
1751- mt.derivedLambdaType(resType = mt.resType.dropJavaMethod)
1752-
1753- case _ => this
1754-
1755- end dropJavaMethod
1756-
17571739 /** The signature of this type. This is by default NotAMethod,
17581740 * but is overridden for PolyTypes, MethodTypes, and TermRef types.
17591741 * (the reason why we deviate from the "final-method-with-pattern-match-in-base-class"
@@ -3558,7 +3540,6 @@ object Types {
35583540
35593541 def companion : MethodTypeCompanion
35603542
3561- final override def isJavaMethod : Boolean = companion eq JavaMethodType
35623543 final override def isImplicitMethod : Boolean =
35633544 companion.eq(ImplicitMethodType ) ||
35643545 companion.eq(ErasedImplicitMethodType ) ||
@@ -3654,21 +3635,14 @@ object Types {
36543635 }
36553636
36563637 object MethodType extends MethodTypeCompanion (" MethodType" ) {
3657- def companion (isJava : Boolean = false , isContextual : Boolean = false , isImplicit : Boolean = false , isErased : Boolean = false ): MethodTypeCompanion =
3658- if (isJava) {
3659- assert(! isImplicit)
3660- assert(! isErased)
3661- assert(! isContextual)
3662- JavaMethodType
3663- }
3664- else if (isContextual)
3638+ def companion (isContextual : Boolean = false , isImplicit : Boolean = false , isErased : Boolean = false ): MethodTypeCompanion =
3639+ if (isContextual)
36653640 if (isErased) ErasedContextualMethodType else ContextualMethodType
36663641 else if (isImplicit)
36673642 if (isErased) ErasedImplicitMethodType else ImplicitMethodType
36683643 else
36693644 if (isErased) ErasedMethodType else MethodType
36703645 }
3671- object JavaMethodType extends MethodTypeCompanion (" JavaMethodType" )
36723646 object ErasedMethodType extends MethodTypeCompanion (" ErasedMethodType" )
36733647 object ContextualMethodType extends MethodTypeCompanion (" ContextualMethodType" )
36743648 object ErasedContextualMethodType extends MethodTypeCompanion (" ErasedContextualMethodType" )
0 commit comments