IR metadata source: extract & use declaration name
This commit is contained in:
@@ -9,6 +9,7 @@ import org.jetbrains.kotlin.descriptors.PropertyDescriptor
|
|||||||
import org.jetbrains.kotlin.fir.FirSession
|
import org.jetbrains.kotlin.fir.FirSession
|
||||||
import org.jetbrains.kotlin.fir.declarations.*
|
import org.jetbrains.kotlin.fir.declarations.*
|
||||||
import org.jetbrains.kotlin.ir.declarations.MetadataSource
|
import org.jetbrains.kotlin.ir.declarations.MetadataSource
|
||||||
|
import org.jetbrains.kotlin.name.Name
|
||||||
|
|
||||||
interface FirMetadataSource : MetadataSource {
|
interface FirMetadataSource : MetadataSource {
|
||||||
|
|
||||||
@@ -23,6 +24,9 @@ interface FirMetadataSource : MetadataSource {
|
|||||||
) : FirMetadataSource {
|
) : FirMetadataSource {
|
||||||
override val session: FirSession
|
override val session: FirSession
|
||||||
get() = klass.session
|
get() = klass.session
|
||||||
|
|
||||||
|
override val name: Name?
|
||||||
|
get() = (klass as? FirRegularClass)?.name
|
||||||
}
|
}
|
||||||
|
|
||||||
class Function(
|
class Function(
|
||||||
@@ -30,6 +34,13 @@ interface FirMetadataSource : MetadataSource {
|
|||||||
) : FirMetadataSource {
|
) : FirMetadataSource {
|
||||||
override val session: FirSession
|
override val session: FirSession
|
||||||
get() = function.session
|
get() = function.session
|
||||||
|
|
||||||
|
override val name: Name?
|
||||||
|
get() = when (function) {
|
||||||
|
is FirSimpleFunction -> function.name
|
||||||
|
is FirConstructor -> Name.special("<init>")
|
||||||
|
else -> null
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class Property(
|
class Property(
|
||||||
|
|||||||
+1
-1
@@ -469,7 +469,7 @@ internal class FunctionReferenceLowering(private val context: JvmBackendContext)
|
|||||||
}
|
}
|
||||||
|
|
||||||
private val IrFunction.originalName: Name
|
private val IrFunction.originalName: Name
|
||||||
get() = (metadata as? MetadataSource.Function)?.descriptor?.name ?: name
|
get() = metadata?.name ?: name
|
||||||
|
|
||||||
private fun JvmIrBuilder.generateSignature(target: IrFunctionSymbol): IrExpression =
|
private fun JvmIrBuilder.generateSignature(target: IrFunctionSymbol): IrExpression =
|
||||||
irCall(backendContext.ir.symbols.signatureStringIntrinsic).apply {
|
irCall(backendContext.ir.symbols.signatureStringIntrinsic).apply {
|
||||||
|
|||||||
@@ -9,13 +9,24 @@ import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
|||||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
||||||
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
|
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
|
||||||
|
import org.jetbrains.kotlin.name.Name
|
||||||
|
|
||||||
interface MetadataSource {
|
interface MetadataSource {
|
||||||
open class Class(val descriptor: ClassDescriptor) : MetadataSource
|
val name: Name?
|
||||||
|
|
||||||
open class File(val descriptors: List<DeclarationDescriptor>) : MetadataSource
|
abstract class DescriptorBased<D : DeclarationDescriptor> internal constructor(val descriptor: D) : MetadataSource {
|
||||||
|
override val name: Name
|
||||||
|
get() = descriptor.name
|
||||||
|
}
|
||||||
|
|
||||||
open class Function(val descriptor: FunctionDescriptor) : MetadataSource
|
open class Class(descriptor: ClassDescriptor) : DescriptorBased<ClassDescriptor>(descriptor)
|
||||||
|
|
||||||
open class Property(val descriptor: PropertyDescriptor) : MetadataSource
|
open class File(val descriptors: List<DeclarationDescriptor>) : MetadataSource {
|
||||||
|
override val name: Name?
|
||||||
|
get() = null
|
||||||
|
}
|
||||||
|
|
||||||
|
open class Function(descriptor: FunctionDescriptor) : DescriptorBased<FunctionDescriptor>(descriptor)
|
||||||
|
|
||||||
|
open class Property(descriptor: PropertyDescriptor) : DescriptorBased<PropertyDescriptor>(descriptor)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user