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

ClassCastException with parameterized universal trait

    Details

      Description

      object N {
         def main(args: Array[String]) {
            val y: AA[Int] = C(2)
            val c: Int = y.x.y
            println(c)
         }
      }
      trait AA[T] extends Any {
         def x: C[T]
      }
      case class C[T](val y: T) extends AnyVal with AA[T] {
         def x = this
      }
      
      java.lang.ClassCastException: C cannot be cast to java.lang.Integer
      	at scala.runtime.BoxesRunTime.unboxToInt(Unknown Source)
      	at N$.main(N.scala:4)
      	at N.main(N.scala)
      

        Issue Links

          Activity

          Show
          Pavel Pavlov added a comment - See also https://groups.google.com/d/msg/scala-sips/KSm99KoiYNA/TTSH-UVb1F8J
          Hide
          Pavel Pavlov added a comment -
          Show
          Pavel Pavlov added a comment - I believe the root cause of this issue is: https://groups.google.com/d/msg/scala-sips/KSm99KoiYNA/wuX6j_XgeZEJ
          Hide
          Paul Phillips added a comment -

          Compile-time error in d435f72e5fb7f (noting for reference.)

          Show
          Paul Phillips added a comment - Compile-time error in d435f72e5fb7f (noting for reference.)
          Hide
          Jason Zaugg added a comment -

          Relates to the side problems reported in the comments of SI-6260.

          I believe this was wrongly resolved with a prohibition. The problem is actually that a spurious bridge is created in cases when the overriding and overridden methods contained parameteric value classes. I have a fix for this in the works.

          Show
          Jason Zaugg added a comment - Relates to the side problems reported in the comments of SI-6260 . I believe this was wrongly resolved with a prohibition. The problem is actually that a spurious bridge is created in cases when the overriding and overridden methods contained parameteric value classes. I have a fix for this in the works.
          Hide
          Jason Zaugg added a comment -

          Reopening, patch pending.

          Show
          Jason Zaugg added a comment - Reopening, patch pending.
          Show
          Jason Zaugg added a comment - https://github.com/scala/scala/pull/3082

            People

            • Assignee:
              Jason Zaugg
              Reporter:
              Mark Harrah
            • Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development