Skip to content

Overload perturbs extension with varargs #12133

Closed
@rjolly

Description

@rjolly

Compiler version

3.0.0-RC2

Minimized code and output

class B

class A {
  def foo(x: B) = ???
  def foo(str: String) = ???
}

extension (x: A) def foo(s: Int*) = s.size

val a = new A

println(a.foo(1, 2))
//        ^^^^
//        Found:    (Int, Int)
//        Required: Int

Expectation : should work as when there's no overload:

class A {
  def foo(x: B) = ???
//def foo(str: String) = ???
}

println(a.foo(1, 2))
// 2

Note that when there's just one parameter it also works

class A {
  def foo(x: B) = ???
  def foo(str: String) = ???
}

println(a.foo(1))
// 1

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions