@@ -29,7 +29,7 @@ import EtaExpansion.etaExpand
29
29
import TypeComparer .CompareResult
30
30
import util .Spans ._
31
31
import util .common ._
32
- import util .Property
32
+ import util .{ Property , SimpleIdentityMap }
33
33
import Applications .{ExtMethodApply , IntegratedTypeArgs , productSelectorTypes , wrapDefs }
34
34
35
35
import collection .mutable
@@ -2567,7 +2567,7 @@ class Typer extends Namer
2567
2567
2568
2568
def typedStats (stats : List [untpd.Tree ], exprOwner : Symbol )(using Context ): (List [Tree ], Context ) = {
2569
2569
val buf = new mutable.ListBuffer [Tree ]
2570
- val enumContexts = new mutable. HashMap [Symbol , Context ]
2570
+ var enumContexts : SimpleIdentityMap [Symbol , Context ] = SimpleIdentityMap . Empty
2571
2571
val initialNotNullInfos = ctx.notNullInfos
2572
2572
// A map from `enum` symbols to the contexts enclosing their definitions
2573
2573
@ tailrec def traverse (stats : List [untpd.Tree ])(using Context ): (List [Tree ], Context ) = stats match {
@@ -2589,7 +2589,7 @@ class Typer extends Namer
2589
2589
// replace body with expansion, because it will be used as inlined body
2590
2590
// from separately compiled files - the original BodyAnnotation is not kept.
2591
2591
case mdef1 : TypeDef if mdef1.symbol.is(Enum , butNot = Case ) =>
2592
- enumContexts(mdef1.symbol) = ctx
2592
+ enumContexts = enumContexts.updated (mdef1.symbol, ctx)
2593
2593
buf += mdef1
2594
2594
case EmptyTree =>
2595
2595
// clashing synthetic case methods are converted to empty trees, drop them here
@@ -2621,7 +2621,8 @@ class Typer extends Namer
2621
2621
}
2622
2622
def finalize (stat : Tree )(using Context ): Tree = stat match {
2623
2623
case stat : TypeDef if stat.symbol.is(Module ) =>
2624
- for (enumContext <- enumContexts.get(stat.symbol.linkedClass))
2624
+ val enumContext = enumContexts(stat.symbol.linkedClass)
2625
+ if enumContext != null then
2625
2626
checkEnumCaseRefsLegal(stat, enumContext)
2626
2627
stat.removeAttachment(Deriver ) match {
2627
2628
case Some (deriver) => deriver.finalize(stat)
0 commit comments