Skip to content

Commit 9f444a8

Browse files
committed
Address review comments
1 parent 2396a1b commit 9f444a8

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ object ProtoTypes {
4747
necessarySubType(tpn, pt) || tpn.isValueSubType(pt) || viewExists(tpn, pt)
4848

4949
/** 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.
5151
*/
5252
def normalizedCompatible(tp: Type, pt: Type, keepConstraint: Boolean)(using Context): Boolean =
5353

@@ -64,15 +64,19 @@ object ProtoTypes {
6464
i"""normalizedCompatible for $poly, $pt = $result
6565
|constraint was: ${ctx.typerState.constraint}
6666
|constraint now: ${newctx.typerState.constraint}""")
67-
val existingVars = ctx.typerState.uninstVars.toSet
6867
if result
6968
&& (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+
}
7173
then newctx.typerState.commit()
7274
// If the new constrait contains fresh type variables we cannot keep it,
7375
// since those type variables are not instantiated anywhere in the source.
7476
// See pos/i6682a.scala for a test case. See pos/11243.scala and pos/i5773b.scala
7577
// 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.
7680
result
7781
case _ => testCompat
7882
else explore(testCompat)
@@ -95,8 +99,8 @@ object ProtoTypes {
9599
if pt.constrainResultDeep
96100
&& mt.isImplicitMethod == (pt.applyKind == ApplyKind.Using)
97101
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)
100104
else true
101105
}
102106
case _ => true

0 commit comments

Comments
 (0)