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

regression (since 2.9): pattern matcher chokes on invalid pattern with type parameter

    Details

      Description

      Welcome to Scala version 2.10.1 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0-ea).
      
      scala> class Y[T]; 0 match { case Y[_] => }
      <console>:9: error: unsupported pattern: Y[_] (a class scala.reflect.internal.Trees$TypeTree).
       This is a scalac bug. Tree diagnostics: Y[_].
              0 match { case Y[_] => }
                              ^
      

      "This is a scalac bug": when I say it, most often false; when scalac says it, guaranteed true!

      the result in Scala version 2.11.0-20130322-102202-0acf87844e is the same.

      2.9 says "class Y of type Y does not take type parameters", which is a correct-ish error to give though it doesn't help the naive user clear up the class vs. companion object confusion that probably made them write this. (what naive user? who, me? <looks around wildly>)

        Activity

        Hide
        Adriaan Moors added a comment - - edited

        Yes, a real error message would probably be more appropriate than scalac going all mea culpa.

        Show
        Adriaan Moors added a comment - - edited Yes, a real error message would probably be more appropriate than scalac going all mea culpa.
        Show
        Adriaan Moors added a comment - https://github.com/scala/scala/pull/2358

          People

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

            Dates

            • Created:
              Updated:
              Resolved:

              Development