Skip to content

Call to parameterless extension method does not work with given  #7119

Closed
@SrTobi

Description

@SrTobi

minimized code

I'm on 0.18.1-bin-20190827-2bbfd17-NIGHTLY

class Impl

def (impl: Impl) prop given Int = the[Int]


def main(args: Array[String]): Unit = {
  println(Impl().prop given 3)
}

expectation

Compiles and prints 3

actual

[error] -- [E008] Member Not Found Error: /[...]/dotty-test/src/main/scala/Main.scala:11:17 
[error] 11 |  println(Impl().prop given 3)
[error]    |          ^^^^^^^^^^^
[error]    |          value prop is not a member of Main.Impl
[error] one error found

note

If it's not an extension method it works

class Impl {
  def prop given Int = the[Int]
}

def main(args: Array[String]): Unit = {
  println(Impl().prop given 3)
}

Also when the extension methods has an empty parameter clause it also works

class Impl

def (impl: Impl) prop() given Int = the[Int]


def main(args: Array[String]): Unit = {
  println(Impl().prop() given 3)
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions