Skip to content

Given instances' extension methods with implicit arguments don't chain #7084

@anatoliykmetyuk

Description

@anatoliykmetyuk
type Foo

given A {
  def (y: Any) g given Foo: Any = ???
}

def f(x: Any) given Foo: Any = x.g.g

Out:

-- [E008] Member Not Found Error: ../pg/Macros2.scala:7:33 ---------------------
7 |def f(x: Any) given Foo: Any = x.g.g
  |                               ^^^
  |        value g is not a member of Any - did you mean x.==?.
  |        An extension method was tried, but could not be fully constructed:
  |
  |            Macros2$package.A.g(x)
one error found

However, the following works:

type Foo

given A {
  def (y: Any) g given Foo: Any = ???
}

def f(x: Any) given Foo: Any = {
  val a = x.g
  a.g
}

The following also works:

type Foo

def (y: Any) g given Foo: Any = ???

def f(x: Any) given Foo: Any = x.g.g

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