@@ -181,7 +181,7 @@ object Types {
181181 * It makes no sense for it to be an alias type because isRef would always
182182 * return false in that case.
183183 */
184- def isRef (sym : Symbol , skipRefined : Boolean = true )(using Context ): Boolean = stripAnnots.stripTypeVar match {
184+ def isRef (sym : Symbol , skipRefined : Boolean = true )(using Context ): Boolean = stripped match {
185185 case this1 : TypeRef =>
186186 this1.info match { // see comment in Namer#typeDefSig
187187 case TypeAlias (tp) => tp.isRef(sym, skipRefined)
@@ -196,7 +196,7 @@ object Types {
196196 case _ => false
197197 }
198198
199- /** Is this type a (neither aliased nor applied) reference to class `sym`? */
199+ /** Is this type a (neither aliased nor applied nor annotated ) reference to class `sym`? */
200200 def isDirectRef (sym : Symbol )(using Context ): Boolean = stripTypeVar match {
201201 case this1 : TypeRef =>
202202 this1.name == sym.name && // avoid forcing info if names differ
@@ -369,7 +369,7 @@ object Types {
369369
370370 /** Is this a match type or a higher-kinded abstraction of one?
371371 */
372- def isMatch (using Context ): Boolean = stripTypeVar.stripAnnots match {
372+ def isMatch (using Context ): Boolean = stripped match {
373373 case _ : MatchType => true
374374 case tp : HKTypeLambda => tp.resType.isMatch
375375 case _ => false
@@ -1070,9 +1070,12 @@ object Types {
10701070 def stripTypeVar (using Context ): Type = this
10711071
10721072 /** Remove all AnnotatedTypes wrapping this type.
1073- */
1073+ */
10741074 def stripAnnots (using Context ): Type = this
10751075
1076+ /** Strip TypeVars and Annotation wrappers */
1077+ def stripped (using Context ): Type = this
1078+
10761079 def rewrapAnnots (tp : Type )(using Context ): Type = tp.stripTypeVar match {
10771080 case AnnotatedType (tp1, annot) => AnnotatedType (rewrapAnnots(tp1), annot)
10781081 case _ => this
@@ -1105,7 +1108,7 @@ object Types {
11051108 case tp : SingletonType => tp.underlying.widen
11061109 case tp : ExprType => tp.resultType.widen
11071110 case tp =>
1108- val tp1 = tp.stripTypeVar.stripAnnots
1111+ val tp1 = tp.stripped
11091112 if tp1 eq tp then tp
11101113 else
11111114 val tp2 = tp1.widen
@@ -1114,7 +1117,7 @@ object Types {
11141117 /** Widen from singleton type to its underlying non-singleton
11151118 * base type by applying one or more `underlying` dereferences.
11161119 */
1117- final def widenSingleton (using Context ): Type = stripTypeVar.stripAnnots match {
1120+ final def widenSingleton (using Context ): Type = stripped match {
11181121 case tp : SingletonType if ! tp.isOverloaded => tp.underlying.widenSingleton
11191122 case _ => this
11201123 }
@@ -4302,6 +4305,8 @@ object Types {
43024305 if (inst.exists) inst.stripTypeVar else origin
43034306 }
43044307
4308+ override def stripped (using Context ): Type = stripTypeVar.stripped
4309+
43054310 /** If the variable is instantiated, its instance, otherwise its origin */
43064311 override def underlying (using Context ): Type = {
43074312 val inst = instanceOpt
@@ -4705,6 +4710,8 @@ object Types {
47054710
47064711 override def stripAnnots (using Context ): Type = parent.stripAnnots
47074712
4713+ override def stripped (using Context ): Type = parent.stripped
4714+
47084715 private var isRefiningKnown = false
47094716 private var isRefiningCache : Boolean = _
47104717
0 commit comments