JVM IR: fix ::class reference and type mapping for scripts
#KT-46284 Fixed
This commit is contained in:
committed by
TeamCityServer
parent
d10f734594
commit
276ffd5a4b
@@ -101,6 +101,12 @@ class IrTypeMapper(private val context: JvmBackendContext) : KotlinTypeMapperBas
|
||||
override fun getClassInternalName(typeConstructor: TypeConstructorMarker): String =
|
||||
classInternalName((typeConstructor as IrClassSymbol).owner)
|
||||
|
||||
override fun getScriptInternalName(typeConstructor: TypeConstructorMarker): String {
|
||||
val script = (typeConstructor as IrScriptSymbol).owner
|
||||
val targetClass = script.targetClass ?: error("No target class computed for script: ${script.render()}")
|
||||
return classInternalName(targetClass.owner)
|
||||
}
|
||||
|
||||
fun writeFormalTypeParameters(irParameters: List<IrTypeParameter>, sw: JvmSignatureWriter) {
|
||||
if (sw.skipGenericSignature()) return
|
||||
with(KotlinTypeMapper) {
|
||||
|
||||
@@ -66,12 +66,11 @@ fun IrType.eraseTypeParameters() = when (this) {
|
||||
is IrErrorType -> this
|
||||
is IrSimpleType ->
|
||||
when (val owner = classifier.owner) {
|
||||
is IrClass -> IrSimpleTypeImpl(
|
||||
classifier,
|
||||
hasQuestionMark,
|
||||
arguments.map { it.eraseTypeParameters() },
|
||||
annotations
|
||||
)
|
||||
is IrScript -> {
|
||||
assert(arguments.isEmpty()) { "Script can't be generic: " + owner.render() }
|
||||
IrSimpleTypeImpl(classifier, hasQuestionMark, emptyList(), annotations)
|
||||
}
|
||||
is IrClass -> IrSimpleTypeImpl(classifier, hasQuestionMark, arguments.map { it.eraseTypeParameters() }, annotations)
|
||||
is IrTypeParameter -> {
|
||||
val upperBound = owner.erasedUpperBound
|
||||
IrSimpleTypeImpl(
|
||||
|
||||
@@ -338,6 +338,8 @@ fun ReferenceSymbolTable.referenceClassifier(classifier: ClassifierDescriptor):
|
||||
when (classifier) {
|
||||
is TypeParameterDescriptor ->
|
||||
referenceTypeParameter(classifier)
|
||||
is ScriptDescriptor ->
|
||||
referenceScript(classifier)
|
||||
is ClassDescriptor ->
|
||||
referenceClass(classifier)
|
||||
else ->
|
||||
|
||||
Reference in New Issue
Block a user