@@ -47,7 +47,7 @@ object ProtoTypes {
47
47
necessarySubType(tpn, pt) || tpn.isValueSubType(pt) || viewExists(tpn, pt)
48
48
49
49
/** Test compatibility after normalization.
50
- * Do this in a fresh typerstate unless `keepConstraint` is true .
50
+ * If `keepConstraint` is false, the current constraint set will not be modified by this call .
51
51
*/
52
52
def normalizedCompatible (tp : Type , pt : Type , keepConstraint : Boolean )(using Context ): Boolean =
53
53
@@ -64,15 +64,19 @@ object ProtoTypes {
64
64
i """ normalizedCompatible for $poly, $pt = $result
65
65
|constraint was: ${ctx.typerState.constraint}
66
66
|constraint now: ${newctx.typerState.constraint}""" )
67
- val existingVars = ctx.typerState.uninstVars.toSet
68
67
if result
69
68
&& (ctx.typerState.constraint ne newctx.typerState.constraint)
70
- && newctx.typerState.uninstVars.forall(existingVars.contains)
69
+ && {
70
+ val existingVars = ctx.typerState.uninstVars.toSet
71
+ newctx.typerState.uninstVars.forall(existingVars.contains)
72
+ }
71
73
then newctx.typerState.commit()
72
74
// If the new constrait contains fresh type variables we cannot keep it,
73
75
// since those type variables are not instantiated anywhere in the source.
74
76
// See pos/i6682a.scala for a test case. See pos/11243.scala and pos/i5773b.scala
75
77
// for tests where it matters that we keep the constraint otherwise.
78
+ // TODO: A better solution would clean the new constraint, so that it "avoids"
79
+ // the problematic type variables. But we have not implemented such an algorithm yet.
76
80
result
77
81
case _ => testCompat
78
82
else explore(testCompat)
@@ -95,8 +99,8 @@ object ProtoTypes {
95
99
if pt.constrainResultDeep
96
100
&& mt.isImplicitMethod == (pt.applyKind == ApplyKind .Using )
97
101
then
98
- val tpargs = pt.args.lazyZip(mt.paramInfos).map(pt.typedArg)
99
- tpargs.tpes.corresponds(mt.paramInfos)(_ <:< _ )
102
+ pt.args.lazyZip(mt.paramInfos).forall((arg, paramInfo) =>
103
+ pt.typedArg(arg, paramInfo).tpe <:< paramInfo )
100
104
else true
101
105
}
102
106
case _ => true
0 commit comments