IR: make DescriptorMetadataSource a subtype of MetadataSource
FirMetadataSource is a metadata source too.
This commit is contained in:
@@ -11,21 +11,27 @@ import org.jetbrains.kotlin.name.Name
|
||||
interface MetadataSource {
|
||||
val name: Name?
|
||||
|
||||
abstract class DescriptorBased<D : DeclarationDescriptor> internal constructor(val descriptor: D) : MetadataSource {
|
||||
override val name: Name
|
||||
get() = descriptor.name
|
||||
}
|
||||
|
||||
class Class(descriptor: ClassDescriptor) : DescriptorBased<ClassDescriptor>(descriptor)
|
||||
|
||||
open class File(val descriptors: List<DeclarationDescriptor>) : MetadataSource {
|
||||
override val name: Name?
|
||||
get() = null
|
||||
}
|
||||
|
||||
class Function(descriptor: FunctionDescriptor) : DescriptorBased<FunctionDescriptor>(descriptor)
|
||||
|
||||
class Property(descriptor: PropertyDescriptor) : DescriptorBased<PropertyDescriptor>(descriptor)
|
||||
|
||||
class LocalDelegatedProperty(descriptor: VariableDescriptorWithAccessors) : DescriptorBased<VariableDescriptorWithAccessors>(descriptor)
|
||||
interface File : MetadataSource
|
||||
interface Class : MetadataSource
|
||||
interface Function : MetadataSource
|
||||
interface Property : MetadataSource
|
||||
}
|
||||
|
||||
sealed class DescriptorMetadataSource : MetadataSource {
|
||||
open val descriptor: Named?
|
||||
get() = null
|
||||
|
||||
override val name: Name?
|
||||
get() = descriptor?.name
|
||||
|
||||
class File(val descriptors: List<DeclarationDescriptor>) : DescriptorMetadataSource(), MetadataSource.File
|
||||
|
||||
class Class(override val descriptor: ClassDescriptor) : DescriptorMetadataSource(), MetadataSource.Class
|
||||
|
||||
class Function(override val descriptor: FunctionDescriptor) : DescriptorMetadataSource(), MetadataSource.Function
|
||||
|
||||
class Property(override val descriptor: PropertyDescriptor) : DescriptorMetadataSource(), MetadataSource.Property
|
||||
|
||||
class LocalDelegatedProperty(override val descriptor: VariableDescriptorWithAccessors) : DescriptorMetadataSource(),
|
||||
MetadataSource.Property
|
||||
}
|
||||
|
||||
@@ -589,7 +589,7 @@ class SymbolTable(
|
||||
visibility ?: it.descriptor.visibility, !it.descriptor.isVar, it.descriptor.isEffectivelyExternal(),
|
||||
it.descriptor.dispatchReceiverParameter == null
|
||||
).apply {
|
||||
metadata = MetadataSource.Property(it.descriptor)
|
||||
metadata = DescriptorMetadataSource.Property(it.descriptor)
|
||||
}
|
||||
}
|
||||
): IrField =
|
||||
@@ -662,7 +662,7 @@ class SymbolTable(
|
||||
isExternal = descriptor.isEffectivelyExternal(),
|
||||
isExpect = descriptor.isExpect
|
||||
).apply {
|
||||
metadata = MetadataSource.Property(symbol.descriptor)
|
||||
metadata = DescriptorMetadataSource.Property(symbol.descriptor)
|
||||
}
|
||||
}
|
||||
): IrProperty =
|
||||
@@ -978,7 +978,7 @@ class SymbolTable(
|
||||
{ IrLocalDelegatedPropertySymbolImpl(descriptor) },
|
||||
factory
|
||||
).apply {
|
||||
metadata = MetadataSource.LocalDelegatedProperty(descriptor)
|
||||
metadata = DescriptorMetadataSource.LocalDelegatedProperty(descriptor)
|
||||
}
|
||||
|
||||
fun referenceLocalDelegatedProperty(descriptor: VariableDescriptorWithAccessors) =
|
||||
|
||||
@@ -7,9 +7,9 @@ package org.jetbrains.kotlin.ir.util
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
||||
import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI
|
||||
import org.jetbrains.kotlin.ir.declarations.DescriptorMetadataSource
|
||||
import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin
|
||||
import org.jetbrains.kotlin.ir.declarations.IrSimpleFunction
|
||||
import org.jetbrains.kotlin.ir.declarations.MetadataSource
|
||||
import org.jetbrains.kotlin.ir.types.impl.IrUninitializedType
|
||||
|
||||
@ObsoleteDescriptorBasedAPI
|
||||
@@ -25,7 +25,7 @@ fun SymbolTable.declareSimpleFunctionWithOverrides(
|
||||
startOffset, endOffset, origin, it, nameProvider.nameForDeclaration(this),
|
||||
visibility, modality, IrUninitializedType, isInline, isExternal, isTailrec, isSuspend, isOperator, isInfix, isExpect
|
||||
).also { declaration ->
|
||||
declaration.metadata = MetadataSource.Function(this)
|
||||
declaration.metadata = DescriptorMetadataSource.Function(this)
|
||||
}
|
||||
}
|
||||
}.also { declaration ->
|
||||
|
||||
Reference in New Issue
Block a user