Skip to content

Commit e881350

Browse files
committed
Applications of erased functions are always pure
...by definition since no code is generated, no side effects can be performed either.
1 parent 1fd37a3 commit e881350

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

compiler/src/dotty/tools/dotc/ast/TreeInfo.scala

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -393,20 +393,21 @@ trait TypedTreeInfo extends TreeInfo[Type] { self: Trees.Instance[Type] =>
393393
case Ident(_) =>
394394
refPurity(tree)
395395
case Select(qual, _) =>
396-
refPurity(tree).min(exprPurity(qual))
396+
if (tree.symbol.is(Erased)) Pure
397+
else refPurity(tree).min(exprPurity(qual))
397398
case New(_) =>
398399
SimplyPure
399400
case TypeApply(fn, _) =>
400-
exprPurity(fn)
401+
if (fn.symbol.is(Erased)) Pure else exprPurity(fn)
401402
case Apply(fn, args) =>
402403
def isKnownPureOp(sym: Symbol) =
403404
sym.owner.isPrimitiveValueClass || sym.owner == defn.StringClass
404405
if (tree.tpe.isInstanceOf[ConstantType] && isKnownPureOp(tree.symbol)
405406
// A constant expression with pure arguments is pure.
406407
|| fn.symbol.isStable)
407408
minOf(exprPurity(fn), args.map(exprPurity)) `min` Pure
408-
else
409-
Impure
409+
else if (fn.symbol.is(Erased)) Pure
410+
else Impure
410411
case Typed(expr, _) =>
411412
exprPurity(expr)
412413
case Block(stats, expr) =>

0 commit comments

Comments
 (0)