Skip to content

Error with parameterless extension method overload resolution #7401

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
nicolasstucki opened this issue Oct 10, 2019 · 1 comment
Closed

Error with parameterless extension method overload resolution #7401

nicolasstucki opened this issue Oct 10, 2019 · 1 comment

Comments

@nicolasstucki
Copy link
Contributor

minimized code

object Test {
  given (a: Int) {
    def foo(i: Int): Unit = ()
    def foo: Unit = ()
  }
  val x: Int = 5
  x.foo(4)
  x.foo
}

fails with

11 |  x.foo
   |  ^^^^^
   |  value foo is not a member of Int - did you mean x.+?.
   |  An extension method was tried, but could not be fully constructed:
   |  
   |      Test.given_foo_of_Int.foo(Test.x)

expectation

It should compile and it should generate the same code as

object Test {
  given (a: Int) {
    def foo(i: Int): Unit = ()
    def foo(): Unit = ()
  }
  val x: Int = 5
  x.foo(4)
  x.foo()
}

which does compile.

@nicolasstucki
Copy link
Contributor Author

This also occurs when there are given parameters

object Test {
  given (a: Int) {
    def foo(i: Int)(given Long): Unit = ()
    def foo(given Long): Unit = ()
  }
  given Long = 9
  val x: Int = 5
  x.foo(4)
  x.foo
}
10 |  x.foo
   |  ^^^^^
   |  value foo is not a member of Int - did you mean x.+?.
   |  An extension method was tried, but could not be fully constructed:
   |  
   |      Test.given_foo_of_Int.foo(Test.x)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants