Skip to content

Commit 4dd8e8a

Browse files
committed
Maximise once more
1 parent 5fd810e commit 4dd8e8a

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

+9
Original file line numberDiff line numberDiff line change
@@ -524,13 +524,22 @@ object SpaceEngine {
524524
val mt: MethodType = unapp.widen match {
525525
case mt: MethodType => mt
526526
case pt: PolyType =>
527+
val locked = ctx.typerState.ownedVars
527528
val tvars = constrained(pt)
528529
val mt = pt.instantiate(tvars).asInstanceOf[MethodType]
529530
scrutineeTp <:< mt.paramInfos(0)
530531
// force type inference to infer a narrower type: could be singleton
531532
// see tests/patmat/i4227.scala
532533
mt.paramInfos(0) <:< scrutineeTp
533534
maximizeType(mt.paramInfos(0), Spans.NoSpan)
535+
if !(ctx.typerState.ownedVars -- locked).isEmpty then
536+
// constraining can create type vars out of wildcard types
537+
// (in legalBound, by using a LevelAvoidMap)
538+
// maximise will only do one pass at maximising the type vars in the target type
539+
// which means we can maximise to types that include other type vars
540+
// this fails TreeChecker's "non-empty constraint at end of $fusedPhase" check
541+
// e.g. run-macros/string-context-implicits
542+
maximizeType(mt.paramInfos(0), Spans.NoSpan)
534543
mt
535544
}
536545

0 commit comments

Comments
 (0)