Skip to content

Commit

Permalink
Also handle ImportTypes depending on this references
Browse files Browse the repository at this point in the history
  • Loading branch information
EugeneFlesselle committed Jun 27, 2024
1 parent d9d7f28 commit 6ad4fd8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
5 changes: 2 additions & 3 deletions compiler/src/dotty/tools/dotc/inlines/Inliner.scala
Original file line number Diff line number Diff line change
Expand Up @@ -567,9 +567,8 @@ class Inliner(val call: tpd.Tree)(using Context):
case t: TypeRef => paramProxy.getOrElse(t, mapOver(t))
case t: TermRef if t.symbol.isImport =>
val ImportType(e) = t.widenTermRefExpr: @unchecked
paramProxy.get(e.tpe) match
case Some(p) => newImportSymbol(ctx.owner, singleton(p)).termRef
case None => mapOver(t)
val e1 = singleton(apply(e.tpe))
newImportSymbol(ctx.owner, e1).termRef
case t: SingletonType =>
if t.termSymbol.isAllOf(InlineParam) then apply(t.widenTermRefExpr)
else paramProxy.getOrElse(t, mapOver(t))
Expand Down
15 changes: 14 additions & 1 deletion tests/pos/i19493.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,21 @@ object Minimization:

inline def foo(x: GivesString): Unit =
import x.aString
summon[String]
summon[String] // ok
summonInline[String] // was error

foo(???)


trait A:
val x: GivesString

inline def bar: Unit =
import this.x.aString
summon[String] // ok
summonInline[String] // was error

val a: A = ???
a.bar

end Minimization

0 comments on commit 6ad4fd8

Please sign in to comment.