diff --git a/tests/neg/i5418.scala b/tests/neg/i5418.scala new file mode 100644 index 000000000000..900cf6a70ccc --- /dev/null +++ b/tests/neg/i5418.scala @@ -0,0 +1,14 @@ +class Test { + class Tree[A] + + def fromOrderedKeys[A](xs: Iterator[A]): Tree[A] = ??? + + def from[E](it: Iterable[E]): Tree[E] = + it match { + case r: Range => + val it = r.iterator + + // instantiation of covariant GADTs is unsound + fromOrderedKeys(it) // error: type mismatch: found: Iterator[Int](it), required Iterator[E] + } +}