scala / bug

Scala 2 bug reports only. Please, no questions — proper bug reports only.
https://scala-lang.org
230 stars 21 forks source link

Literal pattern must conform to the expected type #12722

Open som-snytt opened 1 year ago

som-snytt commented 1 year ago

Reproduction steps

Scala version: 2.13.10

class C {
  def f(n: Short) =
    n match {
      case 2147483647 => true
      //case -1 => true
      case _ => false
    }
}

Problem

Expected an error that Short is required.

This is specified, and is analogous to stable identifier pattern.

Also as specified, the pattern literal is Short by virtue of the expected type (if it is in range).

SethTisue commented 11 months ago

https://github.com/scala/scala/pull/10290 appears abandoned.

SethTisue commented 11 months ago

Scala 3 (3.4.0-RC1-bin-20230807-84099a7-NIGHTLY) is silent as well.

som-snytt commented 11 months ago

It appears abandoned but I am still inside peering out from behind the locked shutters.

som-snytt commented 8 months ago

SLS 8.1.4 is cited on the dotty ticket.