Skip to content

Commit

Permalink
Avoid crash in erasure when reference cannot be emitted
Browse files Browse the repository at this point in the history
Fixes #17391
  • Loading branch information
odersky committed Jun 25, 2023
1 parent ceca748 commit 7065e50
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/transform/Erasure.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
7 changes: 7 additions & 0 deletions tests/neg/i17391/Bar.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package mypkg;

class Base<E> {
public void retainAll(String x) {}
}

public class Bar<E> extends Base<E> {}
11 changes: 11 additions & 0 deletions tests/neg/i17391/test.scala
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 7065e50

Please sign in to comment.