[FIR2IR] Set @Metadata when declaring IR symbols
This commit is contained in:
committed by
Mikhail Glukhikh
parent
b7e270f1c1
commit
08ca6f5f99
@@ -208,6 +208,7 @@ class Fir2IrClassifierStorage(
|
||||
isExpect = regularClass.isExpect,
|
||||
isFun = false // TODO FirRegularClass.isFun
|
||||
).apply {
|
||||
metadata = MetadataSource.Class(descriptor)
|
||||
descriptor.bind(this)
|
||||
}
|
||||
}
|
||||
@@ -242,6 +243,7 @@ class Fir2IrClassifierStorage(
|
||||
isCompanion = false, isInner = false, isData = false,
|
||||
isExternal = false, isInline = false, isExpect = false, isFun = false
|
||||
).apply {
|
||||
metadata = MetadataSource.Class(descriptor)
|
||||
descriptor.bind(this)
|
||||
setThisReceiver()
|
||||
if (irParent != null) {
|
||||
|
||||
+7
-1
@@ -430,7 +430,9 @@ class Fir2IrDeclarationStorage(
|
||||
isExpect = simpleFunction?.isExpect == true,
|
||||
isFakeOverride = updatedOrigin == IrDeclarationOrigin.FAKE_OVERRIDE,
|
||||
isOperator = simpleFunction?.isOperator == true
|
||||
)
|
||||
).apply {
|
||||
metadata = MetadataSource.Function(descriptor)
|
||||
}
|
||||
}
|
||||
result
|
||||
}.bindAndDeclareParameters(function, descriptor, irParent, isStatic = simpleFunction?.isStatic == true)
|
||||
@@ -486,6 +488,7 @@ class Fir2IrDeclarationStorage(
|
||||
constructor.returnTypeRef.toIrType(),
|
||||
isInline = false, isExternal = false, isPrimary = isPrimary, isExpect = false
|
||||
).apply {
|
||||
metadata = MetadataSource.Function(descriptor)
|
||||
enterScope(descriptor)
|
||||
}.bindAndDeclareParameters(constructor, descriptor, irParent, isStatic = false).apply {
|
||||
leaveScope(descriptor)
|
||||
@@ -532,6 +535,7 @@ class Fir2IrDeclarationStorage(
|
||||
isFakeOverride = origin == IrDeclarationOrigin.FAKE_OVERRIDE,
|
||||
isOperator = false
|
||||
).apply {
|
||||
metadata = MetadataSource.Function(descriptor)
|
||||
with(classifierStorage) {
|
||||
setTypeParameters(
|
||||
property, ConversionTypeContext(
|
||||
@@ -585,6 +589,7 @@ class Fir2IrDeclarationStorage(
|
||||
isExpect = property.isExpect,
|
||||
isFakeOverride = origin == IrDeclarationOrigin.FAKE_OVERRIDE
|
||||
).apply {
|
||||
metadata = MetadataSource.Property(descriptor)
|
||||
descriptor.bind(this)
|
||||
if (irParent != null) {
|
||||
parent = irParent
|
||||
@@ -638,6 +643,7 @@ class Fir2IrDeclarationStorage(
|
||||
isStatic = field.isStatic,
|
||||
isFakeOverride = false
|
||||
).apply {
|
||||
metadata = MetadataSource.Property(descriptor)
|
||||
descriptor.bind(this)
|
||||
fieldCache[field] = this
|
||||
}
|
||||
|
||||
@@ -443,7 +443,110 @@ open class WrappedSimpleFunctionDescriptor(
|
||||
override fun <V : Any?> getUserData(key: CallableDescriptor.UserDataKey<V>?): V? = null
|
||||
|
||||
override fun newCopyBuilder(): FunctionDescriptor.CopyBuilder<out SimpleFunctionDescriptor> {
|
||||
TODO("not implemented")
|
||||
// Use the original descriptor's copy builder if available.
|
||||
// make sure that the original descriptor is not `this`. Otherwise, newCopyBuilder ends up with stack overflow.
|
||||
if (originalDescriptor != this && originalDescriptor is SimpleFunctionDescriptor) {
|
||||
return (originalDescriptor as SimpleFunctionDescriptor).newCopyBuilder();
|
||||
}
|
||||
// Otherwise, return a fake copy builder that will eventually return the same wrapped descriptor.
|
||||
// TODO: it is unclear whether IR lowering really needs a deep copy (and a fake copy is okay by chance).
|
||||
return object : FunctionDescriptor.CopyBuilder<SimpleFunctionDescriptor> {
|
||||
override fun setOwner(owner: DeclarationDescriptor): FunctionDescriptor.CopyBuilder<SimpleFunctionDescriptor> {
|
||||
return this
|
||||
}
|
||||
|
||||
override fun setModality(modality: Modality): FunctionDescriptor.CopyBuilder<SimpleFunctionDescriptor> {
|
||||
return this
|
||||
}
|
||||
|
||||
override fun setVisibility(visibility: Visibility): FunctionDescriptor.CopyBuilder<SimpleFunctionDescriptor> {
|
||||
return this
|
||||
}
|
||||
|
||||
override fun setKind(kind: CallableMemberDescriptor.Kind): FunctionDescriptor.CopyBuilder<SimpleFunctionDescriptor> {
|
||||
return this
|
||||
}
|
||||
|
||||
override fun setCopyOverrides(copyOverrides: Boolean): FunctionDescriptor.CopyBuilder<SimpleFunctionDescriptor> {
|
||||
return this
|
||||
}
|
||||
|
||||
override fun setName(name: Name): FunctionDescriptor.CopyBuilder<SimpleFunctionDescriptor> {
|
||||
return this
|
||||
}
|
||||
|
||||
override fun setValueParameters(parameters: MutableList<ValueParameterDescriptor>):
|
||||
FunctionDescriptor.CopyBuilder<SimpleFunctionDescriptor> {
|
||||
return this
|
||||
}
|
||||
|
||||
override fun setTypeParameters(
|
||||
parameters: MutableList<TypeParameterDescriptor>
|
||||
): FunctionDescriptor.CopyBuilder<SimpleFunctionDescriptor> {
|
||||
return this
|
||||
}
|
||||
|
||||
override fun setReturnType(type: KotlinType): FunctionDescriptor.CopyBuilder<SimpleFunctionDescriptor> {
|
||||
return this
|
||||
}
|
||||
|
||||
override fun setExtensionReceiverParameter(
|
||||
extensionReceiverParameter: ReceiverParameterDescriptor?
|
||||
): FunctionDescriptor.CopyBuilder<SimpleFunctionDescriptor> {
|
||||
return this
|
||||
}
|
||||
|
||||
override fun setDispatchReceiverParameter(
|
||||
dispatchReceiverParameter: ReceiverParameterDescriptor?
|
||||
): FunctionDescriptor.CopyBuilder<SimpleFunctionDescriptor> {
|
||||
return this
|
||||
}
|
||||
|
||||
override fun setOriginal(original: CallableMemberDescriptor?): FunctionDescriptor.CopyBuilder<SimpleFunctionDescriptor> {
|
||||
return this
|
||||
}
|
||||
|
||||
override fun setSignatureChange(): FunctionDescriptor.CopyBuilder<SimpleFunctionDescriptor> {
|
||||
return this
|
||||
}
|
||||
|
||||
override fun setPreserveSourceElement(): FunctionDescriptor.CopyBuilder<SimpleFunctionDescriptor> {
|
||||
return this
|
||||
}
|
||||
|
||||
override fun setDropOriginalInContainingParts(): FunctionDescriptor.CopyBuilder<SimpleFunctionDescriptor> {
|
||||
return this
|
||||
}
|
||||
|
||||
override fun setHiddenToOvercomeSignatureClash(): FunctionDescriptor.CopyBuilder<SimpleFunctionDescriptor> {
|
||||
return this
|
||||
}
|
||||
|
||||
override fun setHiddenForResolutionEverywhereBesideSupercalls(): FunctionDescriptor.CopyBuilder<SimpleFunctionDescriptor> {
|
||||
return this
|
||||
}
|
||||
|
||||
override fun setAdditionalAnnotations(
|
||||
additionalAnnotations: Annotations
|
||||
): FunctionDescriptor.CopyBuilder<SimpleFunctionDescriptor> {
|
||||
return this
|
||||
}
|
||||
|
||||
override fun setSubstitution(substitution: TypeSubstitution): FunctionDescriptor.CopyBuilder<SimpleFunctionDescriptor> {
|
||||
return this
|
||||
}
|
||||
|
||||
override fun <V : Any?> putUserData(
|
||||
userDataKey: CallableDescriptor.UserDataKey<V>,
|
||||
value: V
|
||||
): FunctionDescriptor.CopyBuilder<SimpleFunctionDescriptor> {
|
||||
return this
|
||||
}
|
||||
|
||||
override fun build(): SimpleFunctionDescriptor? {
|
||||
return this@WrappedSimpleFunctionDescriptor
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun <R, D> accept(visitor: DeclarationDescriptorVisitor<R, D>?, data: D) =
|
||||
@@ -570,11 +673,11 @@ open class WrappedClassDescriptor(
|
||||
|
||||
override fun getSource() = sourceElement
|
||||
|
||||
override fun getConstructors() = owner.declarations.asSequence().filterIsInstance<IrConstructor>().map { it.descriptor }.toList()
|
||||
override fun getConstructors() =
|
||||
owner.declarations.filterIsInstance<IrConstructor>().filter { !it.origin.isSynthetic }.map { it.descriptor }.toList()
|
||||
|
||||
override fun getContainingDeclaration() = (owner.parent as IrSymbolOwner).symbol.descriptor
|
||||
|
||||
|
||||
private val _defaultType: SimpleType by lazy {
|
||||
TypeUtils.makeUnsubstitutedType(this, unsubstitutedMemberScope, KotlinTypeFactory.EMPTY_REFINED_TYPE_FACTORY)
|
||||
}
|
||||
@@ -604,9 +707,7 @@ open class WrappedClassDescriptor(
|
||||
|
||||
override fun getDeclaredTypeParameters() = owner.typeParameters.map { it.descriptor }
|
||||
|
||||
override fun getSealedSubclasses(): Collection<ClassDescriptor> {
|
||||
TODO("not implemented")
|
||||
}
|
||||
override fun getSealedSubclasses(): Collection<ClassDescriptor> = emptyList()
|
||||
|
||||
override fun getOriginal() = this
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// IGNORE_BACKEND: JS_IR
|
||||
// TODO: muted automatically, investigate should it be ran for JS or not
|
||||
// IGNORE_BACKEND: JS, NATIVE
|
||||
|
||||
+2
@@ -1,3 +1,5 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
|
||||
fun <T> tableView(init: Table<T>.() -> Unit) {
|
||||
Table<T>().init()
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// IGNORE_BACKEND: JS_IR
|
||||
// IGNORE_BACKEND: JS, NATIVE
|
||||
// WITH_REFLECT
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
// !USE_EXPERIMENTAL: kotlin.ExperimentalStdlibApi
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// TARGET_BACKEND: JVM
|
||||
// WITH_REFLECT
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// IGNORE_BACKEND: JS_IR
|
||||
// TODO: muted automatically, investigate should it be ran for JS or not
|
||||
// IGNORE_BACKEND: JS, NATIVE
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// IGNORE_BACKEND: JS_IR, JS, NATIVE
|
||||
// WITH_REFLECT
|
||||
|
||||
|
||||
-1
@@ -1,4 +1,3 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// IGNORE_BACKEND: JS_IR
|
||||
// IGNORE_BACKEND: JS, NATIVE
|
||||
// WITH_REFLECT
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// IGNORE_BACKEND: JS_IR
|
||||
// TODO: muted automatically, investigate should it be ran for JS or not
|
||||
// IGNORE_BACKEND: JS, NATIVE
|
||||
|
||||
Vendored
-1
@@ -1,4 +1,3 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// TARGET_BACKEND: JVM
|
||||
// WITH_REFLECT
|
||||
|
||||
|
||||
Vendored
-1
@@ -1,5 +1,4 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// WITH_RUNTIME
|
||||
// WITH_REFLECT
|
||||
|
||||
|
||||
-1
@@ -1,4 +1,3 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// TARGET_BACKEND: JVM
|
||||
// WITH_REFLECT
|
||||
|
||||
|
||||
-1
@@ -1,4 +1,3 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// TARGET_BACKEND: JVM
|
||||
// WITH_REFLECT
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// TARGET_BACKEND: JVM
|
||||
|
||||
// WITH_REFLECT
|
||||
|
||||
-1
@@ -1,4 +1,3 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// IGNORE_BACKEND: JS_IR
|
||||
// TODO: muted automatically, investigate should it be ran for JS or not
|
||||
// IGNORE_BACKEND: JS, NATIVE
|
||||
|
||||
-1
@@ -1,4 +1,3 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// IGNORE_BACKEND: JS_IR
|
||||
// TODO: muted automatically, investigate should it be ran for JS or not
|
||||
// IGNORE_BACKEND: JS, NATIVE
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// IGNORE_BACKEND: JS_IR
|
||||
// TODO: muted automatically, investigate should it be ran for JS or not
|
||||
// IGNORE_BACKEND: JS, NATIVE
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
// !USE_EXPERIMENTAL: kotlin.ExperimentalStdlibApi
|
||||
// !LANGUAGE: +NewInference
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// TARGET_BACKEND: JVM
|
||||
// WITH_REFLECT
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
// !USE_EXPERIMENTAL: kotlin.ExperimentalStdlibApi
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// IGNORE_BACKEND: JS, JS_IR, NATIVE
|
||||
// WITH_REFLECT
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
// !USE_EXPERIMENTAL: kotlin.ExperimentalStdlibApi
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// IGNORE_BACKEND: JS, JS_IR, NATIVE
|
||||
// WITH_REFLECT
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
// !USE_EXPERIMENTAL: kotlin.ExperimentalStdlibApi
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// IGNORE_BACKEND: JS, JS_IR, NATIVE
|
||||
// WITH_REFLECT
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// IGNORE_BACKEND: JS_IR
|
||||
// TODO: muted automatically, investigate should it be ran for JS or not
|
||||
// IGNORE_BACKEND: JS, NATIVE
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// IGNORE_BACKEND: JS_IR
|
||||
// TODO: muted automatically, investigate should it be ran for JS or not
|
||||
// IGNORE_BACKEND: JS, NATIVE
|
||||
|
||||
Reference in New Issue
Block a user