Skip to content

Type inference issue in presence of overloads using varargs #11015

@julienrf

Description

@julienrf

As reported in etorreborre/specs2#687 (comment), overloading resolution does not play well with type inference in the following case:

class X[A] {
  def append(a: A): Unit = ()
  def append(a: A*): Unit = ()
}

case class Foo[A](value: Int)

val x = new X[Foo[String]]

x.append(Foo(2))
// overloaded method value append with alternatives:
//   (a: Playground.this.Foo[String]*)Unit 
//   (a: Playground.this.Foo[String])Unit
//  cannot be applied to (Playground.this.Foo[Nothing])

x.append(Foo[String](2)) // OK if the type parameter of `Foo` is explicitly instantiated

This could be a problem for us because scala/scala#6879 did introduce such problematic overloads.

Metadata

Metadata

Assignees

Labels

fixed in Scala 3This issue does not exist in the Scala 3 compiler (https://github.com/lampepfl/dotty/)has PRvarargs

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions