[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:
committed by
Space Team
parent
a10042f909
commit
881997585a
@@ -168,6 +168,7 @@ val firCompilerCoreModules = arrayOf(
|
|||||||
":compiler:fir:checkers:checkers.js",
|
":compiler:fir:checkers:checkers.js",
|
||||||
":compiler:fir:checkers:checkers.native",
|
":compiler:fir:checkers:checkers.native",
|
||||||
":compiler:fir:checkers:checkers.wasm",
|
":compiler:fir:checkers:checkers.wasm",
|
||||||
|
":compiler:fir:checkers:checkers.web.common",
|
||||||
":compiler:fir:entrypoint", // TODO should not be in core modules but FIR IDE uses DependencyListForCliModule from this module
|
":compiler:fir:entrypoint", // TODO should not be in core modules but FIR IDE uses DependencyListForCliModule from this module
|
||||||
":compiler:fir:fir2ir:jvm-backend", // TODO should not be in core modules but FIR IDE uses Fir2IrSignatureComposer from this module
|
":compiler:fir:fir2ir:jvm-backend", // TODO should not be in core modules but FIR IDE uses Fir2IrSignatureComposer from this module
|
||||||
":compiler:fir:fir2ir" // TODO should not be in core modules but FIR IDE uses Fir2IrSignatureComposer from this module
|
":compiler:fir:fir2ir" // TODO should not be in core modules but FIR IDE uses Fir2IrSignatureComposer from this module
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ dependencies {
|
|||||||
api(project(":core:compiler.common.js"))
|
api(project(":core:compiler.common.js"))
|
||||||
api(project(":js:js.ast"))
|
api(project(":js:js.ast"))
|
||||||
api(project(":compiler:fir:checkers"))
|
api(project(":compiler:fir:checkers"))
|
||||||
|
api(project(":compiler:fir:checkers:checkers.web.common"))
|
||||||
|
|
||||||
// FE checks for modules use ModuleKind
|
// FE checks for modules use ModuleKind
|
||||||
// This dependency can be removed when we stop supporting PLAIN and UMD module systems
|
// This dependency can be removed when we stop supporting PLAIN and UMD module systems
|
||||||
|
|||||||
-24
@@ -31,30 +31,6 @@ import org.jetbrains.kotlin.js.common.isES5IdentifierPart
|
|||||||
import org.jetbrains.kotlin.js.common.isES5IdentifierStart
|
import org.jetbrains.kotlin.js.common.isES5IdentifierStart
|
||||||
import org.jetbrains.kotlin.name.JsStandardClassIds
|
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 {
|
fun FirBasedSymbol<*>.isEffectivelyExternalMember(session: FirSession): Boolean {
|
||||||
return fir is FirMemberDeclaration && isEffectivelyExternal(session)
|
return fir is FirMemberDeclaration && isEffectivelyExternal(session)
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -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.context.CheckerContext
|
||||||
import org.jetbrains.kotlin.fir.analysis.checkers.expression.FirCallChecker
|
import org.jetbrains.kotlin.fir.analysis.checkers.expression.FirCallChecker
|
||||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.js.FirJsErrors
|
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.hasAnnotation
|
||||||
|
import org.jetbrains.kotlin.fir.declarations.utils.isEffectivelyExternal
|
||||||
import org.jetbrains.kotlin.fir.expressions.FirCall
|
import org.jetbrains.kotlin.fir.expressions.FirCall
|
||||||
import org.jetbrains.kotlin.fir.expressions.resolvedArgumentMapping
|
import org.jetbrains.kotlin.fir.expressions.resolvedArgumentMapping
|
||||||
import org.jetbrains.kotlin.fir.expressions.unwrapArgument
|
import org.jetbrains.kotlin.fir.expressions.unwrapArgument
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ plugins {
|
|||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
api(project(":compiler:fir:checkers"))
|
api(project(":compiler:fir:checkers"))
|
||||||
|
api(project(":compiler:fir:checkers:checkers.web.common"))
|
||||||
api(project(":core:compiler.common.wasm"))
|
api(project(":core:compiler.common.wasm"))
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -27,8 +28,9 @@ sourceSets {
|
|||||||
"test" { none() }
|
"test" { none() }
|
||||||
}
|
}
|
||||||
|
|
||||||
val compileKotlin by tasks
|
tasks.named("compileKotlin").configure {
|
||||||
compileKotlin.dependsOn(":compiler:fir:checkers:generateCheckersComponents")
|
dependsOn(":compiler:fir:checkers:generateCheckersComponents")
|
||||||
|
}
|
||||||
|
|
||||||
if (kotlinBuildProperties.isInJpsBuildIdeaSync) {
|
if (kotlinBuildProperties.isInJpsBuildIdeaSync) {
|
||||||
apply(plugin = "idea")
|
apply(plugin = "idea")
|
||||||
|
|||||||
@@ -0,0 +1,26 @@
|
|||||||
|
plugins {
|
||||||
|
kotlin("jvm")
|
||||||
|
id("jps-compatible")
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
api(project(":compiler:fir:checkers"))
|
||||||
|
api(project(":core:compiler.common.wasm"))
|
||||||
|
|
||||||
|
/*
|
||||||
|
* We can't remove this dependency until we use
|
||||||
|
* diagnostics framework from FE 1.0
|
||||||
|
*/
|
||||||
|
implementation(project(":compiler:frontend"))
|
||||||
|
implementation(project(":compiler:psi"))
|
||||||
|
|
||||||
|
compileOnly(intellijCore())
|
||||||
|
}
|
||||||
|
|
||||||
|
sourceSets {
|
||||||
|
"main" {
|
||||||
|
projectDefault()
|
||||||
|
generatedDir()
|
||||||
|
}
|
||||||
|
"test" { none() }
|
||||||
|
}
|
||||||
+42
@@ -0,0 +1,42 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||||
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
@file:OptIn(SymbolInternals::class)
|
||||||
|
|
||||||
|
package org.jetbrains.kotlin.fir.declarations.utils
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.fir.FirSession
|
||||||
|
import org.jetbrains.kotlin.fir.analysis.checkers.getContainingClassSymbol
|
||||||
|
import org.jetbrains.kotlin.fir.declarations.FirMemberDeclaration
|
||||||
|
import org.jetbrains.kotlin.fir.symbols.FirBasedSymbol
|
||||||
|
import org.jetbrains.kotlin.fir.symbols.SymbolInternals
|
||||||
|
import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol
|
||||||
|
import org.jetbrains.kotlin.fir.symbols.impl.FirClassSymbol
|
||||||
|
import org.jetbrains.kotlin.fir.symbols.impl.FirPropertyAccessorSymbol
|
||||||
|
import org.jetbrains.kotlin.fir.symbols.impl.FirPropertySymbol
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
@@ -301,6 +301,7 @@ include ":compiler:fir",
|
|||||||
":compiler:fir:checkers:checkers.js",
|
":compiler:fir:checkers:checkers.js",
|
||||||
":compiler:fir:checkers:checkers.native",
|
":compiler:fir:checkers:checkers.native",
|
||||||
":compiler:fir:checkers:checkers.wasm",
|
":compiler:fir:checkers:checkers.wasm",
|
||||||
|
":compiler:fir:checkers:checkers.web.common",
|
||||||
":compiler:fir:checkers:checkers-component-generator",
|
":compiler:fir:checkers:checkers-component-generator",
|
||||||
":compiler:fir:entrypoint",
|
":compiler:fir:entrypoint",
|
||||||
":compiler:fir:analysis-tests",
|
":compiler:fir:analysis-tests",
|
||||||
|
|||||||
Reference in New Issue
Block a user