Skip to content

Overload resolution bug when -Ycc is enabled. #16224

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

Closed
yawen-guan opened this issue Oct 20, 2022 · 1 comment · Fixed by #18067
Closed

Overload resolution bug when -Ycc is enabled. #16224

yawen-guan opened this issue Oct 20, 2022 · 1 comment · Fixed by #18067

Comments

@yawen-guan
Copy link

yawen-guan commented Oct 20, 2022

Compiler version

3.2.1-RC1

Minimized code

 class Delta:
    val value = 1

  def f(v: Int)(using delta: Delta): Int =
    v + delta.value

  def run(): Unit =
    val delta = Delta()
    val x: Map[Char, Int] = Map(
      'a' -> 0,
      'b' -> 1
    )
    val y: Map[Char, Int] = x.map((k, v) => (k, f(v)(using delta)))

Output

it doesn't compile when -Ycc is enabled.

[error] 15 |    val y: Map[Char, Int] = x.map((k, v) => (k, f(v)(using delta)))
[error]    |                            ^^^^^
[error]    |None of the overloaded alternatives of method map in trait IterableOps with types
[error]    | [B](f: ((Char, Int)) => B): scala.collection.immutable.Iterable[B]
[error]    | [K2, V2](f: ((Char, Int)) => (K2, V2)): Map[K2, V2]
[error]    |match arguments ((<?>, <?>) -> <?>)
[error] one error found

With -Ycc flag, it works fine if we specify the type of parameters:

val y: Map[Char, Int] = x.map((k: Char, v: Int) => (k, f(v)(using delta)))

It works fine when -Ycc is disabled.

Expectation

It's expected to be compiled when -Ycc is enabled.

@yawen-guan yawen-guan added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels Oct 20, 2022
@szymon-rd szymon-rd added area:experimental and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Oct 20, 2022
@odersky
Copy link
Contributor

odersky commented Jun 26, 2023

I believe it works now, adding a regression test.

odersky added a commit to dotty-staging/dotty that referenced this issue Jun 26, 2023
odersky added a commit that referenced this issue Jun 27, 2023
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