[FIR] Report NON_MEMBER_FUNCTION_NO_BODY
^KT-59944 Fixed
This commit is contained in:
committed by
Space Team
parent
e103318432
commit
82c18ff26b
+1
-1
@@ -51,6 +51,7 @@ object CommonDeclarationCheckers : DeclarationCheckers() {
|
|||||||
FirFunctionParameterChecker,
|
FirFunctionParameterChecker,
|
||||||
FirFunctionReturnChecker,
|
FirFunctionReturnChecker,
|
||||||
FirInlineDeclarationChecker,
|
FirInlineDeclarationChecker,
|
||||||
|
FirNonMemberFunctionsChecker,
|
||||||
FirSuspendLimitationsChecker,
|
FirSuspendLimitationsChecker,
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -63,7 +64,6 @@ object CommonDeclarationCheckers : DeclarationCheckers() {
|
|||||||
FirMemberFunctionsChecker,
|
FirMemberFunctionsChecker,
|
||||||
FirDataObjectContentChecker,
|
FirDataObjectContentChecker,
|
||||||
ContractSyntaxV2FunctionChecker,
|
ContractSyntaxV2FunctionChecker,
|
||||||
FirTopLevelFunctionsChecker,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
override val propertyCheckers: Set<FirPropertyChecker>
|
override val propertyCheckers: Set<FirPropertyChecker>
|
||||||
|
|||||||
+8
-5
@@ -13,7 +13,9 @@ import org.jetbrains.kotlin.fir.analysis.checkers.FirPlatformDiagnosticSuppresso
|
|||||||
import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext
|
import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext
|
||||||
import org.jetbrains.kotlin.fir.analysis.checkers.hasModifier
|
import org.jetbrains.kotlin.fir.analysis.checkers.hasModifier
|
||||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors
|
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors
|
||||||
import org.jetbrains.kotlin.fir.declarations.FirSimpleFunction
|
import org.jetbrains.kotlin.fir.containingClassLookupTag
|
||||||
|
import org.jetbrains.kotlin.fir.declarations.FirFunction
|
||||||
|
import org.jetbrains.kotlin.fir.declarations.FirPropertyAccessor
|
||||||
import org.jetbrains.kotlin.fir.declarations.utils.hasBody
|
import org.jetbrains.kotlin.fir.declarations.utils.hasBody
|
||||||
import org.jetbrains.kotlin.fir.declarations.utils.isExpect
|
import org.jetbrains.kotlin.fir.declarations.utils.isExpect
|
||||||
import org.jetbrains.kotlin.fir.declarations.utils.isExternal
|
import org.jetbrains.kotlin.fir.declarations.utils.isExternal
|
||||||
@@ -22,10 +24,11 @@ import org.jetbrains.kotlin.lexer.KtTokens
|
|||||||
val FirSession.platformDiagnosticSuppressor: FirPlatformDiagnosticSuppressor? by FirSession.nullableSessionComponentAccessor()
|
val FirSession.platformDiagnosticSuppressor: FirPlatformDiagnosticSuppressor? by FirSession.nullableSessionComponentAccessor()
|
||||||
|
|
||||||
// See old FE's [DeclarationsChecker]
|
// See old FE's [DeclarationsChecker]
|
||||||
object FirTopLevelFunctionsChecker : FirSimpleFunctionChecker() {
|
object FirNonMemberFunctionsChecker : FirFunctionChecker() {
|
||||||
override fun check(declaration: FirSimpleFunction, context: CheckerContext, reporter: DiagnosticReporter) {
|
override fun check(declaration: FirFunction, context: CheckerContext, reporter: DiagnosticReporter) {
|
||||||
// Only report on top level callable declarations
|
if (declaration.containingClassLookupTag() != null || declaration is FirPropertyAccessor) {
|
||||||
if (context.containingDeclarations.size > 1) return
|
return
|
||||||
|
}
|
||||||
|
|
||||||
val source = declaration.source ?: return
|
val source = declaration.source ?: return
|
||||||
if (source.kind is KtFakeSourceElementKind) return
|
if (source.kind is KtFakeSourceElementKind) return
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
//KT-2334 An error 'local function without body' is not reported
|
|
||||||
|
|
||||||
fun foo() {
|
|
||||||
fun bar()
|
|
||||||
}
|
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
// FIR_IDENTICAL
|
||||||
//KT-2334 An error 'local function without body' is not reported
|
//KT-2334 An error 'local function without body' is not reported
|
||||||
|
|
||||||
fun foo() {
|
fun foo() {
|
||||||
|
|||||||
@@ -1,12 +0,0 @@
|
|||||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
|
||||||
|
|
||||||
annotation class ann
|
|
||||||
val bas = fun ()
|
|
||||||
|
|
||||||
fun bar(a: Any) = fun ()
|
|
||||||
|
|
||||||
fun outer() {
|
|
||||||
bar(fun ())
|
|
||||||
bar(l@ fun ())
|
|
||||||
bar(@ann fun ())
|
|
||||||
}
|
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
// FIR_IDENTICAL
|
||||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||||
|
|
||||||
annotation class ann
|
annotation class ann
|
||||||
|
|||||||
Reference in New Issue
Block a user