diff --git a/compiler/src/dotty/tools/dotc/transform/Erasure.scala b/compiler/src/dotty/tools/dotc/transform/Erasure.scala index f068a48cdba4..e20a16c9e60e 100644 --- a/compiler/src/dotty/tools/dotc/transform/Erasure.scala +++ b/compiler/src/dotty/tools/dotc/transform/Erasure.scala @@ -869,7 +869,7 @@ object Erasure { app(fun1) case t => - if ownArgs.isEmpty then fun1 + if ownArgs.isEmpty || t.isError then fun1 else throw new MatchError(i"tree $tree has unexpected type of function $fun/$fun1: $t, was $origFunType, args = $ownArgs") end typedApply diff --git a/tests/neg/i17391/Bar.java b/tests/neg/i17391/Bar.java new file mode 100644 index 000000000000..6d432926bde2 --- /dev/null +++ b/tests/neg/i17391/Bar.java @@ -0,0 +1,7 @@ +package mypkg; + +class Base { + public void retainAll(String x) {} +} + +public class Bar extends Base {} diff --git a/tests/neg/i17391/test.scala b/tests/neg/i17391/test.scala new file mode 100644 index 000000000000..dbcc0ec39de8 --- /dev/null +++ b/tests/neg/i17391/test.scala @@ -0,0 +1,11 @@ +def test(): Unit = +{ + val x: Foo[mypkg.Bar[String]] = ??? + val y: mypkg.Bar[String] = ??? + + y.retainAll("fd") // works + x.f.retainAll("fd"); // error + +} + +class Foo[T](val f: T)