Closed
Description
Compiler version
3.7.0-RC1-bin-20250303-91985db-NIGHTLY
Minimized code
class Input(x: String)
trait Decoder[T]
object Decoder {
inline def apply[T](implicit f: () => Unit): Decoder[T] = ???
}
object Input {
given Decoder[Input] = Decoder { () =>
Input("")
}
}
Compile this with "-rewrite", "-source", "3.7-migration".
Output
object Input {
given Decoder[Input] = Decoder using { () =>
Input("")
}
}
The code cannot be compiled, the using
word is placed at a location where it makes no sense.
Note:
- this style is used quite a lot do define custom codecs when using Borer library.
- the code is rewritten correctly when using parentheses, like `given Decoder[Input] = Decoder(() => Input(""))
Expectation
The rewrite should not produce invalid code.