File tree 1 file changed +8
-2
lines changed
compiler/src/dotty/tools/dotc/transform/localopt 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}
12
12
import config .Printers .simplify
13
13
import ast .tpd
14
14
15
+ import scala .annotation .tailrec
16
+
15
17
/** This phase consists of a series of small, simple, local optimisations
16
18
* applied as a fix point transformation over Dotty Trees.
17
19
*
@@ -160,10 +162,14 @@ object Simplify {
160
162
* System members are the only static final fields that are mutable.
161
163
* See https://docs.oracle.com/javase/specs/jls/se8/html/jls-17.html#jls-17.5.4
162
164
*/
163
- def isEffectivelyMutable (t : Tree )(implicit ctx : Context ): Boolean = t match {
165
+ @ tailrec def isEffectivelyMutable (t : Tree )(implicit ctx : Context ): Boolean = t match {
164
166
case _ if t.symbol.is(Mutable ) => true
165
167
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
+ }
167
173
case _ => false
168
174
}
169
175
You can’t perform that action at this time.
0 commit comments