Skip to content

Wrong rewrite of implicit arguments passed as { } #22731

Closed
@OndrejSpanel

Description

@OndrejSpanel

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.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions