[FIR][checkers] Respect ClassKind.INTERFACE in FirRegularClass.canHaveAbstractDeclaration
A Kotlin interface can have abstract members regardless of its modality. However, this invariant was previously ignored by FIR checkers. As a result, false-positive `ABSTRACT_<MEMBER>_IN_NON_ABSTRACT_CLASS` errors were being reported in explicitly non-abstract interfaces. This commit makes a relevant FIR utility used by relevant FIR checkers aware of the aforementioned invariant. #KT-66260 Fixed
This commit is contained in:
committed by
Space Team
parent
e0b83def00
commit
2de0e4b8d2
@@ -62,7 +62,7 @@ inline val FirClass.isEnumClass: Boolean
|
|||||||
inline val FirRegularClass.isSealed: Boolean get() = status.modality == Modality.SEALED
|
inline val FirRegularClass.isSealed: Boolean get() = status.modality == Modality.SEALED
|
||||||
|
|
||||||
inline val FirRegularClass.canHaveAbstractDeclaration: Boolean
|
inline val FirRegularClass.canHaveAbstractDeclaration: Boolean
|
||||||
get() = isAbstract || isSealed || isEnumClass
|
get() = isInterface || isAbstract || isSealed || isEnumClass
|
||||||
|
|
||||||
inline val FirRegularClass.isCompanion: Boolean get() = status.isCompanion
|
inline val FirRegularClass.isCompanion: Boolean get() = status.isCompanion
|
||||||
inline val FirRegularClass.isData: Boolean get() = status.isData
|
inline val FirRegularClass.isData: Boolean get() = status.isData
|
||||||
|
|||||||
@@ -1,15 +0,0 @@
|
|||||||
// FIR_DUMP
|
|
||||||
<!REDUNDANT_MODIFIER_FOR_TARGET!>open<!> interface OpenInterface {
|
|
||||||
fun <!ABSTRACT_FUNCTION_IN_NON_ABSTRACT_CLASS!>defaultModalityFuncWithoutBody<!>()
|
|
||||||
fun defaultModalityFuncWithBody() {}
|
|
||||||
<!ABSTRACT_FUNCTION_IN_NON_ABSTRACT_CLASS!>abstract<!> fun abstractFunc()
|
|
||||||
open fun openFunc() {}
|
|
||||||
|
|
||||||
val <!ABSTRACT_PROPERTY_IN_NON_ABSTRACT_CLASS!>defaultModalityValWithoutGetter<!>: Any
|
|
||||||
val defaultModalityValWithGetter: Any get() = 42
|
|
||||||
<!ABSTRACT_PROPERTY_IN_NON_ABSTRACT_CLASS!>abstract<!> val abstractVal: Any
|
|
||||||
open val openVal: Any get() = 42
|
|
||||||
|
|
||||||
<!ABSTRACT_PROPERTY_IN_NON_ABSTRACT_CLASS!>abstract<!> val abstractValWithGetter: Any get() = 42
|
|
||||||
<!ABSTRACT_PROPERTY_IN_NON_ABSTRACT_CLASS!>abstract<!> var abstractValWithSetter: Any set(value) {}
|
|
||||||
}
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
FILE: OpenInterface.fir.kt
|
FILE: OpenInterface.kt
|
||||||
public open interface OpenInterface : R|kotlin/Any| {
|
public open interface OpenInterface : R|kotlin/Any| {
|
||||||
public abstract fun defaultModalityFuncWithoutBody(): R|kotlin/Unit|
|
public abstract fun defaultModalityFuncWithoutBody(): R|kotlin/Unit|
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
// FIR_IDENTICAL
|
||||||
// FIR_DUMP
|
// FIR_DUMP
|
||||||
<!REDUNDANT_MODIFIER_FOR_TARGET!>open<!> interface OpenInterface {
|
<!REDUNDANT_MODIFIER_FOR_TARGET!>open<!> interface OpenInterface {
|
||||||
fun defaultModalityFuncWithoutBody()
|
fun defaultModalityFuncWithoutBody()
|
||||||
|
|||||||
Reference in New Issue
Block a user