@@ -58,9 +58,7 @@ object Checkable {
58
58
* 8. otherwise, TRUE
59
59
*/
60
60
def checkable (X : Type , P : Type )(implicit ctx : Context ): Boolean = {
61
- def Psym = P .dealias.typeSymbol
62
-
63
- def isAbstract = ! Psym .isClass
61
+ def isAbstract (P : Type ) = ! P .dealias.typeSymbol.isClass
64
62
65
63
def replaceBinderMap (implicit ctx : Context ) = new TypeMap {
66
64
def apply (tp : Type ) = tp match {
@@ -72,38 +70,40 @@ object Checkable {
72
70
}
73
71
}
74
72
75
- def isClassDetermined (tpe : AppliedType )(implicit ctx : Context ) = {
76
- val AppliedType (tycon, _) = tpe
73
+ def isClassDetermined (X : Type , P : AppliedType )(implicit ctx : Context ) = {
74
+ val AppliedType (tycon, _) = P
77
75
val tvars = tycon.typeParams.map { tparam => newTypeVar(tparam.paramInfo.bounds) }
78
76
val P1 = tycon.appliedTo(tvars)
79
77
80
78
debug.println(" P1 : " + P1 .show)
81
- debug.println(" X : " + X .widen )
79
+ debug.println(" X : " + X .show )
82
80
83
- ! (P1 <:< X .widen ) || {
84
- val res = isFullyDefined(P1 , ForceDegree .noBottom) && P1 <:< tpe
81
+ ! (P1 <:< X ) || {
82
+ val res = isFullyDefined(P1 , ForceDegree .noBottom) && P1 <:< P
85
83
debug.println(" P1 <:< P = " + res)
86
84
res
87
85
}
88
86
}
89
87
90
- val res = replaceBinderMap.apply(P ) match {
91
- case _ if isAbstract => X <:< P
88
+ def recur (X : Type , P : Type ): Boolean = P match {
92
89
case _ : SingletonType => true
93
90
case WildcardType => true
91
+ case _ if isAbstract(P ) => X <:< P
94
92
case defn.ArrayOf (tpT) =>
95
- X .widen match {
96
- case defn.ArrayOf (tpE) => checkable (tpE, tpT)
97
- case _ => checkable (defn.AnyType , tpT)
93
+ X match {
94
+ case defn.ArrayOf (tpE) => recur (tpE, tpT)
95
+ case _ => recur (defn.AnyType , tpT)
98
96
}
99
- case tpe : AppliedType => isClassDetermined(tpe)
100
- case AndType (tp1, tp2) => checkable (X , tp1) && checkable (X , tp2)
101
- case OrType (tp1, tp2) => checkable (X , tp1) && checkable (X , tp2)
102
- case AnnotatedType (t, an) => checkable (X , t)
97
+ case tpe : AppliedType => isClassDetermined(X , tpe)
98
+ case AndType (tp1, tp2) => recur (X , tp1) && recur (X , tp2)
99
+ case OrType (tp1, tp2) => recur (X , tp1) && recur (X , tp2)
100
+ case AnnotatedType (t, an) => recur (X , t)
103
101
case _ : RefinedType => false
104
102
case _ => true
105
103
}
106
104
105
+ val res = recur(X .widen, replaceBinderMap.apply(P ))
106
+
107
107
debug.println(i " checking ${X .show} isInstanceOf ${P } = $res" )
108
108
109
109
res
0 commit comments