Skip to content

Extension method fails to construct with <overloaded XX> does not take parameters #13668

Closed
@soronpo

Description

@soronpo

When an extension method is defined for a typeclass more than once but with different arguments, it fails to construct if the method argument has type arguments. If we were to remove the type arguments, the method construction works.

Compiler version

v3.1.0-RC2

Minimized code

class MyType()
trait Candidate[R]
given Candidate[MyType] with {}
class Fuzzy[W]()
class Fuzzy1()
class Bear()

extension [L](lhs: L)(using Candidate[L])
  def +[RW](rhs: Fuzzy[RW]): Unit = {}
  def +(rhs: Bear): Unit = {}
  def -(rhs: Fuzzy1): Unit = {}
  def -(rhs: Bear): Unit = {}

val works = MyType() - Fuzzy1()
val fails = MyType() + Fuzzy[1]()

Output

[error] 15 |val fails = MyType() + Fuzzy[1]()
[error]    |            ^^^^^^^^^^
[error]    |      value + is not a member of MyType.
[error]    |      An extension method was tried, but could not be fully constructed:
[error]    |
[error]    |          +()    failed with
[error]    |
[error]    |              value +: <overloaded +> does not take parameters
[error] one error found

Expectation

No error.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions