Skip to content

Commit

Permalink
Backport "Fallback erasing term references" to LTS (#20650)
Browse files Browse the repository at this point in the history
Backports #18731 to the LTS branch.

PR submitted by the release tooling.
  • Loading branch information
WojciechMazur committed Jun 20, 2024
2 parents 7224aaa + 5d7d518 commit 74b6133
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
3 changes: 1 addition & 2 deletions compiler/src/dotty/tools/dotc/core/TypeErasure.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 5 additions & 0 deletions tests/pos/i18721.min/core.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class Foo
class Bar extends Selectable:
def selectDynamic(name: String): Foo = null

inline def meth(inline foo: Foo): Foo = foo
3 changes: 3 additions & 0 deletions tests/pos/i18721.min/main.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class Test:
def t1(bar: Bar { val foo: Foo }): Any =
meth(bar.foo)

0 comments on commit 74b6133

Please sign in to comment.