Can't detect binary incompatibility when trait extends abstract class
See original GitHub issue- scala version 2.12.6
- mima version 0.3.0
- complete example repository https://github.com/xuwei-k/mima-trait-extends-class
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)
Issue Analytics
- State:
- Created 5 years ago
- Comments:19 (17 by maintainers)
Top Results From Across the Web
Are traits and interfaces binary compatible? - Stack Overflow
When the Scala 2.11 compiler compiles a trait, it doesn't generate an interface with default methods, because the generated code has to work ......
Read more >Class Abstraction - Manual - PHP
Classes defined as abstract cannot be instantiated, and any class that contains at least one abstract method must also be abstract.
Read more >Weeks Flashcards | Chegg.com
Binary Incompatibility. Not binary comparable across major releases - must rebuild libraries. var. mutable variable. val. immutable value that cannot be ...
Read more >Using Scala Traits Like Abstract Classes
When a class extends a trait, each abstract method must be implemented, so here's a class that extends Pet and defines comeToMaster :...
Read more >Re: [rdf4j-dev] Source and binary compatiblity checks (was: Re ...
Essentially it's for the query optimizers where they all extend an abstract class in order to inherit a basic implementation. I can't see...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
That’s why a
@PureInterface
annotation would be useful: the compiler could check that your trait doesn’t have any of this baggage.Thanks, it’s slightly different, but fundamentally the same problem.
Note to self’s brain-MiMa:
In addition to the other binary compatibility hazardous problems, like super calls, fields, and etc…
Maybe I’ll just avoid traits altogether…