Skip to content

Extension methods ambiguous despite being the same #24121

@rjolly

Description

@rjolly

Compiler version

3.8.0-RC1-bin-20251002-b7cae74-NIGHTLY

Minimized code

trait R[T]:
  extension (x: T) def m: T

trait S[T] extends R[T]

trait A[T]:
  given R[T] = scala.compiletime.deferred

class B[T : S](x: T) extends A[T]:
  override given S[T] = summon
  x.m

Output

  x.m
  ^
Found:    (B.this.x : T)
Required: ?{ m: ? }
Note that implicit extension methods cannot be applied because they are ambiguous;
both given instance evidence$1 in class B and given instance given_S_T in class B provide an extension method `m` on (B.this.x : T)

Expectation

Should not be ambiguous since the typeclass instance is the same.

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