diff --git a/compiler/src/dotty/tools/dotc/transform/Erasure.scala b/compiler/src/dotty/tools/dotc/transform/Erasure.scala index f068a48cdba4..8e355175c176 100644 --- a/compiler/src/dotty/tools/dotc/transform/Erasure.scala +++ b/compiler/src/dotty/tools/dotc/transform/Erasure.scala @@ -764,7 +764,9 @@ object Erasure { val symIsPrimitive = sym.owner.isPrimitiveValueClass def originalQual: Type = - erasure(tree.qualifier.typeOpt.widen.finalResultType) + erasure( + inContext(preErasureCtx): + tree.qualifier.typeOpt.widen.finalResultType) if (qualIsPrimitive && !symIsPrimitive || qual.tpe.widenDealias.isErasedValueType) recur(box(qual)) @@ -869,7 +871,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/pos/i17391/Bar.java b/tests/pos/i17391/Bar.java new file mode 100644 index 000000000000..6d432926bde2 --- /dev/null +++ b/tests/pos/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/pos/i17391/test.scala b/tests/pos/i17391/test.scala new file mode 100644 index 000000000000..dbcc0ec39de8 --- /dev/null +++ b/tests/pos/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)