Skip to content

Commit d3f49de

Browse files
committed
Added assertion that casts never go to singleton types.
Disabled for now, awaiting a fix.
1 parent e6fd1bb commit d3f49de

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,10 @@ object Erasure {
133133

134134
/** Generate a synthetic cast operation from tree.tpe to pt.
135135
*/
136-
def cast(tree: Tree, pt: Type)(implicit ctx: Context): Tree =
136+
def cast(tree: Tree, pt: Type)(implicit ctx: Context): Tree = {
137+
// TODO: The commented out assertion fails for tailcall/t6574.scala
138+
// Fix the problem and enable the assertion.
139+
// assert(!pt.isInstanceOf[SingletonType], pt)
137140
if (pt isRef defn.UnitClass) unbox(tree, pt)
138141
else (tree.tpe, pt) match {
139142
case (defn.ArrayType(treeElem), defn.ArrayType(ptElem))
@@ -144,6 +147,7 @@ object Erasure {
144147
ctx.log(s"casting from ${tree.showSummary}: ${tree.tpe.show} to ${pt.show}")
145148
mkAsInstanceOf(tree, pt)
146149
}
150+
}
147151

148152
/** Adaptation of an expression `e` to an expected type `PT`, applying the following
149153
* rewritings exhaustively as long as the type of `e` is not a subtype of `PT`.

0 commit comments

Comments
 (0)