Skip to content

Commit ea6449f

Browse files
committed
TyperState#commit: Flush reporter before committing
Flushing the reporter can force messages (apparently because of `HideNonSensicalMessages#isHidden`) which can affect the TyperState we're in the process of committing, so make sure that flushing happens before committing to not trigger any assertion. Fixes #12736
1 parent 6b8169c commit ea6449f

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

compiler/src/dotty/tools/dotc/core/TyperState.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ class TyperState() {
140140
Stats.record("typerState.commit")
141141
assert(isCommittable, s"$this is not committable")
142142
assert(!isCommitted, s"$this is already committed")
143+
reporter.flush()
143144
setCommittable(false)
144145
val targetState = ctx.typerState
145146
assert(!targetState.isCommitted, s"Attempt to commit $this into already committed $targetState")
@@ -152,7 +153,6 @@ class TyperState() {
152153
else
153154
targetState.mergeConstraintWith(this)
154155
targetState.gc()
155-
reporter.flush()
156156
isCommitted = true
157157
}
158158

tests/neg/i12736b.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
object Test {
2+
def apply[S](r: Any)(using DoesntExist): Any = r // error
3+
4+
def test(o: Option[Any]) =
5+
o.map(x => Test(doesntExist, x)) // error
6+
}

0 commit comments

Comments
 (0)