Skip to content

Commit 38ecc56

Browse files
committed
Relax erased type check
Now that mixin forwarders are generated after erasure, we may end up with a reference to ThisType(*:) after erasure in Tuple.scala, because *: extends NonEmptyTuple which erases to Product, and Product has methods that should get mixin forwarders. This fixes the tastyBootstrap test broken after the last commit.
1 parent 18de547 commit 38ecc56

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

compiler/src/dotty/tools/dotc/transform/Erasure.scala

+10-6
Original file line numberDiff line numberDiff line change
@@ -134,13 +134,17 @@ class Erasure extends Phase with DenotTransformer {
134134
}
135135

136136
def assertErased(tp: Type, tree: tpd.Tree = tpd.EmptyTree)(implicit ctx: Context): Unit = {
137-
def isAllowed(cls: Symbol, sourceName: String) =
138-
tp.typeSymbol == cls && ctx.compilationUnit.source.file.name == sourceName
137+
def isAllowed(tp: Type, cls: Symbol, sourceName: String): Boolean = tp match {
138+
case tp: ThisType =>
139+
isAllowed(tp.underlying, cls, sourceName)
140+
case _ =>
141+
tp.typeSymbol == cls && ctx.compilationUnit.source.file.name == sourceName
142+
}
139143
assert(isErasedType(tp) ||
140-
isAllowed(defn.ArrayClass, "Array.scala") ||
141-
isAllowed(defn.TupleClass, "Tuple.scala") ||
142-
isAllowed(defn.NonEmptyTupleClass, "Tuple.scala") ||
143-
isAllowed(defn.PairClass, "Tuple.scala"),
144+
isAllowed(tp, defn.ArrayClass, "Array.scala") ||
145+
isAllowed(tp, defn.TupleClass, "Tuple.scala") ||
146+
isAllowed(tp, defn.NonEmptyTupleClass, "Tuple.scala") ||
147+
isAllowed(tp, defn.PairClass, "Tuple.scala"),
144148
i"The type $tp - ${tp.toString} of class ${tp.getClass} of tree $tree : ${tree.tpe} / ${tree.getClass} is illegal after erasure, phase = ${ctx.phase.prev}")
145149
}
146150
}

0 commit comments

Comments
 (0)