Skip to content

Overload resolution bug when -Ycc is enabled. #16224

Closed
@yawen-guan

Description

@yawen-guan

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.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions