Skip to content

Commit

Permalink
special case for next field of colon colon in global init checker
Browse files Browse the repository at this point in the history
  • Loading branch information
willerf committed Apr 29, 2024
1 parent 837ed3a commit c714ae5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 2 additions & 1 deletion compiler/src/dotty/tools/dotc/transform/init/Objects.scala
Original file line number Diff line number Diff line change
Expand Up @@ -812,7 +812,8 @@ class Objects(using Context @constructorOnly):
else
Bottom
else if target.exists then
if target.isOneOf(Flags.Mutable) then
def isNextFieldOfColonColon: Boolean = ref.klass == defn.ConsClass && target.name.toString == "next"
if target.isOneOf(Flags.Mutable) && !isNextFieldOfColonColon then
if ref.hasVar(target) then
val addr = ref.varAddr(target)
if addr.owner == State.currentObject then
Expand Down
5 changes: 5 additions & 0 deletions tests/init-global/pos/list-colon-colon-next.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
object A:
val a: List[Int] = List(1, 2, 3)

object B:
val b = A.a.size

0 comments on commit c714ae5

Please sign in to comment.