Skip to content

Inline extension method leaks out proxy variable to macros #16106

Closed
@eed3si9n

Description

@eed3si9n

Compiler version

If you're not sure what version you're using, run print scalaVersion from sbt
(if you're running scalac manually, use scalac -version instead).

Minimized code

I don't have minimized repro yet. In sbt .value method for a setting is implemented as follows:

  extension [A1](in: Initialize[A1])
    inline def value: A1 = InputWrapper.wrapInit[A1](in)

For example,

name := "abc" + version.value

first becomes

name := "abc" + InputWrapper.wrapInput(version)

Later on :=(...) macro expands the above to

name.set(version.mapN { p0 => "abc" + p0 })

Output

While expanding a macro, a reference to value in$proxy1 was used outside the scope where it was defined

This happens I think because .value expands to

name := "abc" + {
  val in$proxy1 = version
  InputWrapper.wrapInput(in$proxy1)
}

Expectation

Inline extension method is inlined.

As a workaround, I've started inlining these myself - https://gist.github.com/eed3si9n/6fc1e89f9a730f0e827327af0c268cb1

Metadata

Metadata

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions