Skip to content

Commit 3c6cf39

Browse files
oderskyDarkDimius
authored andcommitted
TypeTestCasts should test and cast wrt erased types
1 parent 74fa107 commit 3c6cf39

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import core.TypeErasure.isUnboundedGeneric
1313
import typer.ErrorReporting._
1414
import ast.Trees._
1515
import Erasure.Boxing._
16+
import core.TypeErasure._
1617

1718
/** This transform normalizes type tests and type casts,
1819
* also replacing type tests with singleton argument type with reference equality check
@@ -92,11 +93,11 @@ trait TypeTestsCasts {
9293
else
9394
derivedTree(qual, defn.Any_asInstanceOf, argType)
9495
}
95-
96+
def erasedArg = erasure(tree.args.head.tpe)
9697
if (sym eq defn.Any_isInstanceOf)
97-
transformIsInstanceOf(qual, tree.args.head.tpe)
98+
transformIsInstanceOf(qual, erasedArg)
9899
else if (sym eq defn.Any_asInstanceOf)
99-
transformAsInstanceOf(tree.args.head.tpe)
100+
transformAsInstanceOf(erasedArg)
100101
else tree
101102

102103
case _ =>

0 commit comments

Comments
 (0)