@@ -494,6 +494,18 @@ class Semantic {
494
494
495
495
// ----- Promotion ----------------------------------------------------
496
496
extension (addr : Addr )
497
+ /** Whether the object is fully initialized
498
+ *
499
+ * It means all fields and outers are set. For performance, we don't check
500
+ * outers here, because Scala semantics ensure that they are always set
501
+ * before any user code in the constructor.
502
+ *
503
+ * The interesting case is the outers for traits. The compiler synthesizes
504
+ * proxy accessors for the outers in the class that extends the trait. As
505
+ * those outers must be stable values, they are initialized immediately
506
+ * following class parameters and before super constructor calls and user
507
+ * code in the class body.
508
+ */
497
509
def isFullyInitialized : Contextual [Boolean ] = log(" isFullyInitialized " + addr, printer) {
498
510
val obj = heap(addr)
499
511
addr.klass.baseClasses.forall { klass =>
@@ -512,7 +524,6 @@ class Semantic {
512
524
extension (thisRef : ThisRef )
513
525
def tryPromoteCurrentObject : Contextual [Boolean ] = log(" tryPromoteCurrentObject " , printer) {
514
526
promoted.isCurrentObjectPromoted || {
515
- val obj = heap(thisRef)
516
527
// If we have all fields initialized, then we can promote This to hot.
517
528
thisRef.isFullyInitialized && {
518
529
promoted.promoteCurrent(thisRef)
@@ -999,6 +1010,11 @@ class Semantic {
999
1010
val parents = tpl.parents.tail
1000
1011
val mixins = klass.baseClasses.tail.takeWhile(_ != superCls)
1001
1012
1013
+ // The interesting case is the outers for traits. The compiler
1014
+ // synthesizes proxy accessors for the outers in the class that extends
1015
+ // the trait. As those outers must be stable values, they are initialized
1016
+ // immediately following class parameters and before super constructor
1017
+ // calls and user code in the class body.
1002
1018
mixins.reverse.foreach { mixin =>
1003
1019
parents.find(_.tpe.classSymbol == mixin) match
1004
1020
case Some (parent) => initParent(parent, handler)
0 commit comments