@@ -11,6 +11,7 @@ import core.NameOps._
1111import transform .TreeTransforms .{MiniPhaseTransform , TransformerInfo }
1212import config .Printers .simplify
1313import ast .tpd
14+ import dotty .tools .dotc .core .PhantomErasure
1415
1516import scala .annotation .tailrec
1617
@@ -175,13 +176,16 @@ object Simplify {
175176 }
176177
177178 def isImmutableAccessor (t : Tree )(implicit ctx : Context ): Boolean = {
178- val isImmutableGetter = t.symbol.isGetter && ! t.symbol.is(Mutable | Lazy )
179- val isCaseAccessor = t.symbol.is(CaseAccessor ) && ! t.symbol.is(Mutable | Lazy )
180- val isProductAccessor = t.symbol.exists &&
181- t.symbol.owner.derivesFrom(defn.ProductClass ) &&
182- t.symbol.owner.is(CaseClass ) &&
183- t.symbol.name.isSelectorName &&
184- ! t.symbol.info.decls.exists(_.is(Mutable | Lazy )) // Conservatively covers case class A(var x: Int)
185- isImmutableGetter || isCaseAccessor || isProductAccessor
179+ val sym = t.symbol
180+ val isImmutableGetter = sym.isGetter && ! sym.is(Mutable | Lazy )
181+ val isCaseAccessor = sym.is(CaseAccessor ) && ! sym.is(Mutable | Lazy )
182+ val isProductAccessor = sym.exists &&
183+ sym.owner.derivesFrom(defn.ProductClass ) &&
184+ sym.owner.is(CaseClass ) &&
185+ sym.name.isSelectorName &&
186+ ! sym.info.decls.exists(_.is(Mutable | Lazy )) // Conservatively covers case class A(var x: Int)
187+ val isErasedPhantom = PhantomErasure .isErasedPhantom(sym)
188+
189+ isImmutableGetter || isCaseAccessor || isProductAccessor || isErasedPhantom
186190 }
187191}
0 commit comments