Skip to content

Ambiguous overload detection bug #14582

Closed
@pootow

Description

@pootow

Compiler version

Scala ( from 3.0.0 to 3.1.2-RC1 )

Minimized code

val map = Map(
  "a" -> 1,
  "b" -> 2
)

val mapView = map.view

val optionMapView = Some(mapView)

val listOfTuples: List[(String, String)] = List(("c", "d"), ("e", "f"))

val mapViewWithDefault = optionMapView.getOrElse(Map())

val result = mapViewWithDefault ++ listOfTuples

println(result.toSeq)

Output

On scala 2, it prints List((a,1), (b,2), (c,d), (e,f)), but on scala 3, it gives a compile error:

Ambiguous overload. The overloaded alternatives of method ++ in trait IterableOps with types
 [B >: (String | Nothing, Int)](suffix: IterableOnce[B]): Iterable[B]
 [B >: (String | Nothing, Int)](suffix: IterableOnce[B]): Iterable[B]
both match arguments ((Playground.listOfTuples : List[(String, String)]))

Here is the scastie of this code snippet: https://scastie.scala-lang.org/P0gdvfw8Qg2cGnOcL0bAwg

Expectation

Compiles with no error.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions