File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed
compiler/src/dotty/tools/dotc/transform/localopt Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,8 @@ import transform.TreeTransforms.{MiniPhaseTransform, TransformerInfo}
1212import config .Printers .simplify
1313import ast .tpd
1414
15+ import scala .annotation .tailrec
16+
1517/** This phase consists of a series of small, simple, local optimisations
1618 * applied as a fix point transformation over Dotty Trees.
1719 *
@@ -160,10 +162,14 @@ object Simplify {
160162 * System members are the only static final fields that are mutable.
161163 * See https://docs.oracle.com/javase/specs/jls/se8/html/jls-17.html#jls-17.5.4
162164 */
163- def isEffectivelyMutable (t : Tree )(implicit ctx : Context ): Boolean = t match {
165+ @ tailrec def isEffectivelyMutable (t : Tree )(implicit ctx : Context ): Boolean = t match {
164166 case _ if t.symbol.is(Mutable ) => true
165167 case s : Select => s.symbol.owner == defn.SystemModule
166- case i : Ident => desugarIdent(i).exists(isEffectivelyMutable)
168+ case i : Ident =>
169+ desugarIdent(i) match {
170+ case Some (ident) => isEffectivelyMutable(ident)
171+ case None => false
172+ }
167173 case _ => false
168174 }
169175
You can’t perform that action at this time.
0 commit comments