@@ -528,8 +528,7 @@ object SpaceEngine {
528528 // force type inference to infer a narrower type: could be singleton
529529 // see tests/patmat/i4227.scala
530530 mt.paramInfos(0 ) <:< scrutineeTp
531- instantiateSelected(mt, tvars)
532- isFullyDefined(mt, ForceDegree .all)
531+ maximizeType(mt.paramInfos(0 ), Spans .NoSpan )
533532 mt
534533 }
535534
@@ -543,7 +542,7 @@ object SpaceEngine {
543542 // Case unapplySeq:
544543 // 1. return the type `List[T]` where `T` is the element type of the unapplySeq return type `Seq[T]`
545544
546- val resTp = ctx.typeAssigner.safeSubstMethodParams(mt, scrutineeTp :: Nil ).finalResultType
545+ val resTp = wildApprox( ctx.typeAssigner.safeSubstMethodParams(mt, scrutineeTp :: Nil ).finalResultType)
547546
548547 val sig =
549548 if (resTp.isRef(defn.BooleanClass ))
@@ -564,20 +563,14 @@ object SpaceEngine {
564563 if (arity > 0 )
565564 productSelectorTypes(resTp, unappSym.srcPos)
566565 else {
567- val getTp = resTp.select(nme.get).finalResultType match
568- case tp : TermRef if ! tp.isOverloaded =>
569- // Like widenTermRefExpr, except not recursively.
570- // For example, in i17184 widen Option[foo.type]#get
571- // to Option[foo.type] instead of Option[Int].
572- tp.underlying.widenExpr
573- case tp => tp
566+ val getTp = extractorMemberType(resTp, nme.get, unappSym.srcPos)
574567 if (argLen == 1 ) getTp :: Nil
575568 else productSelectorTypes(getTp, unappSym.srcPos)
576569 }
577570 }
578571 }
579572
580- sig.map(_.annotatedToRepeated)
573+ sig.map { case tp : WildcardType => tp.bounds.hi case tp => tp }
581574 }
582575
583576 /** Whether the extractor covers the given type */
@@ -623,7 +616,21 @@ object SpaceEngine {
623616 // For instance, from i15029, `decompose((X | Y).Field[T]) = [X.Field[T], Y.Field[T]]`.
624617 parts.map(tp.derivedAppliedType(_, targs))
625618
626- case tp if tp.isDecomposableToChildren =>
619+ case tpOriginal if tpOriginal.isDecomposableToChildren =>
620+ // isDecomposableToChildren uses .classSymbol.is(Sealed)
621+ // But that classSymbol could be from an AppliedType
622+ // where the type constructor is a non-class type
623+ // E.g. t11620 where `?1.AA[X]` returns as "sealed"
624+ // but using that we're not going to infer A1[X] and A2[X]
625+ // but end up with A1[<?>] and A2[<?>].
626+ // So we widen (like AppliedType superType does) away
627+ // non-class type constructors.
628+ def getAppliedClass (tp : Type ): Type = tp match
629+ case tp @ AppliedType (_ : HKTypeLambda , _) => tp
630+ case tp @ AppliedType (tycon : TypeRef , _) if tycon.symbol.isClass => tp
631+ case tp @ AppliedType (tycon : TypeProxy , _) => getAppliedClass(tycon.superType.applyIfParameterized(tp.args))
632+ case tp => tp
633+ val tp = getAppliedClass(tpOriginal)
627634 def getChildren (sym : Symbol ): List [Symbol ] =
628635 sym.children.flatMap { child =>
629636 if child eq sym then List (sym) // i3145: sealed trait Baz, val x = new Baz {}, Baz.children returns Baz...
0 commit comments