Jakub Begera
11/07/2019, 11:47 AMFirst
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, i. e.:
// Java class
class Firs {
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! 🙂Marek Osvald
11/08/2019, 1:19 PM