[JS IR] Fix js("...") call checker in frontend.
Call mather relies on that BuiltIn package fragment implement specific interface `BuiltInsPackageFragment` which was missed. Make sure that BuiltIn module's package fragments implement that interface. Fix progression optimizer symbols resolve in JS & WASM IR BE
This commit is contained in:
committed by
TeamCityServer
parent
18950feeff
commit
f05c8ad953
@@ -98,10 +98,10 @@ open class BuiltinSymbolsBase(val irBuiltIns: IrBuiltIns, private val symbolTabl
|
|||||||
open val getProgressionLastElementByReturnType: Map<IrClassifierSymbol, IrSimpleFunctionSymbol> =
|
open val getProgressionLastElementByReturnType: Map<IrClassifierSymbol, IrSimpleFunctionSymbol> =
|
||||||
irBuiltIns.getNonBuiltinFunctionsByReturnType(Name.identifier("getProgressionLastElement"), "kotlin", "internal")
|
irBuiltIns.getNonBuiltinFunctionsByReturnType(Name.identifier("getProgressionLastElement"), "kotlin", "internal")
|
||||||
|
|
||||||
val toUIntByExtensionReceiver: Map<IrClassifierSymbol, IrSimpleFunctionSymbol> =
|
open val toUIntByExtensionReceiver: Map<IrClassifierSymbol, IrSimpleFunctionSymbol> =
|
||||||
irBuiltIns.getNonBuiltInFunctionsByExtensionReceiver(Name.identifier("toUInt"), "kotlin")
|
irBuiltIns.getNonBuiltInFunctionsByExtensionReceiver(Name.identifier("toUInt"), "kotlin")
|
||||||
|
|
||||||
val toULongByExtensionReceiver: Map<IrClassifierSymbol, IrSimpleFunctionSymbol> =
|
open val toULongByExtensionReceiver: Map<IrClassifierSymbol, IrSimpleFunctionSymbol> =
|
||||||
irBuiltIns.getNonBuiltInFunctionsByExtensionReceiver(Name.identifier("toULong"), "kotlin")
|
irBuiltIns.getNonBuiltInFunctionsByExtensionReceiver(Name.identifier("toULong"), "kotlin")
|
||||||
|
|
||||||
val any get() = irBuiltIns.anyClass
|
val any get() = irBuiltIns.anyClass
|
||||||
|
|||||||
+27
-4
@@ -33,10 +33,7 @@ import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol
|
|||||||
import org.jetbrains.kotlin.ir.symbols.impl.DescriptorlessExternalPackageFragmentSymbol
|
import org.jetbrains.kotlin.ir.symbols.impl.DescriptorlessExternalPackageFragmentSymbol
|
||||||
import org.jetbrains.kotlin.ir.types.*
|
import org.jetbrains.kotlin.ir.types.*
|
||||||
import org.jetbrains.kotlin.ir.types.impl.IrDynamicTypeImpl
|
import org.jetbrains.kotlin.ir.types.impl.IrDynamicTypeImpl
|
||||||
import org.jetbrains.kotlin.ir.util.SymbolTable
|
import org.jetbrains.kotlin.ir.util.*
|
||||||
import org.jetbrains.kotlin.ir.util.getPropertyGetter
|
|
||||||
import org.jetbrains.kotlin.ir.util.getPropertySetter
|
|
||||||
import org.jetbrains.kotlin.ir.util.kotlinPackageFqn
|
|
||||||
import org.jetbrains.kotlin.js.config.ErrorTolerancePolicy
|
import org.jetbrains.kotlin.js.config.ErrorTolerancePolicy
|
||||||
import org.jetbrains.kotlin.js.config.JSConfigurationKeys
|
import org.jetbrains.kotlin.js.config.JSConfigurationKeys
|
||||||
import org.jetbrains.kotlin.js.config.RuntimeDiagnostic
|
import org.jetbrains.kotlin.js.config.RuntimeDiagnostic
|
||||||
@@ -261,6 +258,32 @@ class JsIrBackendContext(
|
|||||||
override fun suspendFunctionN(n: Int): IrClassSymbol {
|
override fun suspendFunctionN(n: Int): IrClassSymbol {
|
||||||
return irFactory.stageController.withInitialIr { super.suspendFunctionN(n) }
|
return irFactory.stageController.withInitialIr { super.suspendFunctionN(n) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private val getProgressionLastElementSymbols =
|
||||||
|
irBuiltIns.findFunctions(Name.identifier("getProgressionLastElement"), "kotlin", "internal")
|
||||||
|
|
||||||
|
override val getProgressionLastElementByReturnType: Map<IrClassifierSymbol, IrSimpleFunctionSymbol> by lazy {
|
||||||
|
getProgressionLastElementSymbols.associateBy { it.owner.returnType.classifierOrFail }
|
||||||
|
}
|
||||||
|
|
||||||
|
private val toUIntSymbols = irBuiltIns.findFunctions(Name.identifier("toUInt"), "kotlin")
|
||||||
|
|
||||||
|
override val toUIntByExtensionReceiver: Map<IrClassifierSymbol, IrSimpleFunctionSymbol> by lazy {
|
||||||
|
toUIntSymbols.associateBy {
|
||||||
|
it.owner.extensionReceiverParameter?.type?.classifierOrFail
|
||||||
|
?: error("Expected extension receiver for ${it.owner.render()}")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private val toULongSymbols = irBuiltIns.findFunctions(Name.identifier("toULong"), "kotlin")
|
||||||
|
|
||||||
|
override val toULongByExtensionReceiver: Map<IrClassifierSymbol, IrSimpleFunctionSymbol> by lazy {
|
||||||
|
toULongSymbols.associateBy {
|
||||||
|
it.owner.extensionReceiverParameter?.type?.classifierOrFail
|
||||||
|
?: error("Expected extension receiver for ${it.owner.render()}")
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun unfoldInlineClassType(irType: IrType): IrType? {
|
override fun unfoldInlineClassType(irType: IrType): IrType? {
|
||||||
|
|||||||
@@ -17,10 +17,12 @@ import org.jetbrains.kotlin.ir.declarations.IrSimpleFunction
|
|||||||
import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
|
import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrClassifierSymbol
|
import org.jetbrains.kotlin.ir.symbols.IrClassifierSymbol
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol
|
import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol
|
||||||
import org.jetbrains.kotlin.ir.types.defaultType
|
|
||||||
import org.jetbrains.kotlin.ir.types.IrType
|
import org.jetbrains.kotlin.ir.types.IrType
|
||||||
|
import org.jetbrains.kotlin.ir.types.classifierOrFail
|
||||||
|
import org.jetbrains.kotlin.ir.types.defaultType
|
||||||
import org.jetbrains.kotlin.ir.types.typeWith
|
import org.jetbrains.kotlin.ir.types.typeWith
|
||||||
import org.jetbrains.kotlin.ir.util.SymbolTable
|
import org.jetbrains.kotlin.ir.util.SymbolTable
|
||||||
|
import org.jetbrains.kotlin.ir.util.render
|
||||||
import org.jetbrains.kotlin.name.FqName
|
import org.jetbrains.kotlin.name.FqName
|
||||||
import org.jetbrains.kotlin.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
import org.jetbrains.kotlin.resolve.scopes.MemberScope
|
import org.jetbrains.kotlin.resolve.scopes.MemberScope
|
||||||
@@ -178,6 +180,31 @@ class WasmSymbols(
|
|||||||
val arraysCopyInto = findFunctions(collectionsPackage.memberScope, Name.identifier("copyInto"))
|
val arraysCopyInto = findFunctions(collectionsPackage.memberScope, Name.identifier("copyInto"))
|
||||||
.map { symbolTable.referenceSimpleFunction(it) }
|
.map { symbolTable.referenceSimpleFunction(it) }
|
||||||
|
|
||||||
|
private val getProgressionLastElementSymbols =
|
||||||
|
irBuiltIns.findFunctions(Name.identifier("getProgressionLastElement"), "kotlin", "internal")
|
||||||
|
|
||||||
|
override val getProgressionLastElementByReturnType: Map<IrClassifierSymbol, IrSimpleFunctionSymbol> by lazy {
|
||||||
|
getProgressionLastElementSymbols.associateBy { it.owner.returnType.classifierOrFail }
|
||||||
|
}
|
||||||
|
|
||||||
|
private val toUIntSymbols = irBuiltIns.findFunctions(Name.identifier("toUInt"), "kotlin")
|
||||||
|
|
||||||
|
override val toUIntByExtensionReceiver: Map<IrClassifierSymbol, IrSimpleFunctionSymbol> by lazy {
|
||||||
|
toUIntSymbols.associateBy {
|
||||||
|
it.owner.extensionReceiverParameter?.type?.classifierOrFail
|
||||||
|
?: error("Expected extension receiver for ${it.owner.render()}")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private val toULongSymbols = irBuiltIns.findFunctions(Name.identifier("toULong"), "kotlin")
|
||||||
|
|
||||||
|
override val toULongByExtensionReceiver: Map<IrClassifierSymbol, IrSimpleFunctionSymbol> by lazy {
|
||||||
|
toULongSymbols.associateBy {
|
||||||
|
it.owner.extensionReceiverParameter?.type?.classifierOrFail
|
||||||
|
?: error("Expected extension receiver for ${it.owner.render()}")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun functionN(n: Int): IrClassSymbol =
|
override fun functionN(n: Int): IrClassSymbol =
|
||||||
functionNInterfaces[n]
|
functionNInterfaces[n]
|
||||||
|
|
||||||
|
|||||||
+16
-1
@@ -6,6 +6,7 @@
|
|||||||
package org.jetbrains.kotlin.library.metadata
|
package org.jetbrains.kotlin.library.metadata
|
||||||
|
|
||||||
import org.jetbrains.kotlin.backend.common.serialization.metadata.KlibMetadataVersion
|
import org.jetbrains.kotlin.backend.common.serialization.metadata.KlibMetadataVersion
|
||||||
|
import org.jetbrains.kotlin.builtins.BuiltInsPackageFragment
|
||||||
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
|
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
|
||||||
import org.jetbrains.kotlin.library.KotlinLibrary
|
import org.jetbrains.kotlin.library.KotlinLibrary
|
||||||
import org.jetbrains.kotlin.metadata.ProtoBuf
|
import org.jetbrains.kotlin.metadata.ProtoBuf
|
||||||
@@ -20,7 +21,7 @@ import org.jetbrains.kotlin.serialization.deserialization.getName
|
|||||||
import org.jetbrains.kotlin.storage.StorageManager
|
import org.jetbrains.kotlin.storage.StorageManager
|
||||||
import java.lang.ref.SoftReference
|
import java.lang.ref.SoftReference
|
||||||
|
|
||||||
class KlibMetadataDeserializedPackageFragment(
|
open class KlibMetadataDeserializedPackageFragment(
|
||||||
fqName: FqName,
|
fqName: FqName,
|
||||||
private val library: KotlinLibrary,
|
private val library: KotlinLibrary,
|
||||||
private val packageAccessHandler: PackageAccessHandler?,
|
private val packageAccessHandler: PackageAccessHandler?,
|
||||||
@@ -51,6 +52,20 @@ class KlibMetadataDeserializedPackageFragment(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class BuiltInKlibMetadataDeserializedPackageFragment(
|
||||||
|
fqName: FqName,
|
||||||
|
library: KotlinLibrary,
|
||||||
|
packageAccessHandler: PackageAccessHandler?,
|
||||||
|
storageManager: StorageManager,
|
||||||
|
module: ModuleDescriptor,
|
||||||
|
partName: String
|
||||||
|
) : KlibMetadataDeserializedPackageFragment(fqName, library, packageAccessHandler, storageManager, module, partName),
|
||||||
|
BuiltInsPackageFragment {
|
||||||
|
|
||||||
|
override val isFallback: Boolean
|
||||||
|
get() = false
|
||||||
|
}
|
||||||
|
|
||||||
class KlibMetadataCachedPackageFragment(
|
class KlibMetadataCachedPackageFragment(
|
||||||
byteArray: ByteArray,
|
byteArray: ByteArray,
|
||||||
storageManager: StorageManager,
|
storageManager: StorageManager,
|
||||||
|
|||||||
+15
-6
@@ -6,11 +6,10 @@ import org.jetbrains.kotlin.descriptors.ModuleDescriptor
|
|||||||
import org.jetbrains.kotlin.descriptors.PackageFragmentDescriptor
|
import org.jetbrains.kotlin.descriptors.PackageFragmentDescriptor
|
||||||
import org.jetbrains.kotlin.descriptors.impl.PackageFragmentDescriptorImpl
|
import org.jetbrains.kotlin.descriptors.impl.PackageFragmentDescriptorImpl
|
||||||
import org.jetbrains.kotlin.incremental.components.LookupLocation
|
import org.jetbrains.kotlin.incremental.components.LookupLocation
|
||||||
import org.jetbrains.kotlin.library.*
|
import org.jetbrains.kotlin.library.KotlinLibrary
|
||||||
import org.jetbrains.kotlin.library.metadata.KlibMetadataCachedPackageFragment
|
import org.jetbrains.kotlin.library.exportForwardDeclarations
|
||||||
import org.jetbrains.kotlin.library.metadata.KlibMetadataDeserializedPackageFragment
|
import org.jetbrains.kotlin.library.isInterop
|
||||||
import org.jetbrains.kotlin.library.metadata.KlibMetadataPackageFragment
|
import org.jetbrains.kotlin.library.metadata.*
|
||||||
import org.jetbrains.kotlin.library.metadata.PackageAccessHandler
|
|
||||||
import org.jetbrains.kotlin.library.packageFqName
|
import org.jetbrains.kotlin.library.packageFqName
|
||||||
import org.jetbrains.kotlin.name.FqName
|
import org.jetbrains.kotlin.name.FqName
|
||||||
import org.jetbrains.kotlin.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
@@ -32,8 +31,18 @@ open class KlibMetadataDeserializedPackageFragmentsFactoryImpl : KlibMetadataDes
|
|||||||
) = packageFragmentNames.flatMap {
|
) = packageFragmentNames.flatMap {
|
||||||
val fqName = FqName(it)
|
val fqName = FqName(it)
|
||||||
val parts = library.packageMetadataParts(fqName.asString())
|
val parts = library.packageMetadataParts(fqName.asString())
|
||||||
|
val isBuiltInModule = moduleDescriptor.builtIns.builtInsModule === moduleDescriptor
|
||||||
parts.map { partName ->
|
parts.map { partName ->
|
||||||
KlibMetadataDeserializedPackageFragment(fqName, library, packageAccessedHandler, storageManager, moduleDescriptor, partName)
|
if (isBuiltInModule)
|
||||||
|
BuiltInKlibMetadataDeserializedPackageFragment(
|
||||||
|
fqName,
|
||||||
|
library,
|
||||||
|
packageAccessedHandler,
|
||||||
|
storageManager,
|
||||||
|
moduleDescriptor,
|
||||||
|
partName
|
||||||
|
) else
|
||||||
|
KlibMetadataDeserializedPackageFragment(fqName, library, packageAccessedHandler, storageManager, moduleDescriptor, partName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user