Skip to content

SAM conversion fails with "cannot override an extension method" for Self-based type classes #24765

@halotukozak

Description

@halotukozak

Compiler version

3.8.0-RC1

Minimized code

trait A[T]:
  extension(t: T) def foo: T

trait B:
  type Self
  extension(t: Self) def foo: Self

given A[Int] = x => x // ok

given Int is B = x => x

Output

error overriding method foo in trait B of type (t: Self): Self;
  method foo of type (x: Int): Int is a normal method, cannot override an extension method

Expectation

The error message doesn't seem to be true, since the first one compiles. I assume, it's valid, but with a different reason.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions