Skip to content

s.c.m.Buffer#append method is ambiguous #11112

@joshlemer

Description

@joshlemer

scala.collection.mutable.Buffer defines two append methods. One is single-arg, the other is var-arg. This means that you cannot call the single-arg version because it is ambiguous with a single-elem var-arg call.

the method definitions:

  @`inline` final def append(elem: A): this.type = addOne(elem)

  @deprecated("Use appendAll instead", "2.13.0")
  @`inline` final def append(elems: A*): this.type = addAll(elems)

an example error:

[error] /Users/joshlemer/IdeaProjects/scala2/src/library/scala/collection/immutable/ChampHashSet.scala:831: ambiguous reference to overloaded definition,
[error] both method append in trait Buffer of type (elems: Any*)hc.content.type
[error] and  method append in trait Buffer of type (elem: Any)hc.content.type
[error] match argument types (A)
[error]         hc.content.append(element)
[error]                    ^

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions