[Wasm] Add K2 checkers.web.common module (KT-56849)

This module is created to share JS and Wasm checker logic

Extract isEffectivelyExternal util fun from K/JS in order to
 reuse it in Wasm checkers
This commit is contained in:
Svyatoslav Kuzmich
2023-10-04 15:31:16 +02:00
committed by Space Team
parent a10042f909
commit 881997585a
8 changed files with 76 additions and 27 deletions
@@ -9,6 +9,7 @@ dependencies {
api(project(":core:compiler.common.js"))
api(project(":js:js.ast"))
api(project(":compiler:fir:checkers"))
api(project(":compiler:fir:checkers:checkers.web.common"))
// FE checks for modules use ModuleKind
// This dependency can be removed when we stop supporting PLAIN and UMD module systems
@@ -31,30 +31,6 @@ import org.jetbrains.kotlin.js.common.isES5IdentifierPart
import org.jetbrains.kotlin.js.common.isES5IdentifierStart
import org.jetbrains.kotlin.name.JsStandardClassIds
private val FirBasedSymbol<*>.isExternal
get() = when (this) {
is FirCallableSymbol<*> -> isExternal
is FirClassSymbol<*> -> isExternal
else -> false
}
fun FirBasedSymbol<*>.isEffectivelyExternal(session: FirSession): Boolean {
if (fir is FirMemberDeclaration && isExternal) return true
if (this is FirPropertyAccessorSymbol) {
val property = propertySymbol
if (property.isEffectivelyExternal(session)) return true
}
if (this is FirPropertySymbol) {
if (getterSymbol?.isExternal == true && (!isVar || setterSymbol?.isExternal == true)) {
return true
}
}
return getContainingClassSymbol(session)?.isEffectivelyExternal(session) == true
}
fun FirBasedSymbol<*>.isEffectivelyExternalMember(session: FirSession): Boolean {
return fir is FirMemberDeclaration && isEffectivelyExternal(session)
}
@@ -10,8 +10,8 @@ import org.jetbrains.kotlin.diagnostics.reportOn
import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext
import org.jetbrains.kotlin.fir.analysis.checkers.expression.FirCallChecker
import org.jetbrains.kotlin.fir.analysis.diagnostics.js.FirJsErrors
import org.jetbrains.kotlin.fir.analysis.js.checkers.isEffectivelyExternal
import org.jetbrains.kotlin.fir.declarations.hasAnnotation
import org.jetbrains.kotlin.fir.declarations.utils.isEffectivelyExternal
import org.jetbrains.kotlin.fir.expressions.FirCall
import org.jetbrains.kotlin.fir.expressions.resolvedArgumentMapping
import org.jetbrains.kotlin.fir.expressions.unwrapArgument