Skip to content

Commit 7ee0726

Browse files
author
EnzeXing
committed
Modify test
1 parent fdcb455 commit 7ee0726

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
@@ -826,9 +826,6 @@ class Objects(using Context @constructorOnly):
826826
else if target.equals(defn.Predef_classOf) then
827827
// Predef.classOf is a stub method in tasty and is replaced in backend
828828
UnknownValue
829-
else if target.equals(defn.ClassTagModule_apply) then
830-
// ClassTag and other reflection related values are not analyzed
831-
UnknownValue
832829
else if target.hasSource then
833830
val cls = target.owner.enclosingClass.asClass
834831
val ddef = target.defTree.asInstanceOf[DefDef]
@@ -1427,7 +1424,9 @@ class Objects(using Context @constructorOnly):
14271424
val meth = defn.getWrapVarargsArrayModule.requiredMethod(wrapArrayMethodName)
14281425
val module = defn.getWrapVarargsArrayModule.moduleClass.asClass
14291426
val args = evalArgs(elems.map(Arg.apply), thisV, klass)
1430-
call(ObjectRef(module), meth, args, module.typeRef, NoType)
1427+
val arr = OfArray(State.currentObject, summon[Regions.Data])
1428+
Heap.writeJoin(arr.addr, args.map(_.value).join)
1429+
call(ObjectRef(module), meth, List(ArgInfo(arr, summon[Trace], EmptyTree)), module.typeRef, NoType)
14311430

14321431
case Inlined(call, bindings, expansion) =>
14331432
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)