@@ -537,8 +537,7 @@ object SpaceEngine {
537
537
// force type inference to infer a narrower type: could be singleton
538
538
// see tests/patmat/i4227.scala
539
539
mt.paramInfos(0 ) <:< scrutineeTp
540
- instantiateSelected(mt, tvars)
541
- isFullyDefined(mt, ForceDegree .all)
540
+ maximizeType(mt.paramInfos(0 ), Spans .NoSpan )
542
541
mt
543
542
}
544
543
@@ -552,7 +551,7 @@ object SpaceEngine {
552
551
// Case unapplySeq:
553
552
// 1. return the type `List[T]` where `T` is the element type of the unapplySeq return type `Seq[T]`
554
553
555
- val resTp = ctx.typeAssigner.safeSubstMethodParams(mt, scrutineeTp :: Nil ).finalResultType
554
+ val resTp = wildApprox( ctx.typeAssigner.safeSubstMethodParams(mt, scrutineeTp :: Nil ).finalResultType)
556
555
557
556
val sig =
558
557
if (resTp.isRef(defn.BooleanClass ))
@@ -573,14 +572,14 @@ object SpaceEngine {
573
572
if (arity > 0 )
574
573
productSelectorTypes(resTp, unappSym.srcPos)
575
574
else {
576
- val getTp = resTp.select( nme.get).finalResultType.widenTermRefExpr
575
+ val getTp = extractorMemberType(resTp, nme.get, unappSym.srcPos)
577
576
if (argLen == 1 ) getTp :: Nil
578
577
else productSelectorTypes(getTp, unappSym.srcPos)
579
578
}
580
579
}
581
580
}
582
581
583
- sig.map(_.annotatedToRepeated)
582
+ sig.map { case tp : WildcardType => tp.bounds.hi case tp => tp }
584
583
}
585
584
586
585
/** Whether the extractor covers the given type */
@@ -625,7 +624,21 @@ object SpaceEngine {
625
624
// For instance, from i15029, `decompose((X | Y).Field[T]) = [X.Field[T], Y.Field[T]]`.
626
625
parts.map(tp.derivedAppliedType(_, targs))
627
626
628
- case tp if tp.isDecomposableToChildren =>
627
+ case tpOriginal if tpOriginal.isDecomposableToChildren =>
628
+ // isDecomposableToChildren uses .classSymbol.is(Sealed)
629
+ // But that classSymbol could be from an AppliedType
630
+ // where the type constructor is a non-class type
631
+ // E.g. t11620 where `?1.AA[X]` returns as "sealed"
632
+ // but using that we're not going to infer A1[X] and A2[X]
633
+ // but end up with A1[<?>] and A2[<?>].
634
+ // So we widen (like AppliedType superType does) away
635
+ // non-class type constructors.
636
+ def getAppliedClass (tp : Type ): Type = tp match
637
+ case tp @ AppliedType (_ : HKTypeLambda , _) => tp
638
+ case tp @ AppliedType (tycon : TypeRef , _) if tycon.symbol.isClass => tp
639
+ case tp @ AppliedType (tycon : TypeProxy , _) => getAppliedClass(tycon.superType.applyIfParameterized(tp.args))
640
+ case tp => tp
641
+ val tp = getAppliedClass(tpOriginal)
629
642
def getChildren (sym : Symbol ): List [Symbol ] =
630
643
sym.children.flatMap { child =>
631
644
if child eq sym then List (sym) // i3145: sealed trait Baz, val x = new Baz {}, Baz.children returns Baz...
0 commit comments