Skip to content

Commit

Permalink
TyperState#commit: Flush reporter before committing
Browse files Browse the repository at this point in the history
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 scala#12736
  • Loading branch information
smarter committed Jun 15, 2021
1 parent 6b8169c commit ea6449f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/core/TyperState.scala
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ class TyperState() {
Stats.record("typerState.commit")
assert(isCommittable, s"$this is not committable")
assert(!isCommitted, s"$this is already committed")
reporter.flush()
setCommittable(false)
val targetState = ctx.typerState
assert(!targetState.isCommitted, s"Attempt to commit $this into already committed $targetState")
Expand All @@ -152,7 +153,6 @@ class TyperState() {
else
targetState.mergeConstraintWith(this)
targetState.gc()
reporter.flush()
isCommitted = true
}

Expand Down
6 changes: 6 additions & 0 deletions tests/neg/i12736b.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
object Test {
def apply[S](r: Any)(using DoesntExist): Any = r // error

def test(o: Option[Any]) =
o.map(x => Test(doesntExist, x)) // error
}

0 comments on commit ea6449f

Please sign in to comment.