[K2] Fix EXPECTED_DECLARATION_WITH_BODY not reporting on property accessors
We don't want any `expect` function to have body. So we're sure no new false-positive reports are introduced because of removal of `isTopLevelOrInsideClass` condition. ^KT-59899 Fixed
This commit is contained in:
committed by
Space Team
parent
4404e5f036
commit
1fdc607898
+3
-3
@@ -46,7 +46,7 @@ object FirExpectConsistencyChecker : FirBasicDeclarationChecker() {
|
||||
reporter.reportOn(source, FirErrors.EXPECTED_PRIVATE_DECLARATION, context)
|
||||
}
|
||||
|
||||
if (isProhibitedDeclarationWithBody(declaration, isTopLevelOrInsideClass)) {
|
||||
if (isProhibitedDeclarationWithBody(declaration)) {
|
||||
reporter.reportOn(source, FirErrors.EXPECTED_DECLARATION_WITH_BODY, context)
|
||||
}
|
||||
}
|
||||
@@ -68,7 +68,7 @@ object FirExpectConsistencyChecker : FirBasicDeclarationChecker() {
|
||||
return isTopLevelOrInsideClass && declaration !is FirConstructor && Visibilities.isPrivate(declaration.visibility)
|
||||
}
|
||||
|
||||
private fun isProhibitedDeclarationWithBody(declaration: FirMemberDeclaration, isTopLevelOrInsideClass: Boolean): Boolean {
|
||||
return isTopLevelOrInsideClass && declaration is FirFunction && declaration.hasBody
|
||||
private fun isProhibitedDeclarationWithBody(declaration: FirMemberDeclaration): Boolean {
|
||||
return declaration is FirFunction && declaration.hasBody
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ expect interface My {
|
||||
|
||||
open val a: Int
|
||||
open val b: String
|
||||
open val c: String get() = ""
|
||||
open val c: String <!EXPECTED_DECLARATION_WITH_BODY!>get()<!> = ""
|
||||
<!REDUNDANT_MODIFIER!>open<!> abstract val e: Int
|
||||
|
||||
val f: Int
|
||||
|
||||
Vendored
+2
-2
@@ -18,8 +18,8 @@
|
||||
val prop: String = <!EXPECTED_PROPERTY_INITIALIZER!>"no"<!>
|
||||
|
||||
var getSet: String
|
||||
get() = "no"
|
||||
set(value) {}
|
||||
<!EXPECTED_DECLARATION_WITH_BODY!>get()<!> = "no"
|
||||
<!EXPECTED_DECLARATION_WITH_BODY!>set(value)<!> {}
|
||||
|
||||
<!EXPECTED_DECLARATION_WITH_BODY!>fun functionWithBody(x: Int): Int<!> {
|
||||
return x + 1
|
||||
|
||||
+3
-3
@@ -17,10 +17,10 @@
|
||||
var backingFieldVar: String = <!EXPECTED_PROPERTY_INITIALIZER!>"no"<!>
|
||||
|
||||
val customAccessorVal: String
|
||||
get() = "no"
|
||||
<!EXPECTED_DECLARATION_WITH_BODY!>get()<!> = "no"
|
||||
var customAccessorVar: String
|
||||
get() = "no"
|
||||
set(value) {}
|
||||
<!EXPECTED_DECLARATION_WITH_BODY!>get()<!> = "no"
|
||||
<!EXPECTED_DECLARATION_WITH_BODY!>set(value)<!> {}
|
||||
|
||||
<!EXPECTED_LATEINIT_PROPERTY!>lateinit<!> var lateinitVar: String
|
||||
|
||||
|
||||
Reference in New Issue
Block a user