[FIR] Fix some missing EXPECTED_DECLARATION_WITH_BODY
This commit is contained in:
committed by
Space Team
parent
8f4a580c17
commit
5f1e2764c3
+14
-9
@@ -19,8 +19,19 @@ import org.jetbrains.kotlin.fir.declarations.utils.visibility
|
|||||||
// See old FE's [DeclarationsChecker]
|
// See old FE's [DeclarationsChecker]
|
||||||
object FirExpectConsistencyChecker : FirBasicDeclarationChecker() {
|
object FirExpectConsistencyChecker : FirBasicDeclarationChecker() {
|
||||||
override fun check(declaration: FirDeclaration, context: CheckerContext, reporter: DiagnosticReporter) {
|
override fun check(declaration: FirDeclaration, context: CheckerContext, reporter: DiagnosticReporter) {
|
||||||
|
val source = declaration.source ?: return
|
||||||
|
if (source.kind is KtFakeSourceElementKind) return
|
||||||
|
|
||||||
val isTopLevel = context.containingDeclarations.size == 1
|
val isTopLevel = context.containingDeclarations.size == 1
|
||||||
val isInsideClass = context.containingDeclarations.lastOrNull() is FirClass
|
val lastClass = context.containingDeclarations.lastOrNull() as? FirClass
|
||||||
|
val isInsideClass = lastClass != null
|
||||||
|
|
||||||
|
if (declaration is FirAnonymousInitializer) {
|
||||||
|
if (lastClass?.isExpect == true) {
|
||||||
|
reporter.reportOn(source, FirErrors.EXPECTED_DECLARATION_WITH_BODY, context)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
declaration !is FirMemberDeclaration ||
|
declaration !is FirMemberDeclaration ||
|
||||||
@@ -30,9 +41,6 @@ object FirExpectConsistencyChecker : FirBasicDeclarationChecker() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
val source = declaration.source ?: return
|
|
||||||
if (source.kind is KtFakeSourceElementKind) return
|
|
||||||
|
|
||||||
if (declaration is FirConstructor) {
|
if (declaration is FirConstructor) {
|
||||||
if (!declaration.isPrimary) {
|
if (!declaration.isPrimary) {
|
||||||
val delegatedConstructorSource = declaration.delegatedConstructor?.source
|
val delegatedConstructorSource = declaration.delegatedConstructor?.source
|
||||||
@@ -40,14 +48,11 @@ object FirExpectConsistencyChecker : FirBasicDeclarationChecker() {
|
|||||||
reporter.reportOn(delegatedConstructorSource, FirErrors.EXPECTED_CLASS_CONSTRUCTOR_DELEGATION_CALL, context)
|
reporter.reportOn(delegatedConstructorSource, FirErrors.EXPECTED_CLASS_CONSTRUCTOR_DELEGATION_CALL, context)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return
|
} else if (Visibilities.isPrivate(declaration.visibility)) {
|
||||||
}
|
|
||||||
|
|
||||||
if (Visibilities.isPrivate(declaration.visibility)) {
|
|
||||||
reporter.reportOn(source, FirErrors.EXPECTED_PRIVATE_DECLARATION, context)
|
reporter.reportOn(source, FirErrors.EXPECTED_PRIVATE_DECLARATION, context)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (declaration is FirSimpleFunction && declaration.hasBody) {
|
if (declaration is FirFunction && declaration.hasBody) {
|
||||||
reporter.reportOn(source, FirErrors.EXPECTED_DECLARATION_WITH_BODY, context)
|
reporter.reportOn(source, FirErrors.EXPECTED_DECLARATION_WITH_BODY, context)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
+2
-2
@@ -5,11 +5,11 @@
|
|||||||
val constructorProperty: String,
|
val constructorProperty: String,
|
||||||
constructorParameter: String
|
constructorParameter: String
|
||||||
) {
|
) {
|
||||||
init {
|
<!EXPECTED_DECLARATION_WITH_BODY!>init<!> {
|
||||||
"no"
|
"no"
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(s: String) {
|
<!EXPECTED_DECLARATION_WITH_BODY!>constructor(s: String)<!> {
|
||||||
"no"
|
"no"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user