@@ -5,7 +5,7 @@ package patmat
55
66import core .* , Constants .* , Contexts .* , Decorators .* , Flags .* , Names .* , NameOps .* , StdNames .* , Symbols .* , Types .*
77import ast .* , tpd .*
8- import config .Printers .exhaustivity
8+ import config .Printers .*
99import printing .{ Printer , * }, Texts .*
1010import reporting .*
1111import typer .* , Applications .* , Inferencing .* , ProtoTypes .*
@@ -531,37 +531,14 @@ object SpaceEngine {
531531 val mt : MethodType = unapp.widen match {
532532 case mt : MethodType => mt
533533 case pt : PolyType =>
534- scrutineeTp match
535- case AppliedType (tycon, targs)
536- if unappSym.is(Synthetic )
537- && (pt.resultType.asInstanceOf [MethodType ].paramInfos.head.typeConstructor eq tycon) =>
538- // Special case synthetic unapply/unapplySeq's
539- // Provided the shapes of the types match:
540- // the scrutinee type being unapplied and
541- // the unapply parameter type
542- pt.instantiate(targs).asInstanceOf [MethodType ]
543- case _ =>
544- val locked = ctx.typerState.ownedVars
545534 val tvars = constrained(pt)
546535 val mt = pt.instantiate(tvars).asInstanceOf [MethodType ]
547- val unapplyArgType = mt.paramInfos.head
548- scrutineeTp <:< unapplyArgType
536+ scrutineeTp <:< mt.paramInfos(0 )
549537 // force type inference to infer a narrower type: could be singleton
550538 // see tests/patmat/i4227.scala
551- unapplyArgType <:< scrutineeTp
552- maximizeType(unapplyArgType, Spans .NoSpan )
553- if ! (ctx.typerState.ownedVars -- locked).isEmpty then
554- // constraining can create type vars out of wildcard types
555- // (in legalBound, by using a LevelAvoidMap)
556- // maximise will only do one pass at maximising the type vars in the target type
557- // which means we can maximise to types that include other type vars
558- // this fails TreeChecker's "non-empty constraint at end of $fusedPhase" check
559- // e.g. run-macros/string-context-implicits
560- // I can't prove that a second call won't also create type vars,
561- // but I'd rather have an unassigned new-new type var, than an infinite loop.
562- // After all, there's nothing strictly "wrong" with unassigned type vars,
563- // it just fails TreeChecker's linting.
564- maximizeType(unapplyArgType, Spans .NoSpan )
539+ mt.paramInfos(0 ) <:< scrutineeTp
540+ instantiateSelected(mt, tvars)
541+ isFullyDefined(mt, ForceDegree .all)
565542 mt
566543 }
567544
0 commit comments