[FIR] Don't mangle FirFields as properties
The correct way to mangle a field is to just use its name. This is a step towards fixing KT-57754. It will be fixed in the next commit.
This commit is contained in:
committed by
Space Team
parent
d73e44b89b
commit
1ac3355a41
+3
-16
@@ -7,12 +7,10 @@ package org.jetbrains.kotlin.fir.backend.jvm
|
||||
|
||||
import org.jetbrains.kotlin.backend.common.serialization.mangle.MangleMode
|
||||
import org.jetbrains.kotlin.fir.backend.FirMangleComputer
|
||||
import org.jetbrains.kotlin.fir.declarations.*
|
||||
import org.jetbrains.kotlin.fir.java.declarations.FirJavaField
|
||||
import org.jetbrains.kotlin.fir.originalForSubstitutionOverride
|
||||
import org.jetbrains.kotlin.fir.declarations.FirDeclaration
|
||||
import org.jetbrains.kotlin.fir.declarations.FirFunction
|
||||
import org.jetbrains.kotlin.fir.declarations.FirSimpleFunction
|
||||
import org.jetbrains.kotlin.fir.resolve.providers.firProvider
|
||||
import org.jetbrains.kotlin.fir.symbols.ConeTypeParameterLookupTag
|
||||
import org.jetbrains.kotlin.fir.types.coneType
|
||||
|
||||
/**
|
||||
* JVM backend-specific mangle computer that generates a mangled name for a Kotlin declaration represented by [FirDeclaration].
|
||||
@@ -21,7 +19,6 @@ class FirJvmMangleComputer(
|
||||
builder: StringBuilder,
|
||||
mode: MangleMode,
|
||||
) : FirMangleComputer(builder, mode) {
|
||||
override val visitor: Visitor = JvmVisitor()
|
||||
|
||||
override fun FirFunction.platformSpecificSuffix(): String? =
|
||||
if (this is FirSimpleFunction && name.asString() == "main")
|
||||
@@ -32,14 +29,4 @@ class FirJvmMangleComputer(
|
||||
|
||||
override fun copy(newMode: MangleMode): FirJvmMangleComputer =
|
||||
FirJvmMangleComputer(builder, newMode)
|
||||
|
||||
private inner class JvmVisitor : Visitor() {
|
||||
override fun visitField(field: FirField) {
|
||||
if (field is FirJavaField || field.origin == FirDeclarationOrigin.ImportedFromObjectOrStatic) {
|
||||
field.mangleSimpleDeclaration(field.name.asString())
|
||||
} else {
|
||||
visitVariable(field)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ open class FirMangleComputer(
|
||||
/*FunctionDeclaration=*/FirFunction,
|
||||
/*Session=*/FirSession,
|
||||
>(builder, mode) {
|
||||
protected open val visitor = Visitor()
|
||||
private val visitor = Visitor()
|
||||
|
||||
override fun copy(newMode: MangleMode): FirMangleComputer =
|
||||
FirMangleComputer(builder, newMode)
|
||||
@@ -242,7 +242,7 @@ open class FirMangleComputer(
|
||||
}
|
||||
|
||||
override fun visitField(field: FirField) {
|
||||
visitVariable(field)
|
||||
field.mangleSimpleDeclaration(field.name.asString())
|
||||
}
|
||||
|
||||
override fun visitEnumEntry(enumEntry: FirEnumEntry) {
|
||||
|
||||
@@ -1126,7 +1126,20 @@ open class IrBasedFieldDescriptor(owner: IrField) : PropertyDescriptor, IrBasedD
|
||||
override fun <V : Any?> getUserData(key: CallableDescriptor.UserDataKey<V>?): V? = null
|
||||
}
|
||||
|
||||
fun IrField.toIrBasedDescriptor() = IrBasedFieldDescriptor(this)
|
||||
class IrBasedDelegateFieldDescriptor(owner: IrField) : IrBasedFieldDescriptor(owner), IrImplementingDelegateDescriptor {
|
||||
|
||||
override val correspondingSuperType: KotlinType
|
||||
get() = TODO("not implemented")
|
||||
|
||||
override val isDelegated: Boolean
|
||||
get() = true
|
||||
}
|
||||
|
||||
fun IrField.toIrBasedDescriptor() = if (origin == IrDeclarationOrigin.DELEGATE) {
|
||||
IrBasedDelegateFieldDescriptor(this)
|
||||
} else {
|
||||
IrBasedFieldDescriptor(this)
|
||||
}
|
||||
|
||||
class IrBasedErrorDescriptor(owner: IrErrorDeclaration) : IrBasedDeclarationDescriptor<IrErrorDeclaration>(owner) {
|
||||
override fun getName(): Name = error("IrBasedErrorDescriptor.getName: Should not be reached")
|
||||
|
||||
Reference in New Issue
Block a user