@@ -29,6 +29,7 @@ import scala.collection.mutable
29
29
import scala .annotation .tailrec
30
30
import scala .annotation .constructorOnly
31
31
import dotty .tools .dotc .core .Flags .AbstractOrTrait
32
+ import Decorators .*
32
33
33
34
/** Check initialization safety of static objects
34
35
*
@@ -68,11 +69,21 @@ import dotty.tools.dotc.core.Flags.AbstractOrTrait
68
69
*
69
70
*/
70
71
class Objects (using Context @ constructorOnly):
71
- val immutableHashSetBuider : Symbol = requiredClass(" scala.collection.immutable.HashSetBuilder " )
72
+ val immutableHashSetNode : Symbol = requiredClass(" scala.collection.immutable.SetNode " )
72
73
// TODO: this should really be an annotation on the rhs of the field initializer rather than the field itself.
73
- val HashSetBuilder_rootNode : Symbol = immutableHashSetBuider.requiredValue(" rootNode" )
74
-
75
- val whiteList = Set (HashSetBuilder_rootNode )
74
+ val SetNode_EmptySetNode : Symbol = Denotations .staticRef(" scala.collection.immutable.SetNode.EmptySetNode" .toTermName).symbol
75
+ val immutableHashSet : Symbol = requiredModule(" scala.collection.immutable.HashSet" )
76
+ val HashSet_EmptySet : Symbol = Denotations .staticRef(" scala.collection.immutable.HashSet.EmptySet" .toTermName).symbol
77
+ val immutableVector : Symbol = requiredModule(" scala.collection.immutable.Vector" )
78
+ val Vector_EmptyIterator : Symbol = immutableVector.requiredValue(" emptyIterator" )
79
+ val immutableMapNode : Symbol = requiredModule(" scala.collection.immutable.MapNode" )
80
+ val MapNode_EmptyMapNode : Symbol = immutableMapNode.requiredValue(" EmptyMapNode" )
81
+ val immutableHashMap : Symbol = requiredModule(" scala.collection.immutable.HashMap" )
82
+ val HashMap_EmptyMap : Symbol = immutableHashMap.requiredValue(" EmptyMap" )
83
+ val immutableLazyList : Symbol = requiredModule(" scala.collection.immutable.LazyList" )
84
+ val LazyList_empty : Symbol = immutableLazyList.requiredValue(" _empty" )
85
+
86
+ val whiteList : Set [Symbol ] = Set ()
76
87
77
88
// ----------------------------- abstract domain -----------------------------
78
89
@@ -162,7 +173,7 @@ class Objects(using Context @constructorOnly):
162
173
extends Ref (valsMap = mutable.Map .empty, varsMap = mutable.Map .empty, outersMap = mutable.Map .empty):
163
174
val owner = klass
164
175
165
- def show (using Context ) = " ObjectRef(" + klass.show + " )"
176
+ def show (using Context ) = " ObjectRef(" + klass.show + " )" + " valMap = " + vals + " varMap = " + vars
166
177
167
178
/**
168
179
* Represents values that are instances of the specified class.
@@ -821,6 +832,7 @@ class Objects(using Context @constructorOnly):
821
832
errorReadOtherStaticObject(State .currentObject, addr)
822
833
Bottom
823
834
else if ref.isObjectRef && ref.klass.hasSource then
835
+ println(s " Uninitialized field Position 2, ref = $ref, target = $target" )
824
836
report.warning(" Access uninitialized field " + field.show + " . " + Trace .show, Trace .position)
825
837
Bottom
826
838
else
@@ -829,6 +841,7 @@ class Objects(using Context @constructorOnly):
829
841
else if ref.hasVal(target) then
830
842
ref.valValue(target)
831
843
else if ref.isObjectRef && ref.klass.hasSource then
844
+ println(s " Uninitialized field Position 2, ref = $ref, target = $target" )
832
845
report.warning(" Access uninitialized field " + field.show + " . " + Trace .show, Trace .position)
833
846
Bottom
834
847
else
0 commit comments