Skip to content

Ambiguous overload between varargs and non-varargs #9688

Closed
@eloots

Description

@eloots

Minimized code

Calling a method on the Java Log4J library with 2 arguments (the last one in a position where a varargs polymorphic version exists) results in the compiler reporting an error.

  context.log.error("Received unexpected message in state 'trackProgress': {}", msg)

Compiling the above line results in the following error message:

Output

[error] -- [E051] Reference Error: /Users/ericloots/Trainingen/LBT/lunatech-scala-2-to-scala3-course/exercises/exercise_000_sudoku_solver_initial_state/src/main/scala/org/lunatechlabs/dotty/sudoku/SudokuProgressTracker.scala:43:20
[error] 43 |        context.log.error("Received unexpected message in state 'trackProgress': {}", msg)
[error]    |        ^^^^^^^^^^^^^^^^^
[error]    |Ambiguous overload. The overloaded alternatives of method error in trait Logger with types
[error]    | (x$0: String, x$1: Object*): Unit
[error]    | (x$0: String, x$1: Object): Unit
[error]    |both match arguments (("Received unexpected message in state \'trackProgress\': {}" : String), (msg : org.lunatechlabs.dotty.sudoku.SudokuProgressTracker.SudokuDetailState))

Expectation

The sample line of code given above should compile (as it does in pre-0.27.0 and of course Scala 2.x)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions