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

Inlined closure argument retains NamedArg tree #17227

Closed
nicolasstucki opened this issue Apr 11, 2023 · 0 comments · Fixed by #17228
Closed

Inlined closure argument retains NamedArg tree #17227

nicolasstucki opened this issue Apr 11, 2023 · 0 comments · Fixed by #17228

Comments

@nicolasstucki
Copy link
Contributor

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants