File tree 2 files changed +12
-6
lines changed
compiler/src/dotty/tools/dotc/transform/init 2 files changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -115,9 +115,9 @@ object Errors {
115
115
report.warning(show + stacktrace, objs.head.srcPos)
116
116
}
117
117
118
- case class ObjectLeakDuringInit (obj : Symbol , trace : Seq [Tree ]) extends Error {
118
+ case class ObjectNotInit (obj : Symbol , trace : Seq [Tree ]) extends Error {
119
119
def source : Tree = trace.last
120
- def show (using Context ): String = obj.show + " leaked during its initialization " + " ."
120
+ def show (using Context ): String = obj.show + " not yet initialized " + " ."
121
121
122
122
override def issue (using Context ): Unit =
123
123
report.warning(show + stacktrace, obj.srcPos)
Original file line number Diff line number Diff line change @@ -447,12 +447,14 @@ class Objects {
447
447
if cycle.nonEmpty then
448
448
val classDef = obj.klass.defTree
449
449
var trace1 = trace.toVector.dropWhile(_ != classDef) :+ source
450
- val warning =
450
+ val warnings =
451
451
if cycle.size > 1 then
452
- CyclicObjectInit (cycle, trace1)
452
+ CyclicObjectInit (cycle, trace1) :: Nil
453
453
else
454
- ObjectLeakDuringInit (obj.klass, trace1)
455
- Result (obj, warning :: Nil )
454
+ val o = heap(obj)
455
+ if o.fields.contains(obj.klass) then Nil
456
+ else ObjectNotInit (obj.klass, trace1) :: Nil
457
+ Result (obj, warnings)
456
458
else if obj.klass.is(Flags .JavaDefined ) then
457
459
// Errors will be reported for method calls on it
458
460
Result (Bottom , Nil )
@@ -845,6 +847,10 @@ class Objects {
845
847
val superCls = superParent.tpe.classSymbol.asClass
846
848
initParent(superParent)
847
849
850
+ // Access to the object possible after this point
851
+ if klass.isStaticOwner then
852
+ thisV.updateField(klass, thisV)
853
+
848
854
val parents = tpl.parents.tail
849
855
val mixins = klass.baseClasses.tail.takeWhile(_ != superCls)
850
856
mixins.reverse.foreach { mixin =>
You can’t perform that action at this time.
0 commit comments