Skip to content

[Regression in 3.1.2-RC1] Inferred union in type argument position gets widened #14494

Closed
@ansvonwa

Description

@ansvonwa

Compiler version

3.1.2-RC1

First bad commit 3ab18a9 in #14026

Minimized code

object ImplNotFound:
  def main(args: Array[String]): Unit =
    val res: Seq[String | Int] = (??? : Seq[Int]).collect {
      case 1 => Seq("")
      case 2 => Seq(1)
    }.flatten

Output

[error] -- Error: /.../ImplNotFound.scala:6:13 
[error] 6 |    }.flatten
[error]   |             ^
[error]   |no implicit argument of type Seq[Matchable] => IterableOnce[B] was found for parameter asIterable of method flatten in trait IterableOps
[error]   |
[error]   |where:    B is a type variable with constraint <: String | Int

Expectation

Successful compilation as in 3.0.0 to 3.1.1

Metadata

Metadata

Assignees

Labels

area:implicitsrelated to implicitsitype:bugregressionThis worked in a previous version but doesn't anymore

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions