Forbid usages of super if in fact it accesses an abstract member

#KT-49017 Fixed
This commit is contained in:
Mikhail Glukhikh
2022-01-10 14:19:19 +03:00
parent d15270b9e5
commit b689bbf5c7
23 changed files with 279 additions and 4 deletions
@@ -0,0 +1,26 @@
// FIR_IDENTICAL
// !LANGUAGE: +ForbidSuperDelegationToAbstractFakeOverride
interface Foo {
fun check(): String = "OK"
}
abstract class Base {
abstract fun check(): String
}
abstract class Derived : Base(), Foo
class Derived2 : Derived() {
override fun check(): String {
super<Derived>.<!ABSTRACT_SUPER_CALL!>check<!>()
return super.<!ABSTRACT_SUPER_CALL!>check<!>()
}
}
abstract class A {
abstract override fun hashCode(): Int
}
interface I
class B : A(), I { // I is necessary here
override fun hashCode() = super.hashCode()
}