@@ -528,8 +528,7 @@ object SpaceEngine {
528
528
// force type inference to infer a narrower type: could be singleton
529
529
// see tests/patmat/i4227.scala
530
530
mt.paramInfos(0 ) <:< scrutineeTp
531
- instantiateSelected(mt, tvars)
532
- isFullyDefined(mt, ForceDegree .all)
531
+ maximizeType(mt.paramInfos(0 ), Spans .NoSpan )
533
532
mt
534
533
}
535
534
@@ -543,7 +542,7 @@ object SpaceEngine {
543
542
// Case unapplySeq:
544
543
// 1. return the type `List[T]` where `T` is the element type of the unapplySeq return type `Seq[T]`
545
544
546
- val resTp = ctx.typeAssigner.safeSubstMethodParams(mt, scrutineeTp :: Nil ).finalResultType
545
+ val resTp = wildApprox( ctx.typeAssigner.safeSubstMethodParams(mt, scrutineeTp :: Nil ).finalResultType)
547
546
548
547
val sig =
549
548
if (resTp.isRef(defn.BooleanClass ))
@@ -564,20 +563,14 @@ object SpaceEngine {
564
563
if (arity > 0 )
565
564
productSelectorTypes(resTp, unappSym.srcPos)
566
565
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)
574
567
if (argLen == 1 ) getTp :: Nil
575
568
else productSelectorTypes(getTp, unappSym.srcPos)
576
569
}
577
570
}
578
571
}
579
572
580
- sig.map(_.annotatedToRepeated)
573
+ sig.map { case tp : WildcardType => tp.bounds.hi case tp => tp }
581
574
}
582
575
583
576
/** Whether the extractor covers the given type */
@@ -623,7 +616,21 @@ object SpaceEngine {
623
616
// For instance, from i15029, `decompose((X | Y).Field[T]) = [X.Field[T], Y.Field[T]]`.
624
617
parts.map(tp.derivedAppliedType(_, targs))
625
618
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)
627
634
def getChildren (sym : Symbol ): List [Symbol ] =
628
635
sym.children.flatMap { child =>
629
636
if child eq sym then List (sym) // i3145: sealed trait Baz, val x = new Baz {}, Baz.children returns Baz...
0 commit comments