diff --git a/compiler/src/dotty/tools/dotc/core/TyperState.scala b/compiler/src/dotty/tools/dotc/core/TyperState.scala index 0f5ea0ac431d..2c41fc8f0231 100644 --- a/compiler/src/dotty/tools/dotc/core/TyperState.scala +++ b/compiler/src/dotty/tools/dotc/core/TyperState.scala @@ -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") @@ -152,7 +153,6 @@ class TyperState() { else targetState.mergeConstraintWith(this) targetState.gc() - reporter.flush() isCommitted = true } diff --git a/tests/neg/i12736b.scala b/tests/neg/i12736b.scala new file mode 100644 index 000000000000..c7db2f7a92ea --- /dev/null +++ b/tests/neg/i12736b.scala @@ -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 +}