Skip to content

Commit 72d7bc4

Browse files
committed
Give an error when constraints are unsatisfiable
Not sure this is necessary, but it's not obvious that having *another* error downstream is guaranteed, so giving one right away sounds safer. OTOH, it's not immediate to give a *good* error (which bound is violated?), and if there is a check downstream I'd rather rely on that.
1 parent 6044a54 commit 72d7bc4

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,9 @@ object ProtoTypes {
480480
else tl
481481
val added = ensureFresh(tl)
482482
val tvars = if (addTypeVars) newTypeVars(added) else Nil
483-
ctx.typeComparer.addToConstraint(added, tvars.tpes.asInstanceOf[List[TypeVar]])
483+
if (!ctx.typeComparer.addToConstraint(added, tvars.tpes.asInstanceOf[List[TypeVar]])) {
484+
ctx.error(s"Unsatisfiable type parameter constraints in polymorphic application", owningTree.pos)
485+
}
484486
(added, tvars)
485487
}
486488

tests/neg/i4721.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
object Test {
2-
def main(args: Array[String]):Unit = m(1) // error
2+
def main(args: Array[String]):Unit = m(1) // error // error
33
def m[Y<:String, Z>:Int, W>:Z<:Y](d:Y):Unit={}
44
}

0 commit comments

Comments
 (0)