@@ -181,7 +181,7 @@ object Types {
181
181
* It makes no sense for it to be an alias type because isRef would always
182
182
* return false in that case.
183
183
*/
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 {
185
185
case this1 : TypeRef =>
186
186
this1.info match { // see comment in Namer#typeDefSig
187
187
case TypeAlias (tp) => tp.isRef(sym, skipRefined)
@@ -196,7 +196,7 @@ object Types {
196
196
case _ => false
197
197
}
198
198
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`? */
200
200
def isDirectRef (sym : Symbol )(using Context ): Boolean = stripTypeVar match {
201
201
case this1 : TypeRef =>
202
202
this1.name == sym.name && // avoid forcing info if names differ
@@ -369,7 +369,7 @@ object Types {
369
369
370
370
/** Is this a match type or a higher-kinded abstraction of one?
371
371
*/
372
- def isMatch (using Context ): Boolean = stripTypeVar.stripAnnots match {
372
+ def isMatch (using Context ): Boolean = stripped match {
373
373
case _ : MatchType => true
374
374
case tp : HKTypeLambda => tp.resType.isMatch
375
375
case _ => false
@@ -1070,9 +1070,12 @@ object Types {
1070
1070
def stripTypeVar (using Context ): Type = this
1071
1071
1072
1072
/** Remove all AnnotatedTypes wrapping this type.
1073
- */
1073
+ */
1074
1074
def stripAnnots (using Context ): Type = this
1075
1075
1076
+ /** Strip TypeVars and Annotation wrappers */
1077
+ def stripped (using Context ): Type = this
1078
+
1076
1079
def rewrapAnnots (tp : Type )(using Context ): Type = tp.stripTypeVar match {
1077
1080
case AnnotatedType (tp1, annot) => AnnotatedType (rewrapAnnots(tp1), annot)
1078
1081
case _ => this
@@ -1105,7 +1108,7 @@ object Types {
1105
1108
case tp : SingletonType => tp.underlying.widen
1106
1109
case tp : ExprType => tp.resultType.widen
1107
1110
case tp =>
1108
- val tp1 = tp.stripTypeVar.stripAnnots
1111
+ val tp1 = tp.stripped
1109
1112
if tp1 eq tp then tp
1110
1113
else
1111
1114
val tp2 = tp1.widen
@@ -1114,7 +1117,7 @@ object Types {
1114
1117
/** Widen from singleton type to its underlying non-singleton
1115
1118
* base type by applying one or more `underlying` dereferences.
1116
1119
*/
1117
- final def widenSingleton (using Context ): Type = stripTypeVar.stripAnnots match {
1120
+ final def widenSingleton (using Context ): Type = stripped match {
1118
1121
case tp : SingletonType if ! tp.isOverloaded => tp.underlying.widenSingleton
1119
1122
case _ => this
1120
1123
}
@@ -4302,6 +4305,8 @@ object Types {
4302
4305
if (inst.exists) inst.stripTypeVar else origin
4303
4306
}
4304
4307
4308
+ override def stripped (using Context ): Type = stripTypeVar.stripped
4309
+
4305
4310
/** If the variable is instantiated, its instance, otherwise its origin */
4306
4311
override def underlying (using Context ): Type = {
4307
4312
val inst = instanceOpt
@@ -4705,6 +4710,8 @@ object Types {
4705
4710
4706
4711
override def stripAnnots (using Context ): Type = parent.stripAnnots
4707
4712
4713
+ override def stripped (using Context ): Type = parent.stripped
4714
+
4708
4715
private var isRefiningKnown = false
4709
4716
private var isRefiningCache : Boolean = _
4710
4717
0 commit comments