Skip to content

Commit 270a886

Browse files
committed
Move directlyPromote check up
1 parent e7e6e7c commit 270a886

File tree

1 file changed

+26
-26
lines changed

1 file changed

+26
-26
lines changed

compiler/src/dotty/tools/dotc/transform/init/Checking.scala

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -349,39 +349,39 @@ object Checking {
349349
if (state.safePromoted.contains(eff.potential)) Errors.empty
350350
else {
351351
val pot = eff.potential
352-
val errs = pot match {
353-
case pot if canDirectlyPromote(pot) =>
352+
val errs =
353+
if canDirectlyPromote(pot) then
354354
Errors.empty
355+
else pot match {
356+
case pot: ThisRef =>
357+
PromoteThis(pot, eff.source, state.path).toErrors
355358

356-
case pot: ThisRef =>
357-
PromoteThis(pot, eff.source, state.path).toErrors
358-
359-
case _: Cold =>
360-
PromoteCold(eff.source, state.path).toErrors
359+
case _: Cold =>
360+
PromoteCold(eff.source, state.path).toErrors
361361

362-
case pot @ Warm(cls, outer) =>
363-
checkPromoteWarm(pot, eff)
362+
case pot @ Warm(cls, outer) =>
363+
checkPromoteWarm(pot, eff)
364364

365-
case Fun(pots, effs) =>
366-
val errs1 = state.test {
367-
effs.toList.flatMap(check(_))
368-
}
369-
val errs2 = state.test {
370-
pots.toList.flatMap { pot =>
371-
checkPromote(Promote(pot)(eff.source))
365+
case Fun(pots, effs) =>
366+
val errs1 = state.test {
367+
effs.toList.flatMap(check(_))
368+
}
369+
val errs2 = state.test {
370+
pots.toList.flatMap { pot =>
371+
checkPromote(Promote(pot)(eff.source))
372+
}
372373
}
373-
}
374374

375-
if (errs1.nonEmpty || errs2.nonEmpty)
376-
UnsafePromotion(pot, eff.source, state.path, errs1 ++ errs2).toErrors
377-
else
378-
Errors.empty
375+
if (errs1.nonEmpty || errs2.nonEmpty)
376+
UnsafePromotion(pot, eff.source, state.path, errs1 ++ errs2).toErrors
377+
else
378+
Errors.empty
379379

380-
case pot =>
381-
val Summary(pots, effs) = expand(pot)
382-
val effs2 = pots.map(Promote(_)(eff.source))
383-
(effs2 ++ effs).toList.flatMap(check(_))
384-
}
380+
case pot =>
381+
val Summary(pots, effs) = expand(pot)
382+
val effs2 = pots.map(Promote(_)(eff.source))
383+
(effs2 ++ effs).toList.flatMap(check(_))
384+
}
385385
// If we can safely promote, then we don't need to check again
386386
if (errs.isEmpty)
387387
state.safePromoted += pot

0 commit comments

Comments
 (0)