@@ -58,9 +58,7 @@ object Checkable {
5858 * 8. otherwise, TRUE
5959 */
6060 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
6462
6563 def replaceBinderMap (implicit ctx : Context ) = new TypeMap {
6664 def apply (tp : Type ) = tp match {
@@ -72,38 +70,40 @@ object Checkable {
7270 }
7371 }
7472
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
7775 val tvars = tycon.typeParams.map { tparam => newTypeVar(tparam.paramInfo.bounds) }
7876 val P1 = tycon.appliedTo(tvars)
7977
8078 debug.println(" P1 : " + P1 .show)
81- debug.println(" X : " + X .widen )
79+ debug.println(" X : " + X .show )
8280
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
8583 debug.println(" P1 <:< P = " + res)
8684 res
8785 }
8886 }
8987
90- val res = replaceBinderMap.apply(P ) match {
91- case _ if isAbstract => X <:< P
88+ def recur (X : Type , P : Type ): Boolean = P match {
9289 case _ : SingletonType => true
9390 case WildcardType => true
91+ case _ if isAbstract(P ) => X <:< P
9492 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)
9896 }
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)
103101 case _ : RefinedType => false
104102 case _ => true
105103 }
106104
105+ val res = recur(X .widen, replaceBinderMap.apply(P ))
106+
107107 debug.println(i " checking ${X .show} isInstanceOf ${P } = $res" )
108108
109109 res
0 commit comments