Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
neko-kai opened this issue Aug 25, 2022 · 2 comments · Fixed by #17576
Closed

Comments

@neko-kai
Copy link
Contributor

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
)
@neko-kai neko-kai added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels Aug 25, 2022
neko-kai added a commit to 7mind/izumi that referenced this issue Aug 25, 2022
neko-kai added a commit to 7mind/izumi that referenced this issue Aug 25, 2022
@Kordyjan Kordyjan added area:overloading and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Aug 26, 2022
@Kordyjan
Copy link
Contributor

Still reproducible on the current main.

@som-snytt
Copy link
Contributor

som-snytt commented Aug 26, 2022

It also works to remove the default args. There are a few tickets about unhappy interaction with defaults and overloads.

#12679

Despair at #12679 (comment)

#15898
#14096

@Kordyjan Kordyjan added this to the Future versions milestone Dec 12, 2022
@Kordyjan Kordyjan modified the milestones: Future versions, 3.3.1-RC1 Jan 16, 2023
@anatoliykmetyuk anatoliykmetyuk modified the milestones: 3.3.1-RC1, 3.3.2-RC1 May 22, 2023
ckipp01 added a commit to ckipp01/dotty that referenced this issue May 24, 2023
nicolasstucki added a commit that referenced this issue May 25, 2023
Kordyjan pushed a commit that referenced this issue Nov 16, 2023
[skip community_build]

closes #15913

[Cherry-picked cbd0851]
Kordyjan added a commit that referenced this issue Nov 17, 2023
Backports #17576 to the LTS branch.

PR submitted by the release tooling.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants