Skip to content

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

Closed
@prolativ

Description

@prolativ

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)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions