Skip to content

Commit 15452c7

Browse files
committed
References with constant type are pure
Before the fix to #8058, a reference `x` with constant type `0` was deemed to have a stable member symbol since its symbol did not exist. That's what gave the reference the `PurePath` status. Now that `isStableMember` is fixed, this needs to be asserted explicitly.
1 parent c64e676 commit 15452c7

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,9 @@ trait TypedTreeInfo extends TreeInfo[Type] { self: Trees.Instance[Type] =>
442442

443443
/** The purity level of this reference.
444444
* @return
445-
* PurePath if reference is (nonlazy and stable) or to a parameterized function
445+
* PurePath if reference is (nonlazy and stable)
446+
* or to a parameterized function
447+
* or its type is a constant type
446448
* IdempotentPath if reference is lazy and stable
447449
* Impure otherwise
448450
* @DarkDimius: need to make sure that lazy accessor methods have Lazy and Stable
@@ -452,6 +454,7 @@ trait TypedTreeInfo extends TreeInfo[Type] { self: Trees.Instance[Type] =>
452454
val sym = tree.symbol
453455
if (!tree.hasType) Impure
454456
else if (!tree.tpe.widen.isParameterless || sym.isEffectivelyErased) PurePath
457+
else if tree.tpe.isInstanceOf[ConstantType] then PurePath
455458
else if (!sym.isStableMember) Impure
456459
else if (sym.is(Module))
457460
if (sym.moduleClass.isNoInitsClass) PurePath else IdempotentPath

0 commit comments

Comments
 (0)