Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: Scala 2.11.8, Scala 2.12.0-M5
    • Fix Version/s: Scala 2.13.0-M1
    • Component/s: Type Checker
    • Environment:
      • OS: Windows 10 64 bit
      • JDK: 1.8.0_91
      • ScalaVersion: 2.12.0-M5, 2.11.8, and so on.

      Description

      The following code

      class A {
        def compareTo(o: Any): Int = 0
      }
      class B extends A with Comparable[B] {
        def compareTo(b: B): Int = 0
      }
      object C {
        def main(args: Array[String]): Unit = {
          println(new B().compareTo(new Object()))
        }
      }
      

      compiles without warnings. And it should be executed without any runtime error. However, ClassCastException occurs when the code is executed.

      This problem is also known as an already fixed bug of Java Generics:

      http://www.concurrentaffair.org/2006/10/10/java-generics-unsound/

        Attachments

          Activity

            People

            • Assignee:
              moors Adriaan Moors
              Reporter:
              kmizushima Kota Mizushima
            • Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

              • Created:
                Updated: