Skip to content

Cannot fully construct extension method for IArray #11358

Closed
@nicolasstucki

Description

@nicolasstucki

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.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions