Skip to content

Commit 74b6133

Browse files
Backport "Fallback erasing term references" to LTS (#20650)
Backports #18731 to the LTS branch. PR submitted by the release tooling.
2 parents 7224aaa + 5d7d518 commit 74b6133

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

compiler/src/dotty/tools/dotc/core/TypeErasure.scala

+1-2
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,7 @@ object TypeErasure {
239239
* TermRefs are kept instead of being widened away.
240240
*/
241241
def erasedRef(tp: Type)(using Context): Type = tp match {
242-
case tp: TermRef =>
243-
assert(tp.symbol.exists, tp)
242+
case tp: TermRef if tp.symbol.exists =>
244243
val tp1 = makePackageObjPrefixExplicit(tp)
245244
if (tp1 ne tp) erasedRef(tp1)
246245
else TermRef(erasedRef(tp.prefix), tp.symbol.asTerm)

tests/pos/i18721.min/core.scala

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class Foo
2+
class Bar extends Selectable:
3+
def selectDynamic(name: String): Foo = null
4+
5+
inline def meth(inline foo: Foo): Foo = foo

tests/pos/i18721.min/main.scala

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
class Test:
2+
def t1(bar: Bar { val foo: Foo }): Any =
3+
meth(bar.foo)

0 commit comments

Comments
 (0)