diff --git a/compiler/src/dotty/tools/dotc/core/TypeErasure.scala b/compiler/src/dotty/tools/dotc/core/TypeErasure.scala index c201ecd06054..c914dcdf7e5c 100644 --- a/compiler/src/dotty/tools/dotc/core/TypeErasure.scala +++ b/compiler/src/dotty/tools/dotc/core/TypeErasure.scala @@ -239,8 +239,7 @@ object TypeErasure { * TermRefs are kept instead of being widened away. */ def erasedRef(tp: Type)(using Context): Type = tp match { - case tp: TermRef => - assert(tp.symbol.exists, tp) + case tp: TermRef if tp.symbol.exists => val tp1 = makePackageObjPrefixExplicit(tp) if (tp1 ne tp) erasedRef(tp1) else TermRef(erasedRef(tp.prefix), tp.symbol.asTerm) diff --git a/tests/pos/i18721.min/core.scala b/tests/pos/i18721.min/core.scala new file mode 100644 index 000000000000..02b172fdd73b --- /dev/null +++ b/tests/pos/i18721.min/core.scala @@ -0,0 +1,5 @@ +class Foo +class Bar extends Selectable: + def selectDynamic(name: String): Foo = null + +inline def meth(inline foo: Foo): Foo = foo diff --git a/tests/pos/i18721.min/main.scala b/tests/pos/i18721.min/main.scala new file mode 100644 index 000000000000..a62ee8b0562b --- /dev/null +++ b/tests/pos/i18721.min/main.scala @@ -0,0 +1,3 @@ +class Test: + def t1(bar: Bar { val foo: Foo }): Any = + meth(bar.foo)