diff options
Diffstat (limited to 'src/dotty/tools/dotc/ast/TreeInfo.scala')
-rw-r--r-- | src/dotty/tools/dotc/ast/TreeInfo.scala | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/dotty/tools/dotc/ast/TreeInfo.scala b/src/dotty/tools/dotc/ast/TreeInfo.scala index 416c64079..adc268943 100644 --- a/src/dotty/tools/dotc/ast/TreeInfo.scala +++ b/src/dotty/tools/dotc/ast/TreeInfo.scala @@ -278,9 +278,9 @@ trait TypedTreeInfo extends TreeInfo[Type] {self: Trees.Instance[Type] => | Literal(_) => true case Ident(_) => - tree.symbol is Stable + isIdempotentRef(tree) case Select(qual, _) => - tree.symbol.isStable && isIdempotentExpr(qual) + isIdempotentRef(tree) && isIdempotentExpr(qual) case TypeApply(fn, _) => isIdempotentExpr(fn) /* @@ -305,6 +305,9 @@ trait TypedTreeInfo extends TreeInfo[Type] {self: Trees.Instance[Type] => false } + private def isIdempotentRef(tree: tpd.Tree)(implicit ctx: Context) = + tree.symbol.isStable || !tree.tpe.widen.isParameterless + /** Is symbol potentially a getter of a mutable variable? */ def mayBeVarGetter(sym: Symbol)(implicit ctx: Context): Boolean = { |