Uploaded image for project: 'Scala Programming Language'
  1. Scala Programming Language
  2. SI-1503

Casts inserted when pattern matching for equality on singletons are unsound

    Details

      Description

      I've added a test to pending/run/castsingleton.scala:

      object Test extends Application {
        case class L();
        object N extends L();
       
        def empty(xs : L) : Unit = xs match {
          case x@N => println(x); println(x);
        }
       
        empty(L())
      } 
      

      The problem is that the compiler inserts a cast of xs to N.type, which is unsound: The pattern match will succeed for any L, because N == L().

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                moors Adriaan Moors
                Reporter:
                drmaciver David R. MacIver
                TracCC:
                Erik Engbrecht, Paul Phillips
              • Votes:
                5 Vote for this issue
                Watchers:
                14 Start watching this issue

                Dates

                • Created:
                  Updated: