diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrClassifierStorage.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrClassifierStorage.kt index cd60f4a813b..f62ba9568ce 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrClassifierStorage.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrClassifierStorage.kt @@ -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) { diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrDeclarationStorage.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrDeclarationStorage.kt index daa7531b4a4..d40acc5ddc2 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrDeclarationStorage.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrDeclarationStorage.kt @@ -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 } diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/descriptors/WrappedDescriptors.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/descriptors/WrappedDescriptors.kt index 06a2fb50caf..4d062c68a6d 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/descriptors/WrappedDescriptors.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/descriptors/WrappedDescriptors.kt @@ -443,7 +443,110 @@ open class WrappedSimpleFunctionDescriptor( override fun getUserData(key: CallableDescriptor.UserDataKey?): V? = null override fun newCopyBuilder(): FunctionDescriptor.CopyBuilder { - 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 { + override fun setOwner(owner: DeclarationDescriptor): FunctionDescriptor.CopyBuilder { + return this + } + + override fun setModality(modality: Modality): FunctionDescriptor.CopyBuilder { + return this + } + + override fun setVisibility(visibility: Visibility): FunctionDescriptor.CopyBuilder { + return this + } + + override fun setKind(kind: CallableMemberDescriptor.Kind): FunctionDescriptor.CopyBuilder { + return this + } + + override fun setCopyOverrides(copyOverrides: Boolean): FunctionDescriptor.CopyBuilder { + return this + } + + override fun setName(name: Name): FunctionDescriptor.CopyBuilder { + return this + } + + override fun setValueParameters(parameters: MutableList): + FunctionDescriptor.CopyBuilder { + return this + } + + override fun setTypeParameters( + parameters: MutableList + ): FunctionDescriptor.CopyBuilder { + return this + } + + override fun setReturnType(type: KotlinType): FunctionDescriptor.CopyBuilder { + return this + } + + override fun setExtensionReceiverParameter( + extensionReceiverParameter: ReceiverParameterDescriptor? + ): FunctionDescriptor.CopyBuilder { + return this + } + + override fun setDispatchReceiverParameter( + dispatchReceiverParameter: ReceiverParameterDescriptor? + ): FunctionDescriptor.CopyBuilder { + return this + } + + override fun setOriginal(original: CallableMemberDescriptor?): FunctionDescriptor.CopyBuilder { + return this + } + + override fun setSignatureChange(): FunctionDescriptor.CopyBuilder { + return this + } + + override fun setPreserveSourceElement(): FunctionDescriptor.CopyBuilder { + return this + } + + override fun setDropOriginalInContainingParts(): FunctionDescriptor.CopyBuilder { + return this + } + + override fun setHiddenToOvercomeSignatureClash(): FunctionDescriptor.CopyBuilder { + return this + } + + override fun setHiddenForResolutionEverywhereBesideSupercalls(): FunctionDescriptor.CopyBuilder { + return this + } + + override fun setAdditionalAnnotations( + additionalAnnotations: Annotations + ): FunctionDescriptor.CopyBuilder { + return this + } + + override fun setSubstitution(substitution: TypeSubstitution): FunctionDescriptor.CopyBuilder { + return this + } + + override fun putUserData( + userDataKey: CallableDescriptor.UserDataKey, + value: V + ): FunctionDescriptor.CopyBuilder { + return this + } + + override fun build(): SimpleFunctionDescriptor? { + return this@WrappedSimpleFunctionDescriptor + } + } } override fun accept(visitor: DeclarationDescriptorVisitor?, data: D) = @@ -570,11 +673,11 @@ open class WrappedClassDescriptor( override fun getSource() = sourceElement - override fun getConstructors() = owner.declarations.asSequence().filterIsInstance().map { it.descriptor }.toList() + override fun getConstructors() = + owner.declarations.filterIsInstance().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 { - TODO("not implemented") - } + override fun getSealedSubclasses(): Collection = emptyList() override fun getOriginal() = this diff --git a/compiler/testData/codegen/box/functions/functionNtoString.kt b/compiler/testData/codegen/box/functions/functionNtoString.kt index 9b56ddc7978..74467bb5a20 100644 --- a/compiler/testData/codegen/box/functions/functionNtoString.kt +++ b/compiler/testData/codegen/box/functions/functionNtoString.kt @@ -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 diff --git a/compiler/testData/codegen/box/ir/kt25405.kt b/compiler/testData/codegen/box/ir/kt25405.kt index 485922deed7..1fb602beefc 100644 --- a/compiler/testData/codegen/box/ir/kt25405.kt +++ b/compiler/testData/codegen/box/ir/kt25405.kt @@ -1,3 +1,5 @@ +// IGNORE_BACKEND_FIR: JVM_IR + fun tableView(init: Table.() -> Unit) { Table().init() } diff --git a/compiler/testData/codegen/box/reflection/annotations/findAnnotation.kt b/compiler/testData/codegen/box/reflection/annotations/findAnnotation.kt index 3fd085231a5..dac969d97dc 100644 --- a/compiler/testData/codegen/box/reflection/annotations/findAnnotation.kt +++ b/compiler/testData/codegen/box/reflection/annotations/findAnnotation.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // IGNORE_BACKEND: JS_IR // IGNORE_BACKEND: JS, NATIVE // WITH_REFLECT diff --git a/compiler/testData/codegen/box/reflection/annotations/hasAnnotation.kt b/compiler/testData/codegen/box/reflection/annotations/hasAnnotation.kt index 0866505bc5b..f353d675ced 100644 --- a/compiler/testData/codegen/box/reflection/annotations/hasAnnotation.kt +++ b/compiler/testData/codegen/box/reflection/annotations/hasAnnotation.kt @@ -1,5 +1,4 @@ // !USE_EXPERIMENTAL: kotlin.ExperimentalStdlibApi -// IGNORE_BACKEND_FIR: JVM_IR // TARGET_BACKEND: JVM // WITH_REFLECT diff --git a/compiler/testData/codegen/box/reflection/annotations/simpleClassAnnotation.kt b/compiler/testData/codegen/box/reflection/annotations/simpleClassAnnotation.kt index bf7c29f5f31..8d332ecdd6f 100644 --- a/compiler/testData/codegen/box/reflection/annotations/simpleClassAnnotation.kt +++ b/compiler/testData/codegen/box/reflection/annotations/simpleClassAnnotation.kt @@ -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 diff --git a/compiler/testData/codegen/box/reflection/builtins/enumNameOrdinal.kt b/compiler/testData/codegen/box/reflection/builtins/enumNameOrdinal.kt index 5b27d01183e..4e97f9c22df 100644 --- a/compiler/testData/codegen/box/reflection/builtins/enumNameOrdinal.kt +++ b/compiler/testData/codegen/box/reflection/builtins/enumNameOrdinal.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // IGNORE_BACKEND: JS_IR, JS, NATIVE // WITH_REFLECT diff --git a/compiler/testData/codegen/box/reflection/callBy/manyArgumentsNoneDefaultConstructor.kt b/compiler/testData/codegen/box/reflection/callBy/manyArgumentsNoneDefaultConstructor.kt index 1e8bbd8534c..ac82c92a0b0 100644 --- a/compiler/testData/codegen/box/reflection/callBy/manyArgumentsNoneDefaultConstructor.kt +++ b/compiler/testData/codegen/box/reflection/callBy/manyArgumentsNoneDefaultConstructor.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // IGNORE_BACKEND: JS_IR // IGNORE_BACKEND: JS, NATIVE // WITH_REFLECT diff --git a/compiler/testData/codegen/box/reflection/classes/starProjectedType.kt b/compiler/testData/codegen/box/reflection/classes/starProjectedType.kt index 40c4b4bd637..26fc736c27d 100644 --- a/compiler/testData/codegen/box/reflection/classes/starProjectedType.kt +++ b/compiler/testData/codegen/box/reflection/classes/starProjectedType.kt @@ -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 diff --git a/compiler/testData/codegen/box/reflection/lambdaClasses/reflectOnDefaultWithInlineClassArgument.kt b/compiler/testData/codegen/box/reflection/lambdaClasses/reflectOnDefaultWithInlineClassArgument.kt index 17904c6a0e8..b214a51048d 100644 --- a/compiler/testData/codegen/box/reflection/lambdaClasses/reflectOnDefaultWithInlineClassArgument.kt +++ b/compiler/testData/codegen/box/reflection/lambdaClasses/reflectOnDefaultWithInlineClassArgument.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // TARGET_BACKEND: JVM // WITH_REFLECT diff --git a/compiler/testData/codegen/box/reflection/lambdaClasses/reflectOnLambdaInArrayConstructor.kt b/compiler/testData/codegen/box/reflection/lambdaClasses/reflectOnLambdaInArrayConstructor.kt index 22e6ad89b90..6d065e18695 100644 --- a/compiler/testData/codegen/box/reflection/lambdaClasses/reflectOnLambdaInArrayConstructor.kt +++ b/compiler/testData/codegen/box/reflection/lambdaClasses/reflectOnLambdaInArrayConstructor.kt @@ -1,5 +1,4 @@ // TARGET_BACKEND: JVM -// IGNORE_BACKEND_FIR: JVM_IR // WITH_RUNTIME // WITH_REFLECT diff --git a/compiler/testData/codegen/box/reflection/lambdaClasses/reflectOnLambdaInField.kt b/compiler/testData/codegen/box/reflection/lambdaClasses/reflectOnLambdaInField.kt index c22c2c2db51..60d6914c001 100644 --- a/compiler/testData/codegen/box/reflection/lambdaClasses/reflectOnLambdaInField.kt +++ b/compiler/testData/codegen/box/reflection/lambdaClasses/reflectOnLambdaInField.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // TARGET_BACKEND: JVM // WITH_REFLECT diff --git a/compiler/testData/codegen/box/reflection/lambdaClasses/reflectOnLambdaInStaticField.kt b/compiler/testData/codegen/box/reflection/lambdaClasses/reflectOnLambdaInStaticField.kt index 3b94cf8ac51..ccd88ba89db 100644 --- a/compiler/testData/codegen/box/reflection/lambdaClasses/reflectOnLambdaInStaticField.kt +++ b/compiler/testData/codegen/box/reflection/lambdaClasses/reflectOnLambdaInStaticField.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // TARGET_BACKEND: JVM // WITH_REFLECT diff --git a/compiler/testData/codegen/box/reflection/mapping/types/supertypes.kt b/compiler/testData/codegen/box/reflection/mapping/types/supertypes.kt index 6e51d0cccc4..8e052a45b9d 100644 --- a/compiler/testData/codegen/box/reflection/mapping/types/supertypes.kt +++ b/compiler/testData/codegen/box/reflection/mapping/types/supertypes.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // TARGET_BACKEND: JVM // WITH_REFLECT diff --git a/compiler/testData/codegen/box/reflection/methodsFromAny/typeParametersToString.kt b/compiler/testData/codegen/box/reflection/methodsFromAny/typeParametersToString.kt index 62ee49999af..38e19316f5a 100644 --- a/compiler/testData/codegen/box/reflection/methodsFromAny/typeParametersToString.kt +++ b/compiler/testData/codegen/box/reflection/methodsFromAny/typeParametersToString.kt @@ -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 diff --git a/compiler/testData/codegen/box/reflection/properties/privateFakeOverrideFromSuperclass.kt b/compiler/testData/codegen/box/reflection/properties/privateFakeOverrideFromSuperclass.kt index 9c3d4735984..d1913ec8c12 100644 --- a/compiler/testData/codegen/box/reflection/properties/privateFakeOverrideFromSuperclass.kt +++ b/compiler/testData/codegen/box/reflection/properties/privateFakeOverrideFromSuperclass.kt @@ -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 diff --git a/compiler/testData/codegen/box/reflection/supertypes/genericSubstitution.kt b/compiler/testData/codegen/box/reflection/supertypes/genericSubstitution.kt index 931c428c11a..450bae7e341 100644 --- a/compiler/testData/codegen/box/reflection/supertypes/genericSubstitution.kt +++ b/compiler/testData/codegen/box/reflection/supertypes/genericSubstitution.kt @@ -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 diff --git a/compiler/testData/codegen/box/reflection/typeOf/classes.kt b/compiler/testData/codegen/box/reflection/typeOf/classes.kt index 0955e8e1f35..f4fd9b756ea 100644 --- a/compiler/testData/codegen/box/reflection/typeOf/classes.kt +++ b/compiler/testData/codegen/box/reflection/typeOf/classes.kt @@ -1,6 +1,5 @@ // !USE_EXPERIMENTAL: kotlin.ExperimentalStdlibApi // !LANGUAGE: +NewInference -// IGNORE_BACKEND_FIR: JVM_IR // TARGET_BACKEND: JVM // WITH_REFLECT diff --git a/compiler/testData/codegen/box/reflection/typeOf/inlineClasses.kt b/compiler/testData/codegen/box/reflection/typeOf/inlineClasses.kt index 8685cfbac2f..69b83bded5d 100644 --- a/compiler/testData/codegen/box/reflection/typeOf/inlineClasses.kt +++ b/compiler/testData/codegen/box/reflection/typeOf/inlineClasses.kt @@ -1,5 +1,4 @@ // !USE_EXPERIMENTAL: kotlin.ExperimentalStdlibApi -// IGNORE_BACKEND_FIR: JVM_IR // IGNORE_BACKEND: JS, JS_IR, NATIVE // WITH_REFLECT diff --git a/compiler/testData/codegen/box/reflection/typeOf/manyTypeArguments.kt b/compiler/testData/codegen/box/reflection/typeOf/manyTypeArguments.kt index 2996da17c3a..06c8f6139d2 100644 --- a/compiler/testData/codegen/box/reflection/typeOf/manyTypeArguments.kt +++ b/compiler/testData/codegen/box/reflection/typeOf/manyTypeArguments.kt @@ -1,5 +1,4 @@ // !USE_EXPERIMENTAL: kotlin.ExperimentalStdlibApi -// IGNORE_BACKEND_FIR: JVM_IR // IGNORE_BACKEND: JS, JS_IR, NATIVE // WITH_REFLECT diff --git a/compiler/testData/codegen/box/reflection/typeOf/multipleLayers.kt b/compiler/testData/codegen/box/reflection/typeOf/multipleLayers.kt index 3d0900acc9a..810c16f45bd 100644 --- a/compiler/testData/codegen/box/reflection/typeOf/multipleLayers.kt +++ b/compiler/testData/codegen/box/reflection/typeOf/multipleLayers.kt @@ -1,5 +1,4 @@ // !USE_EXPERIMENTAL: kotlin.ExperimentalStdlibApi -// IGNORE_BACKEND_FIR: JVM_IR // IGNORE_BACKEND: JS, JS_IR, NATIVE // WITH_REFLECT diff --git a/compiler/testData/codegen/box/reflection/types/createType/equality.kt b/compiler/testData/codegen/box/reflection/types/createType/equality.kt index 87c37beb562..3fb58c90353 100644 --- a/compiler/testData/codegen/box/reflection/types/createType/equality.kt +++ b/compiler/testData/codegen/box/reflection/types/createType/equality.kt @@ -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 diff --git a/compiler/testData/codegen/box/reflection/types/createType/simpleCreateType.kt b/compiler/testData/codegen/box/reflection/types/createType/simpleCreateType.kt index 6c63477f256..6f8ea42b0ca 100644 --- a/compiler/testData/codegen/box/reflection/types/createType/simpleCreateType.kt +++ b/compiler/testData/codegen/box/reflection/types/createType/simpleCreateType.kt @@ -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