Skip to content

Cannot fully construct extension method for IArray #11358

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 Feb 9, 2021 · 4 comments · Fixed by #11369
Closed

Cannot fully construct extension method for IArray #11358

nicolasstucki opened this issue Feb 9, 2021 · 4 comments · Fixed by #11369

Comments

@nicolasstucki
Copy link
Contributor

Compiler version

Dotty master 6a5565d

Minimized code

def test1: IArray[Int] = IArray(1, 2) +++ IArray(2, 3)
def test2: IArray[Int] = IArray(1, 2) +++ List(2, 3)

extension [A](arr: IArray[A])
  def +++[B >: A: reflect.ClassTag](suffix: IArray[B]): IArray[B] = ???
  def +++[B >: A: reflect.ClassTag](suffix: IterableOnce[B]): IArray[B] = ???

Output

-- [E008] Not Found Error: Foo.scala:3:38 --------------------------------------
3 |def test1: IArray[Int] = IArray(1, 2) +++ IArray(2, 3)
  |                         ^^^^^^^^^^^^^^^^
  |        value +++ is not a member of IArray[Int].
  |        An extension method was tried, but could not be fully constructed:
  |
  |            +++()    failed with
  |
  |                value +++: <overloaded +++> does not take parameters
-- [E008] Not Found Error: Foo.scala:4:38 --------------------------------------
4 |def test2: IArray[Int] = IArray(1, 2) +++ List(2, 3)
  |                         ^^^^^^^^^^^^^^^^
  |        value +++ is not a member of IArray[Int].
  |        An extension method was tried, but could not be fully constructed:
  |
  |            +++()    failed with
  |
  |                value +++: <overloaded +++> does not take parameters
2 errors found

Expectation

Should compile and be equivalent to the code generated for

def test1: IArray[Int] = IArray(1, 2) +++ IArray(2, 3)

extension [A](arr: IArray[A])
  def +++[B >: A: reflect.ClassTag](suffix: IArray[B]): IArray[B] = ???
def test2: IArray[Int] = IArray(1, 2) +++ List(2, 3)

extension [A](arr: IArray[A])
  def +++[B >: A: reflect.ClassTag](suffix: IterableOnce[B]): IArray[B] = ???

which work individually.

@nicolasstucki
Copy link
Contributor Author

This is a blocker for #11354

@nicolasstucki
Copy link
Contributor Author

Simpler version

def test1: IArray[Int] = IArray(1, 2) +++ IArray(2, 3)
def test2: IArray[Int] = IArray(1, 2) +++ List(2, 3)

extension [A](arr: IArray[A])
  def +++[B](suffix: IArray[B]): IArray[B] = ???
  def +++[B](suffix: IterableOnce[B]): IArray[B] = ???

@nicolasstucki
Copy link
Contributor Author

It is probably the double type arguments list

@odersky
Copy link
Contributor

odersky commented Feb 10, 2021

Yes, if there's just one type parameter it works.

@odersky odersky linked a pull request Feb 10, 2021 that will close this issue
@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.

3 participants