Skip to content

Commit f786ce5

Browse files
committed
Don't drop impure expressions when eliding isInstanceOf tests.
1 parent 82afe5f commit f786ce5

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ trait TypeTestsCasts {
4747

4848
def transformIsInstanceOf(expr:Tree, argType: Type): Tree = {
4949
def argCls = argType.classSymbol
50-
if (expr.tpe <:< argType)
50+
if ((expr.tpe <:< argType) && isPureExpr(expr))
5151
Literal(Constant(true)) withPos tree.pos
5252
else if (argCls.isPrimitiveValueClass)
5353
if (qualCls.isPrimitiveValueClass) Literal(Constant(qualCls == argCls)) withPos tree.pos

0 commit comments

Comments
 (0)