Skip to content

Can't detect binary incompatibility when trait extends abstract class #225

@xuwei-k

Description

@xuwei-k

library x v1

package com.example

trait A

library x v2

package com.example

abstract class B {
  def foo: Int = 42
}

trait A extends B

mima said library x v1 => v2 binary compatible.

another library y

  • depends on library x v1
package com.example

object C {
  val a = new com.example.A {}
}

main

  • depends on library y
  • also depends on library x v2 (override x v1 transitive dependency from y)
package com.example

object Main {
  def main(args: Array[String]): Unit = println(C.a.foo)
}

run main

[error] (run-main-0) java.lang.ClassCastException: com.example.C$$anon$1 cannot be cast to com.example.B
[error] java.lang.ClassCastException: com.example.C$$anon$1 cannot be cast to com.example.B
[error] 	at com.example.Main$.main(Main.scala:6)
[error] 	at com.example.Main.main(Main.scala)
[error] 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[error] 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions