Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fallback erasing term references #18731

Merged
merged 1 commit into from
Oct 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Loading