Skip to content

Commit 74ab521

Browse files
dwijnandWojciechMazur
authored andcommitted
Maximise once more
1 parent c4040ff commit 74ab521

File tree

1 file changed

+9
-0
lines changed
  • compiler/src/dotty/tools/dotc/transform/patmat

1 file changed

+9
-0
lines changed

compiler/src/dotty/tools/dotc/transform/patmat/Space.scala

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -533,13 +533,22 @@ object SpaceEngine {
533533
val mt: MethodType = unapp.widen match {
534534
case mt: MethodType => mt
535535
case pt: PolyType =>
536+
val locked = ctx.typerState.ownedVars
536537
val tvars = constrained(pt)
537538
val mt = pt.instantiate(tvars).asInstanceOf[MethodType]
538539
scrutineeTp <:< mt.paramInfos(0)
539540
// force type inference to infer a narrower type: could be singleton
540541
// see tests/patmat/i4227.scala
541542
mt.paramInfos(0) <:< scrutineeTp
542543
maximizeType(mt.paramInfos(0), Spans.NoSpan)
544+
if !(ctx.typerState.ownedVars -- locked).isEmpty then
545+
// constraining can create type vars out of wildcard types
546+
// (in legalBound, by using a LevelAvoidMap)
547+
// maximise will only do one pass at maximising the type vars in the target type
548+
// which means we can maximise to types that include other type vars
549+
// this fails TreeChecker's "non-empty constraint at end of $fusedPhase" check
550+
// e.g. run-macros/string-context-implicits
551+
maximizeType(mt.paramInfos(0), Spans.NoSpan)
543552
mt
544553
}
545554

0 commit comments

Comments
 (0)