File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed
compiler/src/dotty/tools/dotc/transform/init Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -164,8 +164,16 @@ object Checking {
164
164
case Promote (pot) =>
165
165
pot match {
166
166
case pot : ThisRef =>
167
- PromoteThis (pot, eff.source, state2.path).toErrors
168
-
167
+ // If we have all fields initialized, then we can promote This to hot.
168
+ val classRef = state.thisClass.info.asInstanceOf [ClassInfo ].appliedRef
169
+ val allFieldsInited = classRef.fields.forall { denot =>
170
+ val sym = denot.symbol
171
+ sym.isOneOf(Flags .Lazy | Flags .Deferred ) || state.fieldsInited.contains(sym)
172
+ }
173
+ if (allFieldsInited)
174
+ Errors .empty
175
+ else
176
+ PromoteThis (pot, eff.source, state2.path).toErrors
169
177
case _ : Cold =>
170
178
PromoteCold (eff.source, state2.path).toErrors
171
179
You can’t perform that action at this time.
0 commit comments