@@ -51,12 +51,7 @@ class CollectNullableFields extends MiniPhase {
51
51
private case class Nullable (by : Symbol ) extends FieldInfo
52
52
53
53
/** Whether or not a field is nullable */
54
- private var nullability : IdentityHashMap [Symbol , FieldInfo ] = _
55
-
56
- override def prepareForUnit (tree : Tree )(using Context ): Context = {
57
- if (nullability == null ) nullability = new IdentityHashMap
58
- ctx
59
- }
54
+ private val nullability = new mutable.LinkedHashMap [Symbol , FieldInfo ]
60
55
61
56
private def recordUse (tree : Tree )(using Context ): Tree = {
62
57
val sym = tree.symbol
@@ -71,9 +66,9 @@ class CollectNullableFields extends MiniPhase {
71
66
72
67
if (isNullablePrivateField)
73
68
nullability.get(sym) match {
74
- case Nullable (from) if from != ctx.owner => // used in multiple lazy val initializers
69
+ case Some ( Nullable (from) ) if from != ctx.owner => // used in multiple lazy val initializers
75
70
nullability.put(sym, NotNullable )
76
- case null => // not in the map
71
+ case None => // not in the map
77
72
val from = ctx.owner
78
73
val isNullable =
79
74
from.is(Lazy , butNot = Module ) && // is lazy val
@@ -100,7 +95,7 @@ class CollectNullableFields extends MiniPhase {
100
95
def lazyValNullables (using Context ): IdentityHashMap [Symbol , mutable.ListBuffer [Symbol ]] = {
101
96
val result = new IdentityHashMap [Symbol , mutable.ListBuffer [Symbol ]]
102
97
103
- nullability.forEach {
98
+ nullability.foreach {
104
99
case (sym, Nullable (from)) =>
105
100
val bldr = result.computeIfAbsent(from, _ => new mutable.ListBuffer )
106
101
bldr += sym
0 commit comments