@@ -272,7 +272,7 @@ object Types {
272
272
if (lsym isSubClass rsym) lsym
273
273
else if (rsym isSubClass lsym) rsym
274
274
else NoSymbol
275
- case OrType (l, r) =>
275
+ case OrType (l, r) => // TODO does not conform to spec
276
276
val lsym = l.classSymbol
277
277
val rsym = r.classSymbol
278
278
if (lsym isSubClass rsym) rsym
@@ -295,7 +295,7 @@ object Types {
295
295
case AndType (l, r) =>
296
296
l.classSymbols union r.classSymbols
297
297
case OrType (l, r) =>
298
- l.classSymbols intersect r.classSymbols
298
+ l.classSymbols intersect r.classSymbols // TODO does not conform to spec
299
299
case _ =>
300
300
Nil
301
301
}
@@ -563,7 +563,7 @@ object Types {
563
563
*/
564
564
final def baseTypeRef (base : Symbol )(implicit ctx : Context ): Type = /* ctx.traceIndented(s"$this baseTypeRef $base")*/ /* >|>*/ track(" baseTypeRef" ) /* <|<*/ {
565
565
base.denot match {
566
- case classd : ClassDenotation => classd.baseTypeRefOf(this ) // widen.dealias)
566
+ case classd : ClassDenotation => classd.baseTypeRefOf(this )
567
567
case _ => NoType
568
568
}
569
569
}
@@ -598,22 +598,23 @@ object Types {
598
598
}
599
599
600
600
/** Widen from singleton type to its underlying non-singleton
601
- * base type by applying one or more `underlying` dereferences,
601
+ * base type by applying one or more `underlying` dereferences.
602
602
*/
603
- final def widenSingleton (implicit ctx : Context ): Type = this match {
603
+ final def widenSingleton (implicit ctx : Context ): Type = stripTypeVar match {
604
604
case tp : SingletonType if ! tp.isOverloaded => tp.underlying.widenSingleton
605
605
case _ => this
606
606
}
607
607
608
608
/** Widen from ExprType type to its result type.
609
+ * (Note: no stripTypeVar needed because TypeVar's can't refer to ExprTypes.)
609
610
*/
610
611
final def widenExpr : Type = this match {
611
612
case tp : ExprType => tp.resultType
612
613
case _ => this
613
614
}
614
615
615
616
/** Widen type if it is unstable (i.e. an EpxprType, or Termref to unstable symbol */
616
- final def widenIfUnstable (implicit ctx : Context ): Type = this match {
617
+ final def widenIfUnstable (implicit ctx : Context ): Type = stripTypeVar match {
617
618
case tp : ExprType => tp.resultType.widenIfUnstable
618
619
case tp : TermRef if ! tp.symbol.isStable => tp.underlying.widenIfUnstable
619
620
case _ => this
@@ -636,10 +637,16 @@ object Types {
636
637
case tp => tp
637
638
}
638
639
640
+ /** Peform successive widenings and dealiasings until none can be applied anymore */
641
+ final def widenDealias (implicit ctx : Context ): Type = {
642
+ val res = this .widen.dealias
643
+ if (res eq this ) res else res.widenDealias
644
+ }
645
+
639
646
/** Widen from constant type to its underlying non-constant
640
647
* base type.
641
648
*/
642
- final def deconst (implicit ctx : Context ): Type = this match {
649
+ final def deconst (implicit ctx : Context ): Type = stripTypeVar match {
643
650
case tp : ConstantType => tp.value.tpe
644
651
case _ => this
645
652
}
0 commit comments