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

Regression in @switch pattern matches with guards

    Details

      Description

      This code succeeds in 2.9.x, but fails in 2.10.0-SNAPSHOT. The old pattern matcher would move the guard inside the branch if there were no other branches with the same value.

      import scala.annotation._
      
      object Foo extends App {
      	def eof: Boolean = false
      
      	def method(ch: Char) = (ch: @switch) match {
      	    case 'a' if eof => println("a with oef")
      	    case 'b' => println("b")
      	    case 'c' => println("c")
      	}
      }
      

      It says:

      switch-pat.scala:6: error: could not emit switch for @switch annotated match
      	def method(ch: Char) = (ch: @switch) match {
                                           ^
      one error found
      

        Issue Links

          Activity

          Show
          Adriaan Moors added a comment - https://github.com/scala/scala/pull/821

            People

            • Assignee:
              Adriaan Moors
              Reporter:
              Iulian Dragos
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development