Scala Programming Language
  1. Scala Programming Language
  2. SI-5968

'match may not be exhaustive' warning when matching on singleton types

    Details

      Description

          object X
          def f(e: Either[Int, X.type]) = e match {
            case Left(i) => i
            case Right(X) => 0
          }
      

      gives:

      warning: match may not be exhaustive.
      It would fail on the following input: Right(<not X>)

      Is this correct? Surely the match is in fact exhaustive.

      (c.f. http://stackoverflow.com/questions/11166098/why-does-scala-2-10-give-match-may-not-be-exhaustive-warning-when-matching-on, where it was suggested I post this as a bug report.)

        Activity

        Hide
        Jason Zaugg added a comment -
        Show
        Jason Zaugg added a comment - This seems to do the trick: https://github.com/retronym/scala/compare/ticket/5968
        Hide
        Adriaan Moors added a comment -

        Awesome, thanks Jason! Could you please submit a pullreq?

        Show
        Adriaan Moors added a comment - Awesome, thanks Jason! Could you please submit a pullreq?
        Show
        Jason Zaugg added a comment - https://github.com/scala/scala/commit/1ef679

          People

          • Assignee:
            Jason Zaugg
            Reporter:
            Scott Morrison
          • Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development