@@ -2684,15 +2684,13 @@ object Types {
2684
2684
paramInfosExp : MethodType => List [Type ],
2685
2685
resultTypeExp : MethodType => Type )
2686
2686
extends MethodOrPoly with TermLambda with NarrowCached { thisMethodType =>
2687
- import MethodKinds ._
2688
2687
2689
2688
type This = MethodType
2690
2689
2691
- def kind : MethodKind
2692
- final def companion : MethodTypeCompanion = MethodType .withKind(kind)
2690
+ def companion : MethodTypeCompanion
2693
2691
2694
- final override def isJavaMethod : Boolean = kind is JavaKind
2695
- final override def isImplicitMethod : Boolean = kind is ImplicitKind
2692
+ final override def isJavaMethod : Boolean = companion.isJava
2693
+ final override def isImplicitMethod : Boolean = companion.isImplicit
2696
2694
2697
2695
val paramInfos = paramInfosExp(this )
2698
2696
val resType = resultTypeExp(this )
@@ -2704,7 +2702,7 @@ object Types {
2704
2702
protected def prefixString = " MethodType"
2705
2703
}
2706
2704
2707
- final class CachedMethodType (paramNames : List [TermName ])(paramInfosExp : MethodType => List [Type ], resultTypeExp : MethodType => Type , val kind : MethodKinds . MethodKind )
2705
+ final class CachedMethodType (paramNames : List [TermName ])(paramInfosExp : MethodType => List [Type ], resultTypeExp : MethodType => Type , val companion : MethodTypeCompanion )
2708
2706
extends MethodType (paramNames)(paramInfosExp, resultTypeExp)
2709
2707
2710
2708
abstract class LambdaTypeCompanion [N <: Name , PInfo <: Type , LT <: LambdaType ] {
@@ -2750,10 +2748,10 @@ object Types {
2750
2748
def syntheticParamName (n : Int ) = tpnme.syntheticTypeParamName(n)
2751
2749
}
2752
2750
2753
- abstract class MethodTypeCompanion extends TermLambdaCompanion [MethodType ] {
2754
- import MethodKinds ._
2751
+ abstract class MethodTypeCompanion extends TermLambdaCompanion [MethodType ] { self =>
2755
2752
2756
- def kind : MethodKind
2753
+ def isJava : Boolean = false
2754
+ def isImplicit : Boolean = false
2757
2755
2758
2756
/** Produce method type from parameter symbols, with special mappings for repeated
2759
2757
* and inline parameters:
@@ -2785,7 +2783,7 @@ object Types {
2785
2783
}
2786
2784
2787
2785
final def apply (paramNames : List [TermName ])(paramInfosExp : MethodType => List [Type ], resultTypeExp : MethodType => Type )(implicit ctx : Context ): MethodType =
2788
- checkValid(new CachedMethodType (paramNames)(paramInfosExp, resultTypeExp, kind ))
2786
+ checkValid(new CachedMethodType (paramNames)(paramInfosExp, resultTypeExp, self ))
2789
2787
2790
2788
def checkValid (mt : MethodType )(implicit ctx : Context ): mt.type = {
2791
2789
if (Config .checkMethodTypes)
@@ -2798,39 +2796,20 @@ object Types {
2798
2796
}
2799
2797
}
2800
2798
2801
- object MethodKinds {
2802
- type MethodKind = Byte
2803
-
2804
- val Plain : MethodKind = 0 : Byte
2805
-
2806
- // Flags
2807
- val JavaKind : MethodKind = 1 : Byte
2808
- val ImplicitKind : MethodKind = 2 : Byte
2809
-
2810
- def makeMethodKind (isJava : Boolean , isImplicit : Boolean ): MethodKind = {
2811
- var mk : Int = Plain
2812
- if (isJava) mk |= JavaKind
2813
- if (isImplicit) mk |= ImplicitKind
2814
- mk.toByte
2815
- }
2816
-
2817
- implicit class MethodKindsOps (mk : MethodKind ) {
2818
- def is (that : MethodKind ): Boolean = (mk & that) == that
2799
+ object MethodType extends MethodTypeCompanion {
2800
+ def withKind (isJava : Boolean = false , isImplicit : Boolean = false ): MethodTypeCompanion = {
2801
+ if (isJava) JavaMethodType
2802
+ else if (isImplicit) ImplicitMethodType
2803
+ else MethodType
2819
2804
}
2820
2805
}
2821
2806
2822
- object MethodType extends MethodTypeCompanion { self =>
2823
- import MethodKinds ._
2824
-
2825
- def kind : MethodKind = Plain
2826
-
2827
- private val methodTypeCompanions : mutable.Map [MethodKind , MethodTypeCompanion ] = mutable.Map .empty
2828
- def withKind (methodKind : MethodKind ): MethodTypeCompanion =
2829
- if (methodKind == Plain ) this
2830
- else methodTypeCompanions.getOrElseUpdate(methodKind, new MethodTypeCompanion { def kind = methodKind })
2807
+ object JavaMethodType extends MethodTypeCompanion {
2808
+ override def isJava : Boolean = true
2809
+ }
2831
2810
2832
- def withKind ( isJava : Boolean = false , isImplicit : Boolean = false ) : MethodTypeCompanion =
2833
- withKind(makeMethodKind(isJava, isImplicit))
2811
+ object ImplicitMethodType extends MethodTypeCompanion {
2812
+ override def isImplicit : Boolean = true
2834
2813
}
2835
2814
2836
2815
/** A ternary extractor for MethodType */
0 commit comments