Skip to content

Commit 15f8241

Browse files
author
EnzeXing
committed
Modify test
1 parent 29f3f6b commit 15f8241

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

compiler/src/dotty/tools/dotc/transform/init/Objects.scala

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -791,9 +791,6 @@ class Objects(using Context @constructorOnly):
791791
else if target.equals(defn.Predef_classOf) then
792792
// Predef.classOf is a stub method in tasty and is replaced in backend
793793
UnknownValue
794-
else if target.equals(defn.ClassTagModule_apply) then
795-
// ClassTag and other reflection related values are not analyzed
796-
UnknownValue
797794
else if target.hasSource then
798795
val cls = target.owner.enclosingClass.asClass
799796
val ddef = target.defTree.asInstanceOf[DefDef]
@@ -1389,7 +1386,9 @@ class Objects(using Context @constructorOnly):
13891386
val meth = defn.getWrapVarargsArrayModule.requiredMethod(wrapArrayMethodName)
13901387
val module = defn.getWrapVarargsArrayModule.moduleClass.asClass
13911388
val args = evalArgs(elems.map(Arg.apply), thisV, klass)
1392-
call(ObjectRef(module), meth, args, module.typeRef, NoType)
1389+
val arr = OfArray(State.currentObject, summon[Regions.Data])
1390+
Heap.writeJoin(arr.addr, args.map(_.value).join)
1391+
call(ObjectRef(module), meth, List(ArgInfo(arr, summon[Trace], EmptyTree)), module.typeRef, NoType)
13931392

13941393
case Inlined(call, bindings, expansion) =>
13951394
evalExprs(bindings, thisV, klass)

tests/init-global/warn/mutable-array.check

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
-- Warning: tests/init-global/warn/mutable-array.scala:8:19 ------------------------------------------------------------
2-
8 | val x: Int = box.value // warn
1+
-- Warning: tests/init-global/warn/mutable-array.scala:9:19 ------------------------------------------------------------
2+
9 | val x: Int = box.value // warn
33
| ^^^^^^^^^
44
|Reading mutable state of object A during initialization of object B.
55
|Reading mutable state of other static objects is forbidden as it breaks initialization-time irrelevance. Calling trace:
66
|├── object B: [ mutable-array.scala:5 ]
77
|│ ^
8-
|└── val x: Int = box.value // warn [ mutable-array.scala:8 ]
8+
|└── val x: Int = box.value // warn [ mutable-array.scala:9 ]
99
| ^^^^^^^^^
1010
|The mutable state is created through:
1111
|├── object A: [ mutable-array.scala:1 ]

tests/init-global/warn/mutable-array.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ object A:
33
val box: Box = new Box(0)
44

55
object B:
6-
val boxes: Array[A.Box] = Array(A.box)
6+
val boxes = new Array[A.Box](2)
7+
boxes(0) = A.box
78
val box: A.Box = boxes(0)
89
val x: Int = box.value // warn

0 commit comments

Comments
 (0)