[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
@@ -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
|
||||
}
|
||||
Reference in New Issue
Block a user