Skip to content

Misleading error on unknown member in context function #12487

Closed
@kubukoz

Description

@kubukoz

Compiler version

3.0.0

Minimized code

trait A {
  def combine(another: A): A = ???
}

trait Dsl {
  def example: A
}

object Dsl {
  def execute(program: (dsl: Dsl) ?=> Int): String = ???
}

def example(using a: Dsl): A = ???

import Dsl._

def demo = Dsl.execute {
  // change to `combine` and it compiles
  example notCombine example
  42
}

Output

no implicit argument of type Dsl was found for parameter a of method example

Expectation

value notCombine is not a member of A

Note: the correct behavior is triggered if execute is a top level definition, or it's imported from Dsl._ and used without a prefix.

The same behavior can be seen if combine is an extension method instead of a direct one.

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