Skip to content

Explicit type parameter for method from extension with trailing using clause #11168

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
prolativ opened this issue Jan 19, 2021 · 0 comments · Fixed by #11203
Closed

Explicit type parameter for method from extension with trailing using clause #11168

prolativ opened this issue Jan 19, 2021 · 0 comments · Fixed by #11203

Comments

@prolativ
Copy link
Contributor

Minimized code

trait Foo
given foo: Foo with {}

extension (using Foo)(x: Any)
  def foo1[A] = ???

extension (x: Any)(using Foo)
  def foo2[A] = ???

implicit class LeadingFooOps(using Foo)(x: Any) {
  def foo3[A] = ???
}

implicit class TrailingFooOps(x: Any)(using Foo) {
  def foo4[A] = ???
}

def a1 = "".foo1[Any]
def a2 = "".foo2[Any]
def a3 = "".foo3[Any]
def a4 = "".foo4[Any]

def b2 = "".foo2(using foo)[Any]

def c1 = foo1("")[Any]
def c2 = foo2("")[Any]

def d1 = foo1(using foo)("")[Any]
def d2 = foo2("")(using foo)[Any]

Output

19 |def a2 = "".foo2[Any]
   |         ^^^^^^^^^^^^
   |   method (using x$2: Foo): [A] => Nothing does not take type parameters

26 |def c2 = foo2("")[Any]
   |         ^^^^^^^^^^^^^
   |   method (using x$2: Foo): [A] => Nothing does not take type parameters
2 errors found

Expectation

It should be possible to explicitly pass type parameters to a method defined in an extension which has trailing using clauses just as it is possible when using an implicit class instead of an extension. For consistency this should be possible also when calling the extension method as a normal method (without a dot)

odersky added a commit to dotty-staging/dotty that referenced this issue Jan 24, 2021
Handle adaptation of a method that takes using clause and then a type parameter.
When passing a type argument, we have to first insert an implicit argument for
the using clause.

Fixes scala#11168
@Kordyjan Kordyjan added this to the 3.0.0 milestone Aug 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants