@@ -1734,16 +1734,24 @@ object Objects:
1734
1734
if cls.isAllOf(Flags .JavaInterface ) then Bottom
1735
1735
else evalType(tref.prefix, thisV, klass, elideObjectAccess = cls.isStatic)
1736
1736
1737
+ val mutateErrorSet : mutable.Set [(ClassSymbol , ClassSymbol )] = mutable.Set .empty
1737
1738
def errorMutateOtherStaticObject (currentObj : ClassSymbol , otherObj : ClassSymbol )(using Trace , Context ) =
1738
- val msg =
1739
- s " Mutating ${otherObj.show} during initialization of ${currentObj.show}. \n " +
1740
- " Mutating other static objects during the initialization of one static object is forbidden. " + Trace .show
1739
+ if mutateErrorSet.contains((currentObj, otherObj)) then ()
1740
+ else
1741
+ mutateErrorSet += ((currentObj, otherObj))
1742
+ val msg =
1743
+ s " Mutating ${otherObj.show} during initialization of ${currentObj.show}. \n " +
1744
+ " Mutating other static objects during the initialization of one static object is forbidden. " + Trace .show
1741
1745
1742
- report.warning(msg, Trace .position)
1746
+ report.warning(msg, Trace .position)
1743
1747
1748
+ val readErrorSet : mutable.Set [(ClassSymbol , ClassSymbol )] = mutable.Set .empty
1744
1749
def errorReadOtherStaticObject (currentObj : ClassSymbol , otherObj : ClassSymbol )(using Trace , Context ) =
1745
- val msg =
1746
- " Reading mutable state of " + otherObj.show + " during initialization of " + currentObj.show + " .\n " +
1747
- " Reading mutable state of other static objects is forbidden as it breaks initialization-time irrelevance. " + Trace .show
1750
+ if readErrorSet.contains((currentObj, otherObj)) then ()
1751
+ else
1752
+ readErrorSet += ((currentObj, otherObj))
1753
+ val msg =
1754
+ " Reading mutable state of " + otherObj.show + " during initialization of " + currentObj.show + " .\n " +
1755
+ " Reading mutable state of other static objects is forbidden as it breaks initialization-time irrelevance. " + Trace .show
1748
1756
1749
- report.warning(msg, Trace .position)
1757
+ report.warning(msg, Trace .position)
0 commit comments