Skip to content

Commit 80b194d

Browse files
committed
Move directlyPromote check up
1 parent c1d5be4 commit 80b194d

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
@@ -339,39 +339,39 @@ object Checking {
339339
if (state.safePromoted.contains(eff.potential)) Errors.empty
340340
else {
341341
val pot = eff.potential
342-
val errs = pot match {
343-
case pot if canDirectlyPromote(pot) =>
342+
val errs =
343+
if canDirectlyPromote(pot) then
344344
Errors.empty
345+
else pot match {
346+
case pot: ThisRef =>
347+
PromoteThis(pot, eff.source, state.path).toErrors
345348

346-
case pot: ThisRef =>
347-
PromoteThis(pot, eff.source, state.path).toErrors
348-
349-
case _: Cold =>
350-
PromoteCold(eff.source, state.path).toErrors
349+
case _: Cold =>
350+
PromoteCold(eff.source, state.path).toErrors
351351

352-
case pot @ Warm(cls, outer) =>
353-
checkPromoteWarm(pot, eff)
352+
case pot @ Warm(cls, outer) =>
353+
checkPromoteWarm(pot, eff)
354354

355-
case Fun(pots, effs) =>
356-
val errs1 = state.test {
357-
effs.toList.flatMap(check(_))
358-
}
359-
val errs2 = state.test {
360-
pots.toList.flatMap { pot =>
361-
checkPromote(Promote(pot)(eff.source))
355+
case Fun(pots, effs) =>
356+
val errs1 = state.test {
357+
effs.toList.flatMap(check(_))
358+
}
359+
val errs2 = state.test {
360+
pots.toList.flatMap { pot =>
361+
checkPromote(Promote(pot)(eff.source))
362+
}
362363
}
363-
}
364364

365-
if (errs1.nonEmpty || errs2.nonEmpty)
366-
UnsafePromotion(pot, eff.source, state.path, errs1 ++ errs2).toErrors
367-
else
368-
Errors.empty
365+
if (errs1.nonEmpty || errs2.nonEmpty)
366+
UnsafePromotion(pot, eff.source, state.path, errs1 ++ errs2).toErrors
367+
else
368+
Errors.empty
369369

370-
case pot =>
371-
val Summary(pots, effs) = expand(pot)
372-
val effs2 = pots.map(Promote(_)(eff.source))
373-
(effs2 ++ effs).toList.flatMap(check(_))
374-
}
370+
case pot =>
371+
val Summary(pots, effs) = expand(pot)
372+
val effs2 = pots.map(Promote(_)(eff.source))
373+
(effs2 ++ effs).toList.flatMap(check(_))
374+
}
375375
// If we can safely promote, then we don't need to check again
376376
if (errs.isEmpty)
377377
state.safePromoted += pot

0 commit comments

Comments
 (0)