Skip to content

Overloading doesn't work with contextual functions #7790

Closed
@anatoliykmetyuk

Description

@anatoliykmetyuk

minimized code

trait Foo
  given Int = 10
  def map(f: Int ?=> Int) = f
  def map(f: Int ?=> String) = f

@main def Test =
  val m: Foo = ???
  m.map((using x: Int) => x)

Says:

-- [E134] Type Mismatch Error: /Users/kmetiuk/Projects/scala3/pg/sandbox/iss1.scala:8:4
8 |  m.map((given x: Int) => x)
  |  ^^^^^
   |None of the overloaded alternatives of method map in trait Foo with types
   | (f: (Int) ?=> String): String
   | (f: (Int) ?=> Int): Int
   |match arguments ((Int) ?=> Int)
1 error found

expectation

Clearly the alternative (f: (Int) ?=> Int): Int should match the argument (Int) ?=> Int.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions