Skip to content

Missed match on Array(1L) in Scala 3.1.1 #14693

Closed
@devlaam

Description

@devlaam

Observation

Consider the following code:

object MatchTest { 
  val a: Array[Long] = Array(1L)

  def test(x: Any) = x match { 
    case Array(i: Long) => println("Success!")
    case _              => println("Failure!") }

  def main(args: Array[String]): Unit = test(a) }

When run under Scala 2.13.8 this produces Success whereas under Scala 3.1.1 it produces Failure. For the latter it does not matter if the compiler option -source:3.0-migration is used.

Expectation

Same behaviour under both versions or (at least) a warning that the match will fail. Current situation significantly changes runtime behaviour after migrating projects from Scala 2 to Scala 3.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions