[minor][FIR][checkers][Wasm] Refactor FirWasmJsInteropTypesChecker for readability
This commit is contained in:
committed by
Space Team
parent
4dd0a25eca
commit
a7332a4cad
+14
-11
@@ -26,22 +26,25 @@ object FirWasmJsInteropTypesChecker : FirBasicDeclarationChecker(MppCheckerKind.
|
|||||||
override fun check(declaration: FirDeclaration, context: CheckerContext, reporter: DiagnosticReporter) {
|
override fun check(declaration: FirDeclaration, context: CheckerContext, reporter: DiagnosticReporter) {
|
||||||
val session = context.session
|
val session = context.session
|
||||||
|
|
||||||
fun isExternalJsInteropDeclaration() =
|
fun isExternalJsInteropDeclaration(): Boolean {
|
||||||
declaration.symbol.isEffectivelyExternal(session) &&
|
val isEffectivelyExternal = declaration.symbol.isEffectivelyExternal(session)
|
||||||
!declaration.annotations.hasAnnotation(WasmStandardClassIds.Annotations.WasmImport, session)
|
val hasWasmImportAnnotation = declaration.annotations.hasAnnotation(WasmStandardClassIds.Annotations.WasmImport, session)
|
||||||
|
return isEffectivelyExternal && !hasWasmImportAnnotation
|
||||||
|
}
|
||||||
|
|
||||||
fun isJsCodeDeclaration() =
|
fun isJsCodeDeclaration(): Boolean {
|
||||||
(declaration is FirSimpleFunction && declaration.hasValidJsCodeBody()) ||
|
return when (declaration) {
|
||||||
(declaration is FirProperty && declaration.hasValidJsCodeBody())
|
is FirSimpleFunction -> declaration.hasValidJsCodeBody()
|
||||||
|
is FirProperty -> declaration.hasValidJsCodeBody()
|
||||||
|
else -> false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun isJsExportDeclaration() =
|
// Interop type restriction rules apply uniformly to external, js("code"), and @JsExport declarations.
|
||||||
declaration is FirSimpleFunction && isJsExportedDeclaration(declaration, session)
|
|
||||||
|
|
||||||
// Interop type restriction rules apply uniformly to external, js("code"), and @JsExport declarations
|
|
||||||
if (
|
if (
|
||||||
!isExternalJsInteropDeclaration() &&
|
!isExternalJsInteropDeclaration() &&
|
||||||
!isJsCodeDeclaration() &&
|
!isJsCodeDeclaration() &&
|
||||||
!isJsExportDeclaration()
|
!isJsExportedDeclaration(declaration, session)
|
||||||
) {
|
) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user