Skip to content

Overload resolution fails to disambiguate between the alternatives #23773

@hamzaremmal

Description

@hamzaremmal

Compiler version

8c3f1a6

Minimized code

trait Foo[T]

def foo[A]: Int = ???
def foo[A: Foo]: Int = ???

extension (x: Int)
  def succ: Int = x + 1

val a = foo[Int]
val b = foo[Int].succ // error

Output

-- [E134] Type Error: test.scala:10:8 ------------------------------------------
10 |val b = foo[Int].succ
   |        ^^^
   |        None of the overloaded alternatives of method foo with types
   |         [A](using evidence$1: Foo[A]): Int
   |         [A]: Int
   |        match type arguments [Int] and expected type ?{ succ: ? }
1 error found

Expectation

Should work

Notes

I know this will be very very tricky to fix. This fails as overload resolution tries to find an alternative using the expected type (a return type that includes def/val succ, which Int doesn't have) for b.

Metadata

Metadata

Assignees

No one assigned

    Labels

    itype:bugstat:needs triageEvery issue needs to have an "area" and "itype" label

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions