- 
                Notifications
    You must be signed in to change notification settings 
- Fork 1.1k
Keep inlined nodes until the backend phase #18230
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
base: main
Are you sure you want to change the base?
Conversation
Check if the copied inlined node's expansion exists, and if not set it to the original node's expansion
135f6cd    to
    1355b26      
    Compare
  
    Refactoring of inlined nodes to simplify the work on scala#17055. This work is based on scala#18229.
1355b26    to
    66ddf48      
    Compare
  
    | case _ => | ||
| } | ||
| (scall, stats ::: inits, args) | ||
| case inlined @ Inlined(_, _, _) => transformConstructor(Inlines.dropInlined(inlined) ) | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why was this one needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
newClassExtendsClassParams was finding an unexpected inlined node while transforming the constructor
| I have investigated the failures, and this is what I found. Consider the following example compiled with  object Test:
  inline def foo(xs: List[Int]): Unit =
    val f = () => xs
    ()
  def test = foo(Nil)before lambda lift we will have     def test(): Unit =
      {{/* inlined from Test.foo(Nil) */
        {
          val f: Function0 =
            {
              def $anonfun(): scala.collection.immutable.List =
                {{/* inlined from outside */Nil()}}
              closure($anonfun:Function0)
            }
          ()
        }
      }}but after lambda lift we get     def test(): Unit =
      {{/* inlined from Test.foo(Nil) */
        {
          val f: Function0 =
            {
              closure(this.$anonfun$1:Function0)
            }
          ()
        }
      }}
    private final def $anonfun$1(): scala.collection.immutable.List =
      {{/* inlined from outside */Nil()}}Note that  It seems we will need to redesign the contents of  | 
| Inlined trees with an empty call cannot just be dropped when lambda lifted. For example the lifted argument in the following example should be marked as inlined from  object Test:
  inline def bar(): Unit = foo(Nil)
  inline def foo(xs: List[Int]): Unit =
    val f = () => xs
    ()
  def test = bar() | 
| Maybe we could change this     def test(): Unit =
      {{/* inlined from Test.bar() */
        {{/* inlined from Test.foo(Nil) */
          {
            val f: Function0 =
              {
                def $anonfun(): scala.collection.immutable.List =
-                  {{/* inlined from outside */Nil()}}
+                  {{/*  inlined from Test.foo(Nil) */Nil()}}
                closure($anonfun:Function0)
              }
            ()
          }
        }}
      }}But we would also need to change the way we handle nested inline contexts. We might add a new field to state if the inline node is adding a scope or poping it. We would need to make this after the pickling phases (Pickling and PickleQuotes) to make sure that we do not change the current behavior of TASTy. | 
This is the first step towards supporting `Inlined` trees after lambda lift (see #18230 (comment)). We decouple the way we compute if a call was inlined from an outer scope from the inlined call.
Refactoring of inlined nodes to simplify the work on #17055.
This work is based on #18229.