@@ -596,7 +596,6 @@ class SpaceEngine(implicit ctx: Context) extends SpaceLogic {
596
596
// replace type parameter references with bounds
597
597
val typeParamMap = new TypeMap {
598
598
def apply (t : Type ): Type = t match {
599
-
600
599
case tp : TypeRef if tp.symbol.is(TypeParam ) && tp.underlying.isInstanceOf [TypeBounds ] =>
601
600
// See tests/patmat/gadt.scala tests/patmat/exhausting.scala tests/patmat/t9657.scala
602
601
val exposed =
@@ -611,13 +610,32 @@ class SpaceEngine(implicit ctx: Context) extends SpaceLogic {
611
610
}
612
611
}
613
612
613
+ // replace uninstantiated type vars with WildcardType, check tests/patmat/3333.scala
614
+ val instUndetMap = new TypeMap {
615
+ def apply (t : Type ): Type = t match {
616
+ case tvar : TypeVar if ! tvar.isInstantiated => WildcardType (tvar.origin.underlying.bounds)
617
+ case _ => mapOver(t)
618
+ }
619
+ }
620
+
621
+ val force = new ForceDegree .Value (
622
+ tvar => ! (ctx.typerState.constraint.entry(tvar.origin) eq tvar.origin.underlying),
623
+ minimizeAll = false
624
+ )
625
+
614
626
val tvars = tp1.typeParams.map { tparam => newTypeVar(tparam.paramInfo.bounds) }
615
627
val protoTp1 = thisTypeMap(tp1.appliedTo(tvars))
616
628
617
- if (protoTp1 <:< tp2 && isFullyDefined(protoTp1, ForceDegree .noBottom)) protoTp1
629
+ if (protoTp1 <:< tp2) {
630
+ isFullyDefined(protoTp1, force)
631
+ instUndetMap(protoTp1)
632
+ }
618
633
else {
619
634
val protoTp2 = typeParamMap(tp2)
620
- if (protoTp1 <:< protoTp2 && isFullyDefined(protoTp1 & protoTp2, ForceDegree .noBottom)) protoTp1
635
+ if (protoTp1 <:< protoTp2) {
636
+ isFullyDefined(protoTp1 & protoTp2, force)
637
+ instUndetMap(protoTp1)
638
+ }
621
639
else {
622
640
debug.println(s " $protoTp1 <:< $protoTp2 = false " )
623
641
NoType
0 commit comments