Skip to content

Commit 0e17117

Browse files
authored
analyze object when selecting from package (#21511)
This PR is an updated version of #20424, which fixes a bug in the global initialization checker such that when accessing global object through full path, the checker immediately analyzes the initialization code of the corresponding object. [test_scala2_library_tasty]
2 parents 5fa69ad + 3416509 commit 0e17117

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -867,7 +867,7 @@ class Objects(using Context @constructorOnly):
867867
Bottom
868868

869869
case Bottom =>
870-
if field.isStaticObject then ObjectRef(field.moduleClass.asClass)
870+
if field.isStaticObject then accessObject(field.moduleClass.asClass)
871871
else Bottom
872872

873873
case ValueSet(values) =>

compiler/test/dotc/neg-init-global-scala2-library-tasty.blacklist

+13
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,16 @@ unapplySeq-implicit-arg.scala
55
unapplySeq-implicit-arg2.scala
66
unapplySeq-implicit-arg3.scala
77
ScalaCheck.scala
8+
mutable-read8.scala
9+
TypeCast.scala
10+
global-cycle8.scala
11+
global-cycle6.scala
12+
i12544b.scala
13+
t9360.scala
14+
mutable-array.scala
15+
patmat-unapplySeq2.scala
16+
line-spacing.scala
17+
global-list.scala
18+
t5366.scala
19+
mutable-read7.scala
20+
t9115.scala
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package cyclicObject
2+
3+
object O1 { // warn
4+
val o = cyclicObject.O2
5+
}
6+
7+
object O2 {
8+
val o = cyclicObject.O1
9+
}

0 commit comments

Comments
 (0)