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

Cannot resolve overloaded method with default parameters + implicit constraints #15546

Closed
armanbilge opened this issue Jun 29, 2022 · 2 comments · Fixed by #17569
Closed

Cannot resolve overloaded method with default parameters + implicit constraints #15546

armanbilge opened this issue Jun 29, 2022 · 2 comments · Fixed by #17569

Comments

@armanbilge
Copy link
Contributor

Compiler version

3.2.1-RC1-bin-20220627-4be1482-NIGHTLY

Minimized code

//> using scala "3.2.1-RC1-bin-20220627-4be1482-NIGHTLY"

trait Foo[F[_]]

object Bug {
  def apply[F[_]: Foo](
    await: Boolean,
    whatever: Int = 0
  ): Nothing = ???

  def apply[F[_]: Foo]: Nothing =
    apply[F](false)
}

Output

[error] ./bug.scala:12:5: None of the overloaded alternatives of method apply in object Bug with types
[error]  [F[_$3]](implicit evidence$2: Foo[F]): Nothing
[error]  [F[_$2]](await: Boolean, whatever: Int)(implicit evidence$1: Foo[F]): Nothing
[error] match type arguments [F] and arguments ((false : Boolean))
[error]     apply[F](false)
[error]     ^^^^^

Expectation

It compiles in 2.12 and 2.13.

@armanbilge armanbilge added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels Jun 29, 2022
@prolativ prolativ added compat:scala2 area:typer and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Jun 29, 2022
@odersky
Copy link
Contributor

odersky commented Jun 29, 2022

Workaround:

trait Foo[F[_]]

object Bug {
  def apply[F[_]](
    await: Boolean,
    whatever: Int = 0
  )(using Foo[F]): Nothing = ???

  def apply[F[_]](using Foo[F]): Nothing =
    apply[F](false)
}

@odersky
Copy link
Contributor

odersky commented Jun 29, 2022

It also works with -source future, since that translates context bounds into the workaround code.

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.

3 participants