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

no unchecked warnings when unchecked portion is applied type

    Details

      Description

      Presumably it has even less chance of guessing the right type in f2 than it does in f1.

      class D[-A]
      
      object Test {
        def f1(x: D[Int with String]) = x match {
          case _: D[Int]    => 1
          case _: D[String] => 2
        }
        // Correctly warns:
        //
        // a.scala:5: warning: non variable type-argument Int in type pattern D[Int] is unchecked since it is eliminated by erasure
        //     case _: D[Int]    => 1
        //             ^
        // a.scala:6: warning: non variable type-argument String in type pattern D[String] is unchecked since it is eliminated by erasure
        //     case _: D[String] => 2
        //             ^
        // two warnings found
      
        def f2(x: D[D[Int] with D[String]]) = x match {
          case _: D[D[Int]]    => 1
          case _: D[D[String]] => 2
        }
        // No warnings!
      }
      

        Activity

        Hide
        Paul Phillips added a comment -

        I fixed, test in 9904301752 .

        Show
        Paul Phillips added a comment - I fixed, test in 9904301752 .

          People

          • Assignee:
            Paul Phillips
            Reporter:
            Paul Phillips
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development