Skip to content

Commit 8948b09

Browse files
authored
Avoid checking purity of Apply without symbols (#16221)
2 parents 0044c89 + 9e71095 commit 8948b09

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,7 @@ trait TypedTreeInfo extends TreeInfo[Type] { self: Trees.Instance[Type] =>
512512
sym.owner.isPrimitiveValueClass
513513
|| sym.owner == defn.StringClass
514514
|| defn.pureMethods.contains(sym)
515-
tree.tpe.isInstanceOf[ConstantType] && isKnownPureOp(tree.symbol) // A constant expression with pure arguments is pure.
515+
tree.tpe.isInstanceOf[ConstantType] && tree.symbol != NoSymbol && isKnownPureOp(tree.symbol) // A constant expression with pure arguments is pure.
516516
|| fn.symbol.isStableMember && !fn.symbol.is(Lazy) // constructors of no-inits classes are stable
517517

518518
/** The purity level of this reference.

tests/pos/i16174.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
val f = [A] => (a: A) => a
2+
val x1 = f.apply[Int](4)
3+
val x2 = f.apply[4](4)

0 commit comments

Comments
 (0)