@@ -51,12 +51,7 @@ class CollectNullableFields extends MiniPhase {
5151 private case class Nullable (by : Symbol ) extends FieldInfo
5252
5353 /** 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 ]
6055
6156 private def recordUse (tree : Tree )(using Context ): Tree = {
6257 val sym = tree.symbol
@@ -71,9 +66,9 @@ class CollectNullableFields extends MiniPhase {
7166
7267 if (isNullablePrivateField)
7368 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
7570 nullability.put(sym, NotNullable )
76- case null => // not in the map
71+ case None => // not in the map
7772 val from = ctx.owner
7873 val isNullable =
7974 from.is(Lazy , butNot = Module ) && // is lazy val
@@ -100,7 +95,7 @@ class CollectNullableFields extends MiniPhase {
10095 def lazyValNullables (using Context ): IdentityHashMap [Symbol , mutable.ListBuffer [Symbol ]] = {
10196 val result = new IdentityHashMap [Symbol , mutable.ListBuffer [Symbol ]]
10297
103- nullability.forEach {
98+ nullability.foreach {
10499 case (sym, Nullable (from)) =>
105100 val bldr = result.computeIfAbsent(from, _ => new mutable.ListBuffer )
106101 bldr += sym
0 commit comments