Description
When the IDE works with trees coming from TASTy, it cannot see the trees before inlining. That means that find all references
and rename
can return wrong results. All of that happens because we cannot see the original call in the trees that have been unpickled.
Example:
@Test def referencesInlineArg: Unit = {
withSources(
tasty"""package foo
|object Bar {
| val fizz = Foo.foo(Foo.${m1}myValue${m2})
|}""",
code"""package foo
|object Foo {
| inline def foo(x: Int): Int = 0
| val ${m3}myValue${m4} = 3
|}"""
).references(m3 to m4, List(m1 to m2, m3 to m4), withDecl = true)
.references(m3 to m4, List(m1 to m2), withDecl = false)
}
The references inside object Bar
will not be seen by the IDE. Note that object Bar
is not opened , but its trees will be unpickled. If we use the code
interpolator instead of tasty
, then the test passes.
This used to be fine after @nicolasstucki moved inlining out of typer in #5216, but this was reverted by @odersky in #5382 and #5383.
My understanding is that the original call is removed because its size may explode. Would it be possible to improve on that by only storing pre-expansion trees in the original call?
Considering the following source:
object Foo {
inline def foo(x: Int): Int = /* something huge */
inline def bar: Int = /* something huge */
inline def baz: Int = /* something huge */
inline def fizz(a: Int, b: Int) = /* ... */
}
object Bar {
import Foo._
val buzz = fizz(foo(baz), bar)
}
What I'm suggesting is that the RHS of val buzz
could be
Inlined(
call = Apply(fizz, List(Apply(foo, List(baz)), bar)),
expansion = /* ... */)
instead of
Inlined(
call = Apply(fizz,
List(
Inlined(
call = Apply(foo, List(/* something huge */)),
expansion = /* something huge */),
Inlined(
call = Apply(bar, List(/* something huge */)),
expansion = /* something huge */))),
expansion = /* ... */)
which would be more helpful than the current
Inlined(
call = Foo,
expansion = /* ... */)
Would it be possible to create this original call and store it? Would that solve the bytecode size issues?
None of this is a concern for incremental compilation, because the original call is removed after ExtractDependencies
.