Skip to content

Commit

Permalink
Simple case working
Browse files Browse the repository at this point in the history
  • Loading branch information
natsukagami committed Feb 2, 2021
1 parent 9c9d4ec commit 0796461
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions compiler/src/dotty/tools/dotc/transform/init/Checking.scala
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,16 @@ object Checking {
case Promote(pot) =>
pot match {
case pot: ThisRef =>
PromoteThis(pot, eff.source, state2.path).toErrors

// If we have all fields initialized, then we can promote This to hot.
val classRef = state.thisClass.info.asInstanceOf[ClassInfo].appliedRef
val allFieldsInited = classRef.fields.forall { denot =>
val sym = denot.symbol
sym.isOneOf(Flags.Lazy | Flags.Deferred) || state.fieldsInited.contains(sym)
}
if (allFieldsInited)
Errors.empty
else
PromoteThis(pot, eff.source, state2.path).toErrors
case _: Cold =>
PromoteCold(eff.source, state2.path).toErrors

Expand Down

0 comments on commit 0796461

Please sign in to comment.