Skip to content

Inlined closure argument retains NamedArg tree #17227

@nicolasstucki

Description

@nicolasstucki

Compiler version

3.2, bcaa1ca

Minimized code

inline def foo(f: Int => Int): Int => Int = f
inline def bar(inline f: Int => Int): Int => Int = f

def g(i: Int): Int = i

def test =
  foo(f = g)
  bar(f = g)

Output

-Xprint:inlining

package <empty> {
  final lazy module val Test_2$package: Test_2$package = new Test_2$package()
  @SourceFile("t/Test_2.scala") final module class Test_2$package() extends
    Object() { this: Test_2$package.type =>
    private def writeReplace(): AnyRef =
      new scala.runtime.ModuleSerializationProxy(classOf[Test_2$package.type])
    def g(i: Int): Int = i
    def test: Int => Int =
      {
        {
          val f$proxy1: Int => Int =
            f =
              {
                def $anonfun(i: Int): Int = g(i)
                closure($anonfun)
              }
          f$proxy1:(Int => Int)
        }
        f =
          {
            def $anonfun(i: Int): Int = g(i)
            closure($anonfun)
          }
        :(Int => Int)
      }
  }
}

Expectation

We should not inline the f = from the named argument (NamedArg).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions