Skip to content

Commit 81b27b1

Browse files
committed
Keep SuperTypes around after erasure.
The reason is that otherwise the non-private member super.x gets merged with the private member this.x and that causes a double binding violation.
1 parent 5cc99d4 commit 81b27b1

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/dotty/tools/dotc/TypeErasure.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import util.DotClass
1414
* AnnotatedType
1515
* MethodType
1616
* ThisType
17+
* SuperType
1718
* ClassInfo (NoPrefix, ...)
1819
* NoType
1920
* NoPrefix
@@ -43,7 +44,7 @@ object TypeErasure {
4344
tp.paramTypes.forall(isErasedType) && isErasedType(tp.resultType)
4445
case tp @ ClassInfo(pre, _, parents, decls, _) =>
4546
isErasedType(pre) && parents.forall(isErasedType) //&& decls.forall(sym => isErasedType(sym.info)) && isErasedType(tp.selfType)
46-
case NoType | NoPrefix | WildcardType | ErrorType =>
47+
case NoType | NoPrefix | WildcardType | ErrorType | SuperType(_, _) =>
4748
true
4849
case _ =>
4950
false
@@ -237,7 +238,7 @@ class TypeErasure(isJava: Boolean, isSemi: Boolean, isConstructor: Boolean, wild
237238
case tp: TermRef =>
238239
assert(tp.symbol.exists, tp)
239240
TermRef(NoPrefix, tp.symbol.asTerm)
240-
case ThisType(_) =>
241+
case ThisType(_) | SuperType(_, _) =>
241242
tp
242243
case ExprType(rt) =>
243244
MethodType(Nil, Nil, this(rt))

src/dotty/tools/dotc/core/Types.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1599,8 +1599,7 @@ object Types {
15991599

16001600
object SuperType {
16011601
def apply(thistpe: Type, supertpe: Type)(implicit ctx: Context): Type =
1602-
if (ctx.erasedTypes) thistpe
1603-
else unique(new CachedSuperType(thistpe, supertpe))
1602+
unique(new CachedSuperType(thistpe, supertpe))
16041603
}
16051604

16061605
/** A constant type with single `value`. */

0 commit comments

Comments
 (0)