[K2/N] Refactor KonanSymbols before re-enabling special backend checks

^KT-55598
Merge-request: KT-MR-9477
Merged-by: Vladimir Sukharev <Vladimir.Sukharev@jetbrains.com>
This commit is contained in:
Vladimir Sukharev
2023-04-17 10:35:55 +00:00
committed by Space Team
parent 147a3331a4
commit 3cdf4bae07
7 changed files with 279 additions and 215 deletions
@@ -28,10 +28,7 @@ import org.jetbrains.kotlin.ir.expressions.IrConstructorCall
import org.jetbrains.kotlin.ir.expressions.IrExpression
import org.jetbrains.kotlin.ir.expressions.impl.IrConstImpl
import org.jetbrains.kotlin.ir.expressions.impl.IrConstructorCallImpl
import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
import org.jetbrains.kotlin.ir.symbols.IrClassifierSymbol
import org.jetbrains.kotlin.ir.symbols.IrConstructorSymbol
import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol
import org.jetbrains.kotlin.ir.symbols.*
import org.jetbrains.kotlin.ir.symbols.impl.*
import org.jetbrains.kotlin.ir.types.*
import org.jetbrains.kotlin.ir.types.impl.IrSimpleTypeImpl
@@ -623,6 +620,9 @@ class IrBuiltInsOverFir(
override fun findFunctions(name: Name, packageFqName: FqName): Iterable<IrSimpleFunctionSymbol> =
findFunctions(packageFqName, name)
override fun findProperties(name: Name, packageFqName: FqName): Iterable<IrPropertySymbol> =
findProperties(packageFqName, name)
override fun findClass(name: Name, vararg packageNameSegments: String): IrClassSymbol? =
referenceClassByFqname(FqName.fromSegments(packageNameSegments.asList()), name)
@@ -1165,4 +1165,9 @@ class IrBuiltInsOverFir(
components.session.symbolProvider.getTopLevelFunctionSymbols(packageName, name).mapNotNull { firOpSymbol ->
components.declarationStorage.getIrFunctionSymbol(firOpSymbol) as? IrSimpleFunctionSymbol
}
private fun findProperties(packageName: FqName, name: Name): List<IrPropertySymbol> =
components.session.symbolProvider.getTopLevelPropertySymbols(packageName, name).mapNotNull { firOpSymbol ->
components.declarationStorage.getIrPropertySymbol(firOpSymbol) as? IrPropertySymbol
}
}
@@ -30,6 +30,7 @@ import org.jetbrains.kotlin.ir.descriptors.*
import org.jetbrains.kotlin.ir.expressions.impl.IrConstructorCallImpl
import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
import org.jetbrains.kotlin.ir.symbols.IrClassifierSymbol
import org.jetbrains.kotlin.ir.symbols.IrPropertySymbol
import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol
import org.jetbrains.kotlin.ir.symbols.impl.IrValueParameterSymbolImpl
import org.jetbrains.kotlin.ir.types.*
@@ -488,6 +489,11 @@ class IrBuiltInsOverDescriptors(
symbolTable.referenceSimpleFunction(it)
}
override fun findProperties(name: Name, packageFqName: FqName): Iterable<IrPropertySymbol> =
builtIns.builtInsModule.getPackage(packageFqName).memberScope.getContributedVariables(name, NoLookupLocation.FROM_BACKEND).map {
symbolTable.referenceProperty(it)
}
override fun findClass(name: Name, vararg packageNameSegments: String): IrClassSymbol? =
(builtInsPackage(*packageNameSegments).getContributedClassifier(
name,
@@ -14,6 +14,7 @@ import org.jetbrains.kotlin.ir.declarations.IrExternalPackageFragment
import org.jetbrains.kotlin.ir.declarations.IrFactory
import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
import org.jetbrains.kotlin.ir.symbols.IrClassifierSymbol
import org.jetbrains.kotlin.ir.symbols.IrPropertySymbol
import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol
import org.jetbrains.kotlin.ir.types.IrType
import org.jetbrains.kotlin.name.FqName
@@ -159,6 +160,7 @@ abstract class IrBuiltIns {
// TODO: drop variants from segments, add helper from whole fqn
abstract fun findFunctions(name: Name, vararg packageNameSegments: String = arrayOf("kotlin")): Iterable<IrSimpleFunctionSymbol>
abstract fun findFunctions(name: Name, packageFqName: FqName): Iterable<IrSimpleFunctionSymbol>
abstract fun findProperties(name: Name, packageFqName: FqName): Iterable<IrPropertySymbol>
abstract fun findClass(name: Name, vararg packageNameSegments: String = arrayOf("kotlin")): IrClassSymbol?
abstract fun findClass(name: Name, packageFqName: FqName): IrClassSymbol?