@@ -45,14 +45,14 @@ object Checkable {
45
45
*
46
46
* Replace `T @unchecked` and pattern binder types (e.g., `_$1`) in P with WildcardType, then check:
47
47
*
48
- * 1. if `P` is a singleton type , TRUE
49
- * 2. if `P` is WildcardType , TRUE
48
+ * 1. if `X <:< P` , TRUE
49
+ * 2. if `P` is a singleton type , TRUE
50
50
* 3. if `P` refers to an abstract type member or type parameter, `X <:< P`
51
51
* 4. if `P = Array[T]`, checkable(E, T) where `E` is the element type of `X`, defaults to `Any`.
52
52
* 5. if `P` is `pre.F[Ts]` and `pre.F` refers to a class which is not `Array`:
53
53
* (a) replace `Ts` with fresh type variables `Xs`
54
- * (b) ` pre.F[Xs] <:< X` with `Xs` instantiated as `Es`
55
- * (c) `pre.F[Es ] <:< P`
54
+ * (b) constrain `Xs` with ` pre.F[Xs] <:< X` (may fail)
55
+ * (c) instantiate Xs and check `pre.F[Xs ] <:< P`
56
56
* 6. if `P = T1 | T2` or `P = T1 & T2`, checkable(X, T1) && checkable(X, T2).
57
57
* 7. if `P` is a refinement type, FALSE
58
58
* 8. otherwise, TRUE
@@ -76,33 +76,34 @@ object Checkable {
76
76
val tvars = constrained(typeLambda, untpd.EmptyTree , alwaysAddTypeVars = true )._2.map(_.tpe)
77
77
val P1 = tycon.appliedTo(tvars)
78
78
79
+ debug.println(" P : " + P .show)
79
80
debug.println(" P1 : " + P1 .show)
80
81
debug.println(" X : " + X .show)
81
82
82
- (P1 <:< X ) && {
83
- val res = isFullyDefined(P1 , ForceDegree .noBottom) && P1 <:< P
84
- debug.println(" P1 <:< P = " + res)
85
- res
86
- }
83
+ P1 <:< X // may fail, ignore
84
+
85
+ val res = isFullyDefined(P1 , ForceDegree .noBottom) && P1 <:< P
86
+ debug.println(" P1 : " + P1 )
87
+ debug.println(" P1 <:< P = " + res)
88
+ res
87
89
}
88
90
89
- def recur (X : Type , P : Type ): Boolean = P match {
91
+ def recur (X : Type , P : Type ): Boolean = ( X <:< P ) || ( P match {
90
92
case _ : SingletonType => true
91
- case WildcardType => true
92
93
case _ : TypeProxy
93
- if isAbstract(P ) => X <:< P
94
+ if isAbstract(P ) => false
94
95
case defn.ArrayOf (tpT) =>
95
96
X match {
96
97
case defn.ArrayOf (tpE) => recur(tpE, tpT)
97
98
case _ => recur(defn.AnyType , tpT)
98
99
}
99
- case tpe : AppliedType => isClassDetermined(X , tpe)
100
+ case tpe : AppliedType => isClassDetermined(X , tpe)(ctx.fresh.setNewTyperState())
100
101
case AndType (tp1, tp2) => recur(X , tp1) && recur(X , tp2)
101
102
case OrType (tp1, tp2) => recur(X , tp1) && recur(X , tp2)
102
103
case AnnotatedType (t, an) => recur(X , t)
103
104
case _ : RefinedType => false
104
105
case _ => true
105
- }
106
+ })
106
107
107
108
val res = recur(X .widen, replaceBinderMap.apply(P ))
108
109
0 commit comments