Skip to content

Overload resolution vs. a vararg method breaks when a type argument is set explicitly #15913

Closed
@neko-kai

Description

@neko-kai

Compiler version

3.1.3 and 3.2.0-RC1

Minimized code

runnable: https://scastie.scala-lang.org/zgzJSXSgQ4uLcczMlsoFOw

class injector[F]

object injectorFactory {
  def apply[F](overrides: String*): injector[F] = new injector[F]

  def apply[F](
    bootstrapActivation: Int = ???,
    overrides: Seq[String] = Seq.empty,
  ): injector[F] = new injector[F]
}

object main extends App {
  println(
    injectorFactory[String](
      bootstrapActivation = 0
    )
  )
}

Output

None of the overloaded alternatives of method apply in object injectorFactory with types
 [F](bootstrapActivation: Int, overrides: Seq[String]): injector[F]
 [F](overrides: String*): injector[F]
match type arguments [String] and arguments ((0 : Int))

Expectation

Expected to compile successfully, as in Scala 2: https://scastie.scala-lang.org/nvb0KV3cTHeJloTyW1SY8g

Workaround: removing the explicit type argument fixes the error:

injectorFactory(
  bootstrapActivation = 0
)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions