File tree 1 file changed +6
-6
lines changed
compiler/src/dotty/tools/dotc/transform
1 file changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -26,8 +26,9 @@ import config.Printers.{ transforms => debug }
26
26
*/
27
27
object TypeTestsCasts {
28
28
import ast .tpd ._
29
- import typer .Inferencing .maximizeType
30
- import typer .ProtoTypes .constrained
29
+ import typer ._
30
+ import typer .Inferencing ._
31
+ import typer .ProtoTypes ._
31
32
32
33
/** Whether `(x:X).isInstanceOf[P]` can be checked at runtime?
33
34
*
@@ -77,14 +78,12 @@ object TypeTestsCasts {
77
78
78
79
/** Approximate type parameters depending on variance */
79
80
def stripTypeParam (tp : Type )(using Context ) = new ApproximatingTypeMap {
81
+ val boundTypeParams = util.HashMap [TypeRef , TypeVar ]()
80
82
def apply (tp : Type ): Type = tp match {
81
83
case _ : MatchType =>
82
84
tp // break cycles
83
85
case tp : TypeRef if isBounds(tp.underlying) =>
84
- def lo = apply(tp.info.loBound.subst(tp.symbol :: Nil , WildcardType :: Nil ))
85
- def hi = apply(tp.info.hiBound.subst(tp.symbol :: Nil , WildcardType :: Nil ))
86
-
87
- range(lo, hi)
86
+ boundTypeParams.getOrElseUpdate(tp, newTypeVar(tp.underlying.toBounds))
88
87
case _ =>
89
88
mapOver(tp)
90
89
}
@@ -127,6 +126,7 @@ object TypeTestsCasts {
127
126
debug.println(" P1 <:< P = " + res)
128
127
129
128
res
129
+
130
130
}
131
131
132
132
def recur (X : Type , P : Type ): Boolean = (X <:< P ) || (P .dealias match {
You can’t perform that action at this time.
0 commit comments