687a58843f
Unbound it from implicit receiver stack as it only needs scope structure/declaration nestedness Semantics for protected has been changed in a way it works in old FE NB: We should report additional diagnostic in case of CallCompanionProtectedNonStatic.fir.kt (see KT-38814)
94 lines
1.9 KiB
Kotlin
Vendored
94 lines
1.9 KiB
Kotlin
Vendored
open class VeryBase {
|
|
protected fun baz() {}
|
|
}
|
|
|
|
open class Base {
|
|
protected fun foo() {
|
|
bar() // Ok
|
|
baz() // Ok
|
|
}
|
|
|
|
inner class Inner {
|
|
fun fromInner() {
|
|
foo() // Ok
|
|
bar() // Ok
|
|
gav() // Ok
|
|
baz() // Ok
|
|
}
|
|
}
|
|
|
|
class NestedDerived : Base() {
|
|
fun fromNestedDerived() {
|
|
foo() // Ok
|
|
bar() // Ok
|
|
gav() // Ok
|
|
baz() // Ok
|
|
}
|
|
}
|
|
|
|
companion object : VeryBase() {
|
|
var prop = 42
|
|
protected set
|
|
|
|
protected fun bar() {}
|
|
|
|
@JvmStatic protected fun gav() {}
|
|
|
|
class Nested {
|
|
fun fromNested() {
|
|
bar() // Ok
|
|
gav() // Ok
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
class Derived : Base() {
|
|
fun test() {
|
|
foo() // Ok
|
|
gav() // Ok
|
|
bar()
|
|
baz()
|
|
prop = 0
|
|
}
|
|
|
|
inner class DerivedInner {
|
|
fun fromDerivedInner() {
|
|
foo() // Ok
|
|
gav() // Ok
|
|
bar()
|
|
baz()
|
|
prop = 0
|
|
}
|
|
}
|
|
|
|
companion object {
|
|
fun test2() {
|
|
gav() // Ok
|
|
bar()
|
|
baz()
|
|
prop = 0
|
|
}
|
|
}
|
|
}
|
|
|
|
class Other {
|
|
fun test(base: Base, derived: Derived) {
|
|
base.<!INAPPLICABLE_CANDIDATE!>foo<!>()
|
|
base.<!UNRESOLVED_REFERENCE!>gav<!>()
|
|
base.<!UNRESOLVED_REFERENCE!>bar<!>()
|
|
derived.<!INAPPLICABLE_CANDIDATE!>foo<!>()
|
|
derived.<!UNRESOLVED_REFERENCE!>gav<!>()
|
|
derived.<!UNRESOLVED_REFERENCE!>bar<!>()
|
|
}
|
|
}
|
|
|
|
fun top(base: Base, derived: Derived) {
|
|
base.<!INAPPLICABLE_CANDIDATE!>foo<!>()
|
|
base.<!UNRESOLVED_REFERENCE!>bar<!>()
|
|
base.<!UNRESOLVED_REFERENCE!>gav<!>()
|
|
derived.<!INAPPLICABLE_CANDIDATE!>foo<!>()
|
|
derived.<!UNRESOLVED_REFERENCE!>bar<!>()
|
|
derived.<!UNRESOLVED_REFERENCE!>gav<!>()
|
|
}
|