Skip to content

Overload breaks implicit resolution #17794

Closed
@Adam-Vandervorst

Description

@Adam-Vandervorst

Compiler version

3.1.2-RC1-bin-20211205-94f4118-NIGHTLY

Minimized code

class A
class B

def f(using a: A): Int = 42
def f(using b: B): Int = 41

@main def m14 =
  given A = new A
  assert(f == 42)

Output

  assert(f == 42)
         ^
Ambiguous overload. The overloaded alternatives of method f in package overload_issue with types
 (using b: overload_issue.B): Int
 (using a: overload_issue.A): Int
both match expected type ?{ == : ? }

Expectation

Compile or give a less cryptic expected type than ?{ == : ? }.
This works fine without this line: def f(using b: B): Int = 41.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions