Reputation: 415
I’m dealing with following issue with Kotlin/Java Compiler.
Imagine following scenario: let First
be a Java class with a final function and Second
be a Kotlin class extending First
with a function of the same name like the final function in First
class, example:
// Java class
class First {
final void foo() { }
}
// Kotlin class
class Second: First() {
fun foo() { }
}
Obviously, it’s wrong because the final function foo()
can not be overridden. However, compilation pass successfully and in run-time I get java.lang.LinkageError: Method void Second.foo() overrides final method in class First
.
Is this correct behavior of compiler? I supposed that there will be some validations for this case. Thank you!
Upvotes: 4
Views: 895