Remove CommonBackendContext.getClass
This function is unused in backend.common (and actually throws exception in Native), therefore it makes sense to move it down to subtypes
This commit is contained in:
-2
@@ -20,8 +20,6 @@ interface LoggingContext {
|
||||
interface CommonBackendContext : BackendContext, LoggingContext {
|
||||
override val ir: Ir<CommonBackendContext>
|
||||
|
||||
fun getClass(fqName: FqName): ClassDescriptor
|
||||
|
||||
fun report(element: IrElement?, irFile: IrFile?, message: String, isError: Boolean)
|
||||
|
||||
val configuration: CompilerConfiguration
|
||||
|
||||
@@ -29,6 +29,7 @@ import org.jetbrains.kotlin.ir.backend.js.utils.OperatorNames
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrFileImpl
|
||||
import org.jetbrains.kotlin.ir.descriptors.IrBuiltIns
|
||||
import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
|
||||
import org.jetbrains.kotlin.ir.symbols.IrEnumEntrySymbol
|
||||
import org.jetbrains.kotlin.ir.symbols.IrFunctionSymbol
|
||||
import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol
|
||||
@@ -182,16 +183,12 @@ class JsIrBackendContext(
|
||||
|
||||
// classes forced to be loaded
|
||||
|
||||
val primitiveClassesObject = symbolTable.referenceClass(
|
||||
getClass(FqName.fromSegments(listOf("kotlin", "reflect", "js", "internal", "PrimitiveClasses")))
|
||||
)
|
||||
val primitiveClassesObject = getIrClass(FqName("kotlin.reflect.js.internal.PrimitiveClasses"))
|
||||
|
||||
val throwableClass = symbolTable.referenceClass(getClass(JsIrBackendContext.KOTLIN_PACKAGE_FQN.child(Name.identifier("Throwable"))))
|
||||
val throwableClass = getIrClass(JsIrBackendContext.KOTLIN_PACKAGE_FQN.child(Name.identifier("Throwable")))
|
||||
|
||||
val primitiveCompanionObjects = primitivesWithImplicitCompanionObject().associate {
|
||||
it to symbolTable.referenceClass(
|
||||
getClass(JS_INTERNAL_PACKAGE_FQNAME.child(Name.identifier("${it.identifier}CompanionObject")))
|
||||
)
|
||||
val primitiveCompanionObjects = primitivesWithImplicitCompanionObject().associateWith {
|
||||
getIrClass(JS_INTERNAL_PACKAGE_FQNAME.child(Name.identifier("${it.identifier}CompanionObject")))
|
||||
}
|
||||
|
||||
val coroutineImpl = ir.symbols.coroutineImpl
|
||||
@@ -275,9 +272,11 @@ class JsIrBackendContext(
|
||||
internal fun getJsInternalClass(name: String): ClassDescriptor =
|
||||
findClass(internalPackage.memberScope, Name.identifier(name))
|
||||
|
||||
override fun getClass(fqName: FqName): ClassDescriptor =
|
||||
internal fun getClass(fqName: FqName): ClassDescriptor =
|
||||
findClass(module.getPackage(fqName.parent()).memberScope, fqName.shortName())
|
||||
|
||||
private fun getIrClass(fqName: FqName): IrClassSymbol = symbolTable.referenceClass(getClass(fqName))
|
||||
|
||||
internal fun getJsInternalFunction(name: String): SimpleFunctionDescriptor =
|
||||
findFunctions(internalPackage.memberScope, Name.identifier(name)).single()
|
||||
|
||||
|
||||
@@ -25,7 +25,6 @@ import org.jetbrains.kotlin.ir.util.SymbolTable
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.psi2ir.PsiSourceManager
|
||||
import org.jetbrains.kotlin.resolve.scopes.MemberScope
|
||||
|
||||
class JvmBackendContext(
|
||||
val state: GenerationState,
|
||||
@@ -50,20 +49,14 @@ class JvmBackendContext(
|
||||
}
|
||||
}
|
||||
|
||||
private fun find(memberScope: MemberScope, className: String): ClassDescriptor {
|
||||
return find(memberScope, Name.identifier(className))
|
||||
}
|
||||
|
||||
private fun find(memberScope: MemberScope, name: Name): ClassDescriptor {
|
||||
return memberScope.getContributedClassifier(name, NoLookupLocation.FROM_BACKEND) as ClassDescriptor
|
||||
}
|
||||
|
||||
private fun getJvmInternalClass(name: String): ClassDescriptor {
|
||||
return find(state.module.getPackage(FqName("kotlin.jvm.internal")).memberScope, name)
|
||||
return getClass(FqName("kotlin.jvm.internal").child(Name.identifier(name)))
|
||||
}
|
||||
|
||||
override fun getClass(fqName: FqName): ClassDescriptor {
|
||||
return find(state.module.getPackage(fqName.parent()).memberScope, fqName.shortName())
|
||||
private fun getClass(fqName: FqName): ClassDescriptor {
|
||||
return state.module.getPackage(fqName.parent()).memberScope.getContributedClassifier(
|
||||
fqName.shortName(), NoLookupLocation.FROM_BACKEND
|
||||
) as ClassDescriptor? ?: error("Class is not found: $fqName")
|
||||
}
|
||||
|
||||
fun getIrClass(fqName: FqName): IrClassSymbol {
|
||||
|
||||
Reference in New Issue
Block a user