diff --git a/compiler/fir/analysis-tests/testData/resolve/delegatedSuperType.txt b/compiler/fir/analysis-tests/testData/resolve/delegatedSuperType.txt index 80a6354a6ae..13ab99c38db 100644 --- a/compiler/fir/analysis-tests/testData/resolve/delegatedSuperType.txt +++ b/compiler/fir/analysis-tests/testData/resolve/delegatedSuperType.txt @@ -13,8 +13,11 @@ FILE: delegatedSuperType.kt } public final class C : R|A| { + local final field $$delegate_0: R|A| + public constructor(b: R|B|): R|C| { super() + this@R|/C|.R|/$$delegate_0| = R|/b| } public final val b: R|B| = R|/b| diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/ConversionUtils.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/ConversionUtils.kt index 78c89a8ca2e..81b16a32b0a 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/ConversionUtils.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/ConversionUtils.kt @@ -407,6 +407,10 @@ fun isOverriding( // Not checking the field type (they should match each other if everything other match, otherwise it's a compilation error) target.name == superCandidate.name } + target is IrProperty && superCandidate is IrProperty -> { + // Not checking the property type (they should match each other if names match, otherwise it's a compilation error) + target.name == superCandidate.name + } else -> false } } 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 23955fb7a53..8f34024f34e 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 @@ -5,7 +5,10 @@ package org.jetbrains.kotlin.fir.backend -import org.jetbrains.kotlin.descriptors.* +import org.jetbrains.kotlin.descriptors.ClassKind +import org.jetbrains.kotlin.descriptors.Modality +import org.jetbrains.kotlin.descriptors.Visibilities +import org.jetbrains.kotlin.descriptors.Visibility import org.jetbrains.kotlin.fir.declarations.* import org.jetbrains.kotlin.fir.lazy.Fir2IrLazyClass import org.jetbrains.kotlin.fir.resolve.firProvider @@ -23,7 +26,10 @@ import org.jetbrains.kotlin.ir.declarations.impl.IrClassImpl import org.jetbrains.kotlin.ir.declarations.impl.IrEnumEntryImpl import org.jetbrains.kotlin.ir.declarations.impl.IrTypeAliasImpl import org.jetbrains.kotlin.ir.declarations.impl.IrTypeParameterImpl -import org.jetbrains.kotlin.ir.descriptors.* +import org.jetbrains.kotlin.ir.descriptors.WrappedClassDescriptor +import org.jetbrains.kotlin.ir.descriptors.WrappedEnumEntryDescriptor +import org.jetbrains.kotlin.ir.descriptors.WrappedTypeAliasDescriptor +import org.jetbrains.kotlin.ir.descriptors.WrappedTypeParameterDescriptor import org.jetbrains.kotlin.ir.expressions.impl.IrEnumConstructorCallImpl import org.jetbrains.kotlin.ir.expressions.impl.IrExpressionBodyImpl import org.jetbrains.kotlin.ir.symbols.IrClassSymbol diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrConverter.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrConverter.kt index e3e80bacd5b..1749afa749a 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrConverter.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrConverter.kt @@ -87,7 +87,7 @@ class Fir2IrConverter( anonymousObject.getPrimaryConstructorIfAny()?.let { irClass.declarations += declarationStorage.createIrConstructor(it, irClass) } - for (declaration in anonymousObject.declarations) { + for (declaration in sortBySynthetic(anonymousObject.declarations)) { if (declaration is FirRegularClass) { registerClassAndNestedClasses(declaration, irClass) processClassAndNestedClassHeaders(declaration) @@ -98,6 +98,13 @@ class Fir2IrConverter( return irClass } + // Sort declarations so that all non-synthetic declarations are before synthetic ones. + // This is needed because converting synthetic fields for implementation delegation needs to know + // existing declarations in the class to avoid adding redundant delegated members. + private fun sortBySynthetic(declarations: List) : Iterable { + return declarations.sortedBy { it.isSynthetic } + } + private fun processClassMembers( regularClass: FirRegularClass, irClass: IrClass = classifierStorage.getCachedIrClass(regularClass)!! @@ -105,7 +112,7 @@ class Fir2IrConverter( regularClass.getPrimaryConstructorIfAny()?.let { irClass.declarations += declarationStorage.createIrConstructor(it, irClass) } - for (declaration in regularClass.declarations) { + for (declaration in sortBySynthetic(regularClass.declarations)) { val irDeclaration = processMemberDeclaration(declaration, irClass) ?: continue irClass.declarations += irDeclaration } @@ -142,6 +149,13 @@ class Fir2IrConverter( is FirProperty -> { declarationStorage.createIrProperty(declaration, parent) } + is FirField -> { + if (declaration.isSynthetic) { + declarationStorage.createIrFieldAndDelegatedMembers(declaration, parent as IrClass) + } else { + throw AssertionError("Unexpected non-synthetic field: ${declaration::class}") + } + } is FirConstructor -> if (!declaration.isPrimary) { declarationStorage.createIrConstructor(declaration, parent as IrClass) } else { 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 2fa1d5bfbc4..274f1367402 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 @@ -11,6 +11,7 @@ import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.descriptors.annotations.Annotations import org.jetbrains.kotlin.fir.FirAnnotationContainer import org.jetbrains.kotlin.fir.backend.generators.AnnotationGenerator +import org.jetbrains.kotlin.fir.backend.generators.DelegatedMemberGenerator import org.jetbrains.kotlin.fir.declarations.* import org.jetbrains.kotlin.fir.declarations.impl.FirDefaultPropertyGetter import org.jetbrains.kotlin.fir.declarations.impl.FirDefaultPropertySetter @@ -36,12 +37,9 @@ import org.jetbrains.kotlin.ir.declarations.impl.* import org.jetbrains.kotlin.ir.descriptors.* import org.jetbrains.kotlin.ir.expressions.IrExpression import org.jetbrains.kotlin.ir.expressions.IrSyntheticBodyKind -import org.jetbrains.kotlin.ir.expressions.impl.IrErrorExpressionImpl -import org.jetbrains.kotlin.ir.expressions.impl.IrExpressionBodyImpl +import org.jetbrains.kotlin.ir.expressions.impl.* import org.jetbrains.kotlin.ir.symbols.* -import org.jetbrains.kotlin.ir.types.IrErrorType -import org.jetbrains.kotlin.ir.types.IrSimpleType -import org.jetbrains.kotlin.ir.types.IrType +import org.jetbrains.kotlin.ir.types.* import org.jetbrains.kotlin.ir.util.* import org.jetbrains.kotlin.name.ClassId import org.jetbrains.kotlin.name.FqName @@ -78,6 +76,8 @@ class Fir2IrDeclarationStorage( private val localStorage = Fir2IrLocalStorage() + private val delegatedMemberGenerator = DelegatedMemberGenerator(components) + private fun areCompatible(firFunction: FirFunction<*>, irFunction: IrFunction): Boolean { if (firFunction is FirSimpleFunction && irFunction is IrSimpleFunction) { if (irFunction.name != firFunction.name) return false @@ -700,9 +700,39 @@ class Fir2IrDeclarationStorage( fun getCachedIrProperty(property: FirProperty): IrProperty? = propertyCache[property] - private fun createIrField(field: FirField): IrField { + fun getCachedIrField(field: FirField): IrField? = fieldCache[field] + + fun createIrFieldAndDelegatedMembers(field: FirField, parent: IrClass): IrField { + val irField = createIrField(field, origin = IrDeclarationOrigin.DELEGATE) + irField.setAndModifyParent(parent) + delegatedMemberGenerator.generate(irField, parent) + return irField + } + + internal fun findOverriddenFirFunction(irFunction: IrSimpleFunction, superClassId: ClassId): FirFunction<*>? { + val functions = getFirClassByFqName(superClassId)?.declarations?.filter { + it is FirFunction<*> && functionCache.containsKey(it) && irFunction.overrides(functionCache[it]!!) + } + return if (functions.isNullOrEmpty()) null else functions.first() as FirFunction<*> + } + + internal fun findOverriddenFirProperty(irProperty: IrProperty, superClassId: ClassId): FirProperty? { + val properties = getFirClassByFqName(superClassId)?.declarations?.filter { + it is FirProperty && it.name == irProperty.name + } + return if (properties.isNullOrEmpty()) null else properties.first() as FirProperty + } + + private fun getFirClassByFqName(classId: ClassId): FirClass<*>? { + val declaration = firProvider.getClassLikeSymbolByFqName(classId) ?: firSymbolProvider.getClassLikeSymbolByFqName(classId) + return declaration?.fir as? FirClass<*> + } + + private fun createIrField( + field: FirField, + origin: IrDeclarationOrigin = IrDeclarationOrigin.IR_EXTERNAL_JAVA_DECLARATION_STUB + ): IrField { val descriptor = WrappedFieldDescriptor() - val origin = IrDeclarationOrigin.IR_EXTERNAL_JAVA_DECLARATION_STUB val type = field.returnTypeRef.toIrType() return field.convertWithOffsets { startOffset, endOffset -> symbolTable.declareField( diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrVisitor.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrVisitor.kt index 0094541c57c..1bcf33760eb 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrVisitor.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrVisitor.kt @@ -76,6 +76,14 @@ class Fir2IrVisitor( TODO("Should not be here: ${element.render()}") } + override fun visitField(field: FirField, data: Any?): IrField { + if (field.isSynthetic) { + return declarationStorage.getCachedIrField(field)!! + } else { + throw AssertionError("Unexpected field: ${field.render()}") + } + } + override fun visitFile(file: FirFile, data: Any?): IrFile { return conversionScope.withParent(declarationStorage.getIrFile(file)) { file.declarations.forEach { diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/ClassMemberGenerator.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/ClassMemberGenerator.kt index 0fca9a585bb..e7264182bd4 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/ClassMemberGenerator.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/ClassMemberGenerator.kt @@ -59,6 +59,16 @@ internal class ClassMemberGenerator( else -> null } } + // Add delegated members *before* fake override generations. + // Otherwise, fake overrides for delegated members, which are redundant, will be added. + irClass.declarations.filter { + it.origin == IrDeclarationOrigin.DELEGATED_MEMBER + }.forEach { + when (it) { + is IrSimpleFunction -> processedCallableNames += it.name + is IrProperty -> processedCallableNames += it.name + } + } // Add synthetic members *before* fake override generations. // Otherwise, redundant members, e.g., synthetic toString _and_ fake override toString, will be added. if (irClass.isInline && klass.getPrimaryConstructorIfAny() != null) { diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/DelegatedMemberGenerator.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/DelegatedMemberGenerator.kt new file mode 100644 index 00000000000..5301fd80a9b --- /dev/null +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/DelegatedMemberGenerator.kt @@ -0,0 +1,271 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.backend.generators + +import org.jetbrains.kotlin.backend.common.ir.isFinalClass +import org.jetbrains.kotlin.backend.common.ir.isOverridable +import org.jetbrains.kotlin.descriptors.Modality +import org.jetbrains.kotlin.descriptors.Visibilities +import org.jetbrains.kotlin.fir.backend.Fir2IrComponents +import org.jetbrains.kotlin.fir.backend.FirMetadataSource +import org.jetbrains.kotlin.fir.backend.declareThisReceiverParameter +import org.jetbrains.kotlin.fir.backend.isOverriding +import org.jetbrains.kotlin.fir.declarations.* +import org.jetbrains.kotlin.fir.declarations.builder.buildProperty +import org.jetbrains.kotlin.fir.declarations.builder.buildSimpleFunction +import org.jetbrains.kotlin.fir.declarations.builder.buildValueParameterCopy +import org.jetbrains.kotlin.fir.declarations.impl.FirDeclarationStatusImpl +import org.jetbrains.kotlin.fir.symbols.CallableId +import org.jetbrains.kotlin.fir.symbols.impl.FirNamedFunctionSymbol +import org.jetbrains.kotlin.fir.symbols.impl.FirPropertySymbol +import org.jetbrains.kotlin.fir.symbols.impl.FirVariableSymbol +import org.jetbrains.kotlin.ir.declarations.* +import org.jetbrains.kotlin.ir.declarations.impl.IrFunctionImpl +import org.jetbrains.kotlin.ir.declarations.impl.IrPropertyImpl +import org.jetbrains.kotlin.ir.declarations.impl.IrValueParameterImpl +import org.jetbrains.kotlin.ir.descriptors.WrappedPropertyDescriptor +import org.jetbrains.kotlin.ir.descriptors.WrappedSimpleFunctionDescriptor +import org.jetbrains.kotlin.ir.descriptors.WrappedValueParameterDescriptor +import org.jetbrains.kotlin.ir.expressions.impl.* +import org.jetbrains.kotlin.ir.types.classOrNull +import org.jetbrains.kotlin.ir.types.impl.IrSimpleTypeImpl +import org.jetbrains.kotlin.ir.types.isNothing +import org.jetbrains.kotlin.ir.types.isUnit +import org.jetbrains.kotlin.ir.util.classId +import org.jetbrains.kotlin.ir.util.defaultType +import org.jetbrains.kotlin.ir.util.hasAnnotation +import org.jetbrains.kotlin.ir.util.isFakeOverride +import org.jetbrains.kotlin.name.FqName +import org.jetbrains.kotlin.name.Name + +/** + * A generator for delegated members from implementation by delegation. + * + * It assumes a synthetic field with the super-interface type has been created for the delegate expression. It looks for delegatable + * methods and properties in the super-interface, and creates corresponding members in the subclass. + * TODO: generic super interface types and generic delegated members. + */ +internal class DelegatedMemberGenerator( + private val components: Fir2IrComponents +) : Fir2IrComponents by components { + + // Generate delegated members for [subClass]. The synthetic field [irField] has the super interface type. + fun generate(irField: IrField, subClass: IrClass) { + val superClass = (irField.type as IrSimpleTypeImpl)?.classOrNull?.owner ?: return + val superClassId = superClass.classId ?: return + superClass.declarations?.filter { + it.isDelegatable() && !subClass.declarations.any { decl -> isOverriding(irBuiltIns, decl, it) } + }?.forEach { + if (it is IrSimpleFunction) { + val firFunction = declarationStorage.findOverriddenFirFunction(it, superClassId) ?: return + val function = generateDelegatedFunction(subClass, irField, it, firFunction) + subClass.addMember(function) + } else if (it is IrProperty) { + val firProperty = declarationStorage.findOverriddenFirProperty(it, superClassId) ?: return + generateDelegatedProperty(subClass, irField, it, firProperty) + } + } + } + + private fun IrDeclaration.isDelegatable(): Boolean { + return isOverridable() + && !isFakeOverride + && !(this is IrSimpleFunction && hasDefaultImplementation()) + } + + private fun IrDeclaration.isOverridable(): Boolean { + return when (this) { + is IrSimpleFunction -> this.isOverridable + is IrProperty -> visibility != Visibilities.PRIVATE && modality != Modality.FINAL && (parent as? IrClass)?.isFinalClass != true + else -> false + } + } + + private fun IrSimpleFunction.hasDefaultImplementation(): Boolean { + var realFunction: IrSimpleFunction? = this + while (realFunction != null && realFunction.isFakeOverride) { + realFunction = realFunction.overriddenSymbols?.firstOrNull()?.owner + } + return realFunction != null + && (realFunction.modality != Modality.ABSTRACT && realFunction.origin == IrDeclarationOrigin.IR_EXTERNAL_JAVA_DECLARATION_STUB + || realFunction.annotations.hasAnnotation(FqName("kotlin.jvm.JvmDefault"))) + } + + private fun generateDelegatedFunction( + subClass: IrClass, + irField: IrField, + superFunction: IrSimpleFunction, + firSuperFunction: FirFunction<*> + ): IrSimpleFunction { + val startOffset = irField.startOffset + val endOffset = irField.endOffset + val descriptor = WrappedSimpleFunctionDescriptor() + val origin = IrDeclarationOrigin.DELEGATED_MEMBER + val modality = if (superFunction.modality == Modality.ABSTRACT) Modality.OPEN else superFunction.modality + val delegateFunction = symbolTable.declareSimpleFunction(descriptor) { symbol -> + IrFunctionImpl( + startOffset, + endOffset, + origin, + symbol, + superFunction.name, + superFunction.visibility, + modality, + superFunction.returnType, + superFunction.isInline, + superFunction.isExternal, + superFunction.isTailrec, + superFunction.isSuspend, + superFunction.isOperator, + superFunction.isExpect + ).apply { + descriptor.bind(this) + declarationStorage.enterScope(this) + this.parent = subClass + overriddenSymbols += superFunction.symbol + dispatchReceiverParameter = declareThisReceiverParameter(symbolTable, subClass.defaultType, origin) + // TODO: type parameters from superFunctions and type substitution when super interface types are generic + superFunction.valueParameters.forEach { valueParameter -> + val parameterDescriptor = WrappedValueParameterDescriptor() + valueParameters += symbolTable.declareValueParameter( + startOffset, endOffset, origin, parameterDescriptor, valueParameter.type + ) { symbol -> + IrValueParameterImpl( + startOffset, endOffset, origin, symbol, + valueParameter.name, valueParameter.index, valueParameter.type, + null, valueParameter.isCrossinline, valueParameter.isNoinline + ).also { + parameterDescriptor.bind(it) + it.parent = this + } + } + } + + val visibility = when (firSuperFunction) { + is FirSimpleFunction -> firSuperFunction.status.visibility + is FirPropertyAccessor -> firSuperFunction.status.visibility + else -> Visibilities.PUBLIC + } + metadata = FirMetadataSource.Function( + buildSimpleFunction { + this.origin = FirDeclarationOrigin.Synthetic + this.name = superFunction.name + this.symbol = FirNamedFunctionSymbol(getCallableId(subClass, superFunction.name)) + this.status = FirDeclarationStatusImpl(visibility, modality) + this.session = components.session + this.returnTypeRef = firSuperFunction.returnTypeRef + firSuperFunction.valueParameters.map { superParameter -> + this.valueParameters.add( + buildValueParameterCopy(superParameter) { + this.origin = FirDeclarationOrigin.Synthetic + this.session = components.session + this.symbol = FirVariableSymbol(superParameter.name) + } + ) + } + } + ) + + declarationStorage.leaveScope(this) + } + } + + val body = IrBlockBodyImpl(startOffset, endOffset) + val irCall = IrCallImpl( + startOffset, + endOffset, + superFunction.returnType, + superFunction.symbol, + superFunction.typeParameters.size, + superFunction.valueParameters.size + ).apply { + dispatchReceiver = + IrGetFieldImpl( + startOffset, endOffset, + irField.symbol, + irField.type, + IrGetValueImpl( + startOffset, endOffset, + delegateFunction.dispatchReceiverParameter?.type!!, + delegateFunction.dispatchReceiverParameter?.symbol!! + ) + ) + extensionReceiver = + delegateFunction.extensionReceiverParameter?.let { extensionReceiver -> + IrGetValueImpl(startOffset, endOffset, extensionReceiver.type, extensionReceiver.symbol) + } + delegateFunction.valueParameters.forEach { + putValueArgument(it.index, IrGetValueImpl(startOffset, endOffset, it.type, it.symbol)) + } + } + if (superFunction.returnType.isUnit() || superFunction.returnType.isNothing()) { + body.statements.add(irCall) + } else { + val irReturn = IrReturnImpl(startOffset, endOffset, irBuiltIns.nothingType, delegateFunction.symbol, irCall) + body.statements.add(irReturn) + } + delegateFunction.body = body + return delegateFunction + } + + private fun generateDelegatedProperty( + subClass: IrClass, + irField: IrField, + superProperty: IrProperty, + firSuperProperty: FirProperty + ) { + val startOffset = irField.startOffset + val endOffset = irField.endOffset + val descriptor = WrappedPropertyDescriptor() + val modality = if (superProperty.modality == Modality.ABSTRACT) Modality.OPEN else superProperty.modality + symbolTable.declareProperty( + startOffset, endOffset, + IrDeclarationOrigin.DELEGATED_MEMBER, descriptor, superProperty.isDelegated + ) { symbol -> + IrPropertyImpl( + startOffset, endOffset, IrDeclarationOrigin.DELEGATED_MEMBER, symbol, + superProperty.name, superProperty.visibility, + modality, + isVar = superProperty.isVar, + isConst = superProperty.isConst, + isLateinit = superProperty.isLateinit, + isDelegated = superProperty.isDelegated, + isExternal = false, + isExpect = superProperty.isExpect, + isFakeOverride = false + ).apply { + descriptor.bind(this) + this.parent = subClass + getter = generateDelegatedFunction(subClass, irField, superProperty.getter!!, firSuperProperty.getter!!).apply { + this.correspondingPropertySymbol = symbol + } + if (superProperty.isVar) { + setter = generateDelegatedFunction(subClass, irField, superProperty.setter!!, firSuperProperty.setter!!).apply { + this.correspondingPropertySymbol = symbol + } + } + this.metadata = FirMetadataSource.Property( + buildProperty { + this.name = superProperty.name + this.origin = FirDeclarationOrigin.Synthetic + this.session = components.session + this.status = FirDeclarationStatusImpl(firSuperProperty.status.visibility, modality) + this.isLocal = firSuperProperty.isLocal + this.returnTypeRef = firSuperProperty.returnTypeRef + this.symbol = FirPropertySymbol(getCallableId(subClass, superProperty.name)) + this.isVar = firSuperProperty.isVar + } + ) + subClass.addMember(this) + } + } + } + + private fun getCallableId(irClass: IrClass, name: Name): CallableId { + val classId = irClass.classId + return if (classId != null) CallableId(classId, name) else CallableId(name) + } +} diff --git a/compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/converter/DeclarationsConverter.kt b/compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/converter/DeclarationsConverter.kt index 4023702d636..873ef5c650e 100644 --- a/compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/converter/DeclarationsConverter.kt +++ b/compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/converter/DeclarationsConverter.kt @@ -36,6 +36,7 @@ import org.jetbrains.kotlin.fir.lightTree.fir.modifier.Modifier import org.jetbrains.kotlin.fir.lightTree.fir.modifier.TypeModifier import org.jetbrains.kotlin.fir.lightTree.fir.modifier.TypeParameterModifier import org.jetbrains.kotlin.fir.lightTree.fir.modifier.TypeProjectionModifier +import org.jetbrains.kotlin.fir.references.builder.buildSimpleNamedReference import org.jetbrains.kotlin.fir.scopes.FirScopeProvider import org.jetbrains.kotlin.fir.symbols.CallableId import org.jetbrains.kotlin.fir.symbols.impl.* @@ -408,6 +409,8 @@ class DeclarationsConverter( val delegationSpecifiers = superTypeList?.let { convertDelegationSpecifiers(it) } var delegatedSuperTypeRef: FirTypeRef? = delegationSpecifiers?.delegatedSuperTypeRef val delegatedConstructorSource: FirLightSourceElement? = delegationSpecifiers?.delegatedConstructorSource + delegationSpecifiers?.delegateFields?.map { declarations += it } + val superTypeCallEntry = delegationSpecifiers?.delegatedConstructorArguments.orEmpty() val superTypeRefs = mutableListOf() @@ -449,7 +452,10 @@ class DeclarationsConverter( superTypeCallEntry = superTypeCallEntry ) //parse primary constructor - val primaryConstructorWrapper = convertPrimaryConstructor(primaryConstructor, classWrapper, delegatedConstructorSource) + val primaryConstructorWrapper = convertPrimaryConstructor( + primaryConstructor, classWrapper, delegatedConstructorSource, + delegationSpecifiers?.primaryConstructorBody + ) val firPrimaryConstructor = primaryConstructorWrapper?.firConstructor firPrimaryConstructor?.let { declarations += it } @@ -503,6 +509,8 @@ class DeclarationsConverter( var delegatedSuperTypeRef: FirTypeRef? = null var classBody: LighterASTNode? = null var delegatedConstructorSource: FirLightSourceElement? = null + var delegateFields: List? = null + var primaryConstructorBody: FirBlock? = null objectLiteral.getChildNodesByType(OBJECT_DECLARATION).first().forEachChildren { when (it.tokenType) { MODIFIER_LIST -> modifiers = convertModifierList(it) @@ -512,6 +520,8 @@ class DeclarationsConverter( superTypeRefs += it.superTypesRef superTypeCallEntry += it.delegatedConstructorArguments delegatedConstructorSource = it.delegatedConstructorSource + delegateFields = it.delegateFields + primaryConstructorBody = it.primaryConstructorBody } CLASS_BODY -> classBody = it } @@ -537,6 +547,7 @@ class DeclarationsConverter( this.superTypeRefs += superTypeRefs typeRef = delegatedSelfType + delegateFields?.map { this.declarations += it } val classWrapper = ClassWrapper( SpecialNames.NO_NAME_PROVIDED, modifiers, ClassKind.OBJECT, this, hasPrimaryConstructor = false, @@ -547,7 +558,7 @@ class DeclarationsConverter( superTypeCallEntry = superTypeCallEntry ) //parse primary constructor - convertPrimaryConstructor(primaryConstructor, classWrapper, delegatedConstructorSource) + convertPrimaryConstructor(primaryConstructor, classWrapper, delegatedConstructorSource, primaryConstructorBody) ?.let { this.declarations += it.firConstructor } //parse declarations @@ -666,7 +677,8 @@ class DeclarationsConverter( private fun convertPrimaryConstructor( primaryConstructor: LighterASTNode?, classWrapper: ClassWrapper, - delegatedConstructorSource: FirLightSourceElement? + delegatedConstructorSource: FirLightSourceElement?, + body: FirBlock? = null ): PrimaryConstructor? { if (primaryConstructor == null && !classWrapper.isEnumEntry() && classWrapper.hasSecondaryConstructor) return null if (classWrapper.isInterface()) return null @@ -709,6 +721,7 @@ class DeclarationsConverter( typeParameters += constructorTypeParametersFromConstructedClass(classWrapper.classBuilder.typeParameters) this.valueParameters += valueParameters.map { it.firValueParameter } delegatedConstructor = firDelegatedCall + this.body = body }, valueParameters ) } @@ -1303,7 +1316,9 @@ class DeclarationsConverter( val delegatedSuperTypeRef: FirTypeRef?, val superTypesRef: List, val delegatedConstructorArguments: List, - val delegatedConstructorSource: FirLightSourceElement? + val delegatedConstructorSource: FirLightSourceElement?, + val delegateFields: List, + val primaryConstructorBody: FirBlock? ) private fun convertDelegationSpecifiers(delegationSpecifiers: LighterASTNode): DelegationSpecifiers { @@ -1311,6 +1326,9 @@ class DeclarationsConverter( val superTypeCallEntry = mutableListOf() var delegatedSuperTypeRef: FirTypeRef? = null var delegateConstructorSource: FirLightSourceElement? = null + val delegateFields = mutableListOf() + val initializeDelegateStatements = mutableListOf() + var delegateNumber = 0 delegationSpecifiers.forEachChildren { when (it.tokenType) { SUPER_TYPE_ENTRY -> superTypeRefs += convertType(it) @@ -1320,10 +1338,23 @@ class DeclarationsConverter( superTypeCallEntry += second delegateConstructorSource = it.toFirSourceElement() } - DELEGATED_SUPER_TYPE_ENTRY -> superTypeRefs += convertExplicitDelegation(it) + DELEGATED_SUPER_TYPE_ENTRY -> { + superTypeRefs += convertExplicitDelegation(it, delegateNumber, delegateFields, initializeDelegateStatements) + delegateNumber++ + } } } - return DelegationSpecifiers(delegatedSuperTypeRef, superTypeRefs, superTypeCallEntry, delegateConstructorSource) + val body = if (initializeDelegateStatements.isNotEmpty()) { + buildBlock { + for (statement in initializeDelegateStatements) { + statements += statement + } + } + } else null + return DelegationSpecifiers( + delegatedSuperTypeRef, superTypeRefs, superTypeCallEntry, delegateConstructorSource, + delegateFields, body + ) } /** @@ -1352,7 +1383,12 @@ class DeclarationsConverter( * : userType "by" element * ; */ - private fun convertExplicitDelegation(explicitDelegation: LighterASTNode): FirDelegatedTypeRef { + private fun convertExplicitDelegation( + explicitDelegation: LighterASTNode, + delegateNumber: Int, + delegateFields: MutableList, + initializeDelegateStatements: MutableList + ): FirTypeRef { lateinit var firTypeRef: FirTypeRef var firExpression: FirExpression? = buildErrorExpression( explicitDelegation.toFirSourceElement(), ConeSimpleDiagnostic("Should have delegate", DiagnosticKind.Syntax) @@ -1364,10 +1400,30 @@ class DeclarationsConverter( } } - return buildDelegatedTypeRef { - delegate = firExpression - typeRef = firTypeRef - } + val delegateName = Name.identifier("\$\$delegate_$delegateNumber") + delegateFields.add( + buildField { + source = firExpression!!.source + session = baseSession + origin = FirDeclarationOrigin.Synthetic + name = delegateName + returnTypeRef = firTypeRef!! + symbol = FirFieldSymbol(CallableId(name)) + isVar = false + status = FirDeclarationStatusImpl(Visibilities.LOCAL, Modality.FINAL) + } + ) + initializeDelegateStatements.add( + buildVariableAssignment { + source = firExpression!!.source + calleeReference = + buildSimpleNamedReference { + name = delegateName + } + rValue = firExpression!! + } + ) + return firTypeRef } /***** TYPES *****/ diff --git a/compiler/fir/raw-fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/RawFirBuilder.kt b/compiler/fir/raw-fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/RawFirBuilder.kt index cccc6ef9856..c011370c528 100644 --- a/compiler/fir/raw-fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/RawFirBuilder.kt +++ b/compiler/fir/raw-fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/RawFirBuilder.kt @@ -28,6 +28,7 @@ import org.jetbrains.kotlin.fir.expressions.impl.FirSingleExpressionBlock import org.jetbrains.kotlin.fir.references.FirNamedReference import org.jetbrains.kotlin.fir.references.builder.* import org.jetbrains.kotlin.fir.scopes.FirScopeProvider +import org.jetbrains.kotlin.fir.symbols.CallableId import org.jetbrains.kotlin.fir.symbols.impl.* import org.jetbrains.kotlin.fir.types.* import org.jetbrains.kotlin.fir.types.builder.* @@ -48,7 +49,6 @@ import org.jetbrains.kotlin.util.OperatorNameConventions import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstanceOrNull import java.util.* import org.jetbrains.kotlin.utils.addToStdlib.runIf -import kotlin.collections.contains class RawFirBuilder( session: FirSession, val baseScopeProvider: FirScopeProvider, val stubMode: Boolean @@ -459,6 +459,8 @@ class RawFirBuilder( ): FirTypeRef { var superTypeCallEntry: KtSuperTypeCallEntry? = null var delegatedSuperTypeRef: FirTypeRef? = null + var delegateNumber = 0 + val initializeDelegateStatements = mutableListOf() for (superTypeListEntry in superTypeListEntries) { when (superTypeListEntry) { is KtSuperTypeEntry -> { @@ -471,10 +473,32 @@ class RawFirBuilder( } is KtDelegatedSuperTypeEntry -> { val type = superTypeListEntry.typeReference.toFirOrErrorType() - container.superTypeRefs += buildDelegatedTypeRef { - delegate = { superTypeListEntry.delegateExpression }.toFirExpression("Should have delegate") - typeRef = type + val delegateExpression = { superTypeListEntry.delegateExpression }.toFirExpression("Should have delegate") + container.superTypeRefs += type + val delegateName = Name.identifier("\$\$delegate_$delegateNumber") + val delegateSource = superTypeListEntry.delegateExpression?.toFirSourceElement() + val delegateField = buildField { + source = delegateSource + session = baseSession + origin = FirDeclarationOrigin.Synthetic + name = delegateName + returnTypeRef = type + symbol = FirFieldSymbol(CallableId(name)) + isVar = false + status = FirDeclarationStatusImpl(Visibilities.LOCAL, Modality.FINAL) } + initializeDelegateStatements.add( + buildVariableAssignment { + source = delegateSource + calleeReference = + buildSimpleNamedReference { + name = delegateName + } + rValue = delegateExpression + } + ) + container.declarations.add(delegateField) + delegateNumber ++ } } } @@ -526,8 +550,14 @@ class RawFirBuilder( delegatedSuperTypeRef, delegatedSelfTypeRef ?: delegatedSuperTypeRef, owner = this, - containerTypeParameters + containerTypeParameters, + body = if (initializeDelegateStatements.isNotEmpty()) buildBlock { + for (statement in initializeDelegateStatements) { + statements += statement + } + } else null ) + container.declarations += firPrimaryConstructor return delegatedSuperTypeRef } @@ -537,7 +567,8 @@ class RawFirBuilder( delegatedSuperTypeRef: FirTypeRef, delegatedSelfTypeRef: FirTypeRef, owner: KtClassOrObject, - ownerTypeParameters: List + ownerTypeParameters: List, + body: FirBlock? = null ): FirConstructor { val constructorCallee = superTypeCallEntry?.calleeExpression?.toFirSourceElement() val constructorSource = this?.toFirSourceElement() @@ -577,6 +608,7 @@ class RawFirBuilder( typeParameters += constructorTypeParametersFromConstructedClass(ownerTypeParameters) this@toFirConstructor?.extractAnnotationsTo(this) this@toFirConstructor?.extractValueParametersTo(this) + this.body = body } } @@ -719,7 +751,7 @@ class RawFirBuilder( classOrObject.extractSuperTypeListEntriesTo(this, delegatedSelfType, null, classKind, typeParameters) val primaryConstructor = classOrObject.primaryConstructor - val firPrimaryConstructor = declarations.firstOrNull() as? FirConstructor + val firPrimaryConstructor = declarations.firstOrNull {it is FirConstructor} as? FirConstructor if (primaryConstructor != null && firPrimaryConstructor != null) { primaryConstructor.valueParameters.zip( firPrimaryConstructor.valueParameters diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirStatusResolveTransformer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirStatusResolveTransformer.kt index e8215b2f797..f4ccee0876a 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirStatusResolveTransformer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirStatusResolveTransformer.kt @@ -138,6 +138,14 @@ class FirStatusResolveTransformer( return transformDeclaration(property, data) } + override fun transformField( + field: FirField, + data: FirDeclarationStatus? + ): CompositeTransformResult { + field.transformStatus(this, field.resolveStatus(field.status, containingClass, isLocal = false)) + return transformDeclaration(field, data) + } + override fun transformEnumEntry(enumEntry: FirEnumEntry, data: FirDeclarationStatus?): CompositeTransformResult { return transformDeclaration(enumEntry, data) } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirDeclarationsResolveTransformer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirDeclarationsResolveTransformer.kt index 29a81a42211..d5d7e07a2c8 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirDeclarationsResolveTransformer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirDeclarationsResolveTransformer.kt @@ -741,7 +741,7 @@ open class FirDeclarationsResolveTransformer(transformer: FirBodyResolveTransfor else staticsAndCompanion - val constructor = (owner as? FirRegularClass)?.declarations?.firstOrNull() as? FirConstructor + val constructor = (owner as? FirRegularClass)?.declarations?.firstOrNull { it is FirConstructor } as? FirConstructor val primaryConstructorParametersScope = if (constructor?.isPrimary == true) { constructor.valueParameters.fold(FirLocalScope()) { acc, param -> acc.storeVariable(param) } diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/FirDeclarationUtil.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/FirDeclarationUtil.kt index 33dd4ff9d3d..610ebab7c1b 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/FirDeclarationUtil.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/FirDeclarationUtil.kt @@ -9,8 +9,8 @@ import org.jetbrains.kotlin.descriptors.ClassKind import org.jetbrains.kotlin.descriptors.Visibilities import org.jetbrains.kotlin.fir.declarations.builder.FirRegularClassBuilder import org.jetbrains.kotlin.fir.declarations.builder.FirTypeParameterBuilder -import org.jetbrains.kotlin.fir.declarations.impl.FirRegularClassImpl import org.jetbrains.kotlin.fir.declarations.impl.FirFileImpl +import org.jetbrains.kotlin.fir.declarations.impl.FirRegularClassImpl import org.jetbrains.kotlin.fir.symbols.impl.FirAnonymousObjectSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirClassSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirRegularClassSymbol @@ -119,4 +119,7 @@ var FirProperty.isFromVararg: Boolean? by FirDeclarationDataRegistry.data(IsFrom fun FirAnnotatedDeclaration.hasAnnotation(classId: ClassId): Boolean { return annotations.any { it.annotationTypeRef.coneTypeSafe()?.classId == classId } -} \ No newline at end of file +} + +inline val FirDeclaration.isSynthetic: Boolean + get() = origin == FirDeclarationOrigin.Synthetic diff --git a/compiler/testData/codegen/box/bridges/delegation.kt b/compiler/testData/codegen/box/bridges/delegation.kt index 1fb5bf04340..29dfbecf8a6 100644 --- a/compiler/testData/codegen/box/bridges/delegation.kt +++ b/compiler/testData/codegen/box/bridges/delegation.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR interface A { fun foo(): T } diff --git a/compiler/testData/codegen/box/bridges/delegationProperty.kt b/compiler/testData/codegen/box/bridges/delegationProperty.kt index 4343243c0ad..8192c4f4532 100644 --- a/compiler/testData/codegen/box/bridges/delegationProperty.kt +++ b/compiler/testData/codegen/box/bridges/delegationProperty.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR interface A { var result: T } diff --git a/compiler/testData/codegen/box/bridges/fakeGenericCovariantOverrideWithDelegation.kt b/compiler/testData/codegen/box/bridges/fakeGenericCovariantOverrideWithDelegation.kt index e4938bb819a..450ad185175 100644 --- a/compiler/testData/codegen/box/bridges/fakeGenericCovariantOverrideWithDelegation.kt +++ b/compiler/testData/codegen/box/bridges/fakeGenericCovariantOverrideWithDelegation.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR interface A { fun foo(t: T): String } diff --git a/compiler/testData/codegen/box/classes/delegation2.kt b/compiler/testData/codegen/box/classes/delegation2.kt index 4513bd8f303..81b8b0fb47e 100644 --- a/compiler/testData/codegen/box/classes/delegation2.kt +++ b/compiler/testData/codegen/box/classes/delegation2.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR interface Trait1 { fun foo() : String } diff --git a/compiler/testData/codegen/box/classes/inheritance.kt b/compiler/testData/codegen/box/classes/inheritance.kt index fa0230ebc3d..78d6d58fa3b 100644 --- a/compiler/testData/codegen/box/classes/inheritance.kt +++ b/compiler/testData/codegen/box/classes/inheritance.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // Changed when traits were introduced. May not make sense any more open class X(val x : Int) {} diff --git a/compiler/testData/codegen/box/classes/kt2224.kt b/compiler/testData/codegen/box/classes/kt2224.kt index dd41c152f97..fe6d9bcbe48 100644 --- a/compiler/testData/codegen/box/classes/kt2224.kt +++ b/compiler/testData/codegen/box/classes/kt2224.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR interface A { fun foo(): Int } diff --git a/compiler/testData/codegen/box/classes/kt285.kt b/compiler/testData/codegen/box/classes/kt285.kt index 6e55752b1f4..945b250f7dc 100644 --- a/compiler/testData/codegen/box/classes/kt285.kt +++ b/compiler/testData/codegen/box/classes/kt285.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR interface Trait { fun foo() = "O" fun bar(): String diff --git a/compiler/testData/codegen/box/classes/kt3001.kt b/compiler/testData/codegen/box/classes/kt3001.kt index 5e94162d391..0524528ca1e 100644 --- a/compiler/testData/codegen/box/classes/kt3001.kt +++ b/compiler/testData/codegen/box/classes/kt3001.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR interface A { val result: String } diff --git a/compiler/testData/codegen/box/classes/kt3414.kt b/compiler/testData/codegen/box/classes/kt3414.kt index 9f22d91e31f..6b4a083eda9 100644 --- a/compiler/testData/codegen/box/classes/kt3414.kt +++ b/compiler/testData/codegen/box/classes/kt3414.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR interface A { fun foo(): Int } diff --git a/compiler/testData/codegen/box/closures/kt11634_3.kt b/compiler/testData/codegen/box/closures/kt11634_3.kt index d6918ce25f4..1fdaa65c236 100644 --- a/compiler/testData/codegen/box/closures/kt11634_3.kt +++ b/compiler/testData/codegen/box/closures/kt11634_3.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR interface A { fun foo(): String } diff --git a/compiler/testData/codegen/box/closures/kt11634_4.kt b/compiler/testData/codegen/box/closures/kt11634_4.kt index 2793092a8ca..08722aa81de 100644 --- a/compiler/testData/codegen/box/closures/kt11634_4.kt +++ b/compiler/testData/codegen/box/closures/kt11634_4.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR interface A { fun foo(): String } diff --git a/compiler/testData/codegen/box/coroutines/delegatedSuspendMember.kt b/compiler/testData/codegen/box/coroutines/delegatedSuspendMember.kt index 3333e34ff05..0ab41fbf21d 100644 --- a/compiler/testData/codegen/box/coroutines/delegatedSuspendMember.kt +++ b/compiler/testData/codegen/box/coroutines/delegatedSuspendMember.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // WITH_RUNTIME // WITH_COROUTINES // COMMON_COROUTINES_TEST diff --git a/compiler/testData/codegen/box/coroutines/inlineClasses/interfaceDelegateWithInlineClass.kt b/compiler/testData/codegen/box/coroutines/inlineClasses/interfaceDelegateWithInlineClass.kt index b751ea7383a..5ac261989c2 100644 --- a/compiler/testData/codegen/box/coroutines/inlineClasses/interfaceDelegateWithInlineClass.kt +++ b/compiler/testData/codegen/box/coroutines/inlineClasses/interfaceDelegateWithInlineClass.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // WITH_RUNTIME // WITH_COROUTINES // COMMON_COROUTINES_TEST diff --git a/compiler/testData/codegen/box/coroutines/tailCallOptimizations/interfaceDelegation.kt b/compiler/testData/codegen/box/coroutines/tailCallOptimizations/interfaceDelegation.kt index 5ad7c1cdeb3..e8e67840ec2 100644 --- a/compiler/testData/codegen/box/coroutines/tailCallOptimizations/interfaceDelegation.kt +++ b/compiler/testData/codegen/box/coroutines/tailCallOptimizations/interfaceDelegation.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // TARGET_BACKEND: JVM // FULL_JDK // WITH_RUNTIME diff --git a/compiler/testData/codegen/box/coroutines/tailCallToNothing.kt b/compiler/testData/codegen/box/coroutines/tailCallToNothing.kt index 5a61be5e250..595fd0aa0bd 100644 --- a/compiler/testData/codegen/box/coroutines/tailCallToNothing.kt +++ b/compiler/testData/codegen/box/coroutines/tailCallToNothing.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // WITH_RUNTIME // WITH_COROUTINES import helpers.* diff --git a/compiler/testData/codegen/box/coroutines/unitTypeReturn/interfaceDelegation.kt b/compiler/testData/codegen/box/coroutines/unitTypeReturn/interfaceDelegation.kt index 4bc11b0c0d6..2d14770ff61 100644 --- a/compiler/testData/codegen/box/coroutines/unitTypeReturn/interfaceDelegation.kt +++ b/compiler/testData/codegen/box/coroutines/unitTypeReturn/interfaceDelegation.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // WITH_RUNTIME // WITH_COROUTINES diff --git a/compiler/testData/codegen/box/delegation/defaultOverride.kt b/compiler/testData/codegen/box/delegation/defaultOverride.kt index 0fd79a4d8ae..c2a66177a7a 100644 --- a/compiler/testData/codegen/box/delegation/defaultOverride.kt +++ b/compiler/testData/codegen/box/delegation/defaultOverride.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // SKIP_JDK6 // TARGET_BACKEND: JVM diff --git a/compiler/testData/codegen/box/delegation/hiddenSuperOverrideIn1.0.kt b/compiler/testData/codegen/box/delegation/hiddenSuperOverrideIn1.0.kt index 7457007c694..e3efc096e99 100644 --- a/compiler/testData/codegen/box/delegation/hiddenSuperOverrideIn1.0.kt +++ b/compiler/testData/codegen/box/delegation/hiddenSuperOverrideIn1.0.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR public interface Base { fun test() = "base fail" } diff --git a/compiler/testData/codegen/box/delegation/kt8154.kt b/compiler/testData/codegen/box/delegation/kt8154.kt index 49c3f2bb51d..86550e49f60 100644 --- a/compiler/testData/codegen/box/delegation/kt8154.kt +++ b/compiler/testData/codegen/box/delegation/kt8154.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR interface A { fun foo(): T } diff --git a/compiler/testData/codegen/box/delegation/mixed.kt b/compiler/testData/codegen/box/delegation/mixed.kt index 911177ad4c1..c8ef7c370a8 100644 --- a/compiler/testData/codegen/box/delegation/mixed.kt +++ b/compiler/testData/codegen/box/delegation/mixed.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // SKIP_JDK6 // TARGET_BACKEND: JVM // FILE: Base.java diff --git a/compiler/testData/codegen/box/enum/enumEntryReferenceFromInnerClassConstructor3.kt b/compiler/testData/codegen/box/enum/enumEntryReferenceFromInnerClassConstructor3.kt index b597d1e4d14..635103b8b02 100644 --- a/compiler/testData/codegen/box/enum/enumEntryReferenceFromInnerClassConstructor3.kt +++ b/compiler/testData/codegen/box/enum/enumEntryReferenceFromInnerClassConstructor3.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR interface IFoo { fun foo(): String } diff --git a/compiler/testData/codegen/box/inlineClasses/interfaceDelegation/interfaceImplementationByDelegation.kt b/compiler/testData/codegen/box/inlineClasses/interfaceDelegation/interfaceImplementationByDelegation.kt index 4fc2fb0979a..f80b888b0bf 100644 --- a/compiler/testData/codegen/box/inlineClasses/interfaceDelegation/interfaceImplementationByDelegation.kt +++ b/compiler/testData/codegen/box/inlineClasses/interfaceDelegation/interfaceImplementationByDelegation.kt @@ -1,5 +1,4 @@ // !LANGUAGE: +InlineClasses -// IGNORE_BACKEND_FIR: JVM_IR interface IFoo { fun getO(): String diff --git a/compiler/testData/codegen/box/inlineClasses/interfaceDelegation/memberFunDelegatedToInlineClassInt.kt b/compiler/testData/codegen/box/inlineClasses/interfaceDelegation/memberFunDelegatedToInlineClassInt.kt index bf756beb4ca..ca5d40833a5 100644 --- a/compiler/testData/codegen/box/inlineClasses/interfaceDelegation/memberFunDelegatedToInlineClassInt.kt +++ b/compiler/testData/codegen/box/inlineClasses/interfaceDelegation/memberFunDelegatedToInlineClassInt.kt @@ -1,6 +1,5 @@ // KJS_WITH_FULL_RUNTIME // WITH_RUNTIME -// IGNORE_BACKEND_FIR: JVM_IR import kotlin.test.assertEquals interface IFoo { diff --git a/compiler/testData/codegen/box/inlineClasses/interfaceDelegation/memberFunDelegatedToInlineClassLong.kt b/compiler/testData/codegen/box/inlineClasses/interfaceDelegation/memberFunDelegatedToInlineClassLong.kt index 22720dddbe1..00175bc3120 100644 --- a/compiler/testData/codegen/box/inlineClasses/interfaceDelegation/memberFunDelegatedToInlineClassLong.kt +++ b/compiler/testData/codegen/box/inlineClasses/interfaceDelegation/memberFunDelegatedToInlineClassLong.kt @@ -1,6 +1,5 @@ // KJS_WITH_FULL_RUNTIME // WITH_RUNTIME -// IGNORE_BACKEND_FIR: JVM_IR import kotlin.test.assertEquals interface IFoo { diff --git a/compiler/testData/codegen/box/properties/kt2655.kt b/compiler/testData/codegen/box/properties/kt2655.kt index 0769d049f7d..3956fb3a17d 100644 --- a/compiler/testData/codegen/box/properties/kt2655.kt +++ b/compiler/testData/codegen/box/properties/kt2655.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR interface TextField { fun getText(): String fun setText(text: String) diff --git a/compiler/testData/codegen/box/properties/kt2786.kt b/compiler/testData/codegen/box/properties/kt2786.kt index 36e2375cfea..003ca536275 100644 --- a/compiler/testData/codegen/box/properties/kt2786.kt +++ b/compiler/testData/codegen/box/properties/kt2786.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR interface FooTrait { val propertyTest: String } diff --git a/compiler/testData/codegen/box/secondaryConstructors/delegationWithPrimary.kt b/compiler/testData/codegen/box/secondaryConstructors/delegationWithPrimary.kt index a7901be8eaf..42690e92b97 100644 --- a/compiler/testData/codegen/box/secondaryConstructors/delegationWithPrimary.kt +++ b/compiler/testData/codegen/box/secondaryConstructors/delegationWithPrimary.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR internal interface A { fun foo(): String } diff --git a/compiler/testData/codegen/box/strings/kt3571.kt b/compiler/testData/codegen/box/strings/kt3571.kt index 2c1d3ed7460..960a37656a0 100644 --- a/compiler/testData/codegen/box/strings/kt3571.kt +++ b/compiler/testData/codegen/box/strings/kt3571.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR class Thing(delegate: CharSequence) : CharSequence by delegate fun box(): String { diff --git a/compiler/testData/codegen/box/throws/delegationAndThrows.kt b/compiler/testData/codegen/box/throws/delegationAndThrows.kt index 59983781916..94cd6fa4868 100644 --- a/compiler/testData/codegen/box/throws/delegationAndThrows.kt +++ b/compiler/testData/codegen/box/throws/delegationAndThrows.kt @@ -1,6 +1,5 @@ // !LANGUAGE: +DoNotGenerateThrowsForDelegatedKotlinMembers // TARGET_BACKEND: JVM -// IGNORE_BACKEND_FIR: JVM_IR // WITH_RUNTIME // FILE: A.kt diff --git a/compiler/testData/codegen/box/toArray/toArray.kt b/compiler/testData/codegen/box/toArray/toArray.kt index 4492616e4db..0475226a268 100644 --- a/compiler/testData/codegen/box/toArray/toArray.kt +++ b/compiler/testData/codegen/box/toArray/toArray.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // TARGET_BACKEND: JVM // WITH_RUNTIME diff --git a/compiler/testData/codegen/box/toArray/toArrayFromJava.kt b/compiler/testData/codegen/box/toArray/toArrayFromJava.kt index abf9fffc2d9..4ee49bb44ef 100644 --- a/compiler/testData/codegen/box/toArray/toArrayFromJava.kt +++ b/compiler/testData/codegen/box/toArray/toArrayFromJava.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // TARGET_BACKEND: JVM // The old backend thinks `toArray(): Array` is the same as `toArray(): Array` // IGNORE_BACKEND: JVM diff --git a/compiler/testData/diagnostics/tests/annotations/annotationInheritance.fir.kt b/compiler/testData/diagnostics/tests/annotations/annotationInheritance.fir.kt index dd3c7ea6d62..933f1b7a760 100644 --- a/compiler/testData/diagnostics/tests/annotations/annotationInheritance.fir.kt +++ b/compiler/testData/diagnostics/tests/annotations/annotationInheritance.fir.kt @@ -4,5 +4,5 @@ interface T annotation class Ann: C() annotation class Ann2: T -annotation class Ann3: T by a +annotation class Ann3: T by a annotation class Ann4: C(), T \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/override/MissingDelegate.fir.kt b/compiler/testData/diagnostics/tests/override/MissingDelegate.fir.kt index 21889dbfe5a..fe97c08736a 100644 --- a/compiler/testData/diagnostics/tests/override/MissingDelegate.fir.kt +++ b/compiler/testData/diagnostics/tests/override/MissingDelegate.fir.kt @@ -1,3 +1,3 @@ -class C : Base1 by Base2(1) { +class C : Base1 by Base2(1) { fun test() { } } \ No newline at end of file diff --git a/compiler/testData/ir/irText/classes/delegatedGenericImplementation.fir.txt b/compiler/testData/ir/irText/classes/delegatedGenericImplementation.fir.txt index 156088bad7e..a8d21428d01 100644 --- a/compiler/testData/ir/irText/classes/delegatedGenericImplementation.fir.txt +++ b/compiler/testData/ir/irText/classes/delegatedGenericImplementation.fir.txt @@ -46,34 +46,59 @@ FILE fqName: fileName:/delegatedGenericImplementation.kt BLOCK_BODY DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Test1 modality:FINAL visibility:public superTypes:[.IBase.Test1>]' - FUN FAKE_OVERRIDE name:foo visibility:public modality:ABSTRACT ($this:.IBase.IBase>, a:E of .Test1, b:B of .Test1.foo) returnType:kotlin.Unit [fake_override] + SET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:.IBase.Test1> visibility:local [final]' type=kotlin.Unit origin=EQ + receiver: GET_VAR ': .Test1.Test1> declared in .Test1' type=.Test1.Test1> origin=null + value: GET_VAR 'i: .IBase.Test1> declared in .Test1.' type=.IBase.Test1> origin=null + FUN DELEGATED_MEMBER name:foo visibility:public modality:OPEN <> ($this:.Test1.Test1>, a:A of .IBase, b:B of .IBase.foo) returnType:kotlin.Unit overridden: public abstract fun foo (a: A of .IBase, b: B of .IBase.foo): kotlin.Unit declared in .IBase - TYPE_PARAMETER name:B index:0 variance: superTypes:[kotlin.Any?] - $this: VALUE_PARAMETER name: type:.IBase.IBase> - VALUE_PARAMETER name:a index:0 type:E of .Test1 - VALUE_PARAMETER name:b index:1 type:B of .Test1.foo - PROPERTY FAKE_OVERRIDE name:id visibility:public modality:ABSTRACT [fake_override,val] - FUN FAKE_OVERRIDE name: visibility:public modality:ABSTRACT ($this:.IBase.IBase>) returnType:kotlin.collections.Map.Test1, C of .Test1.>? [fake_override] - correspondingProperty: PROPERTY FAKE_OVERRIDE name:id visibility:public modality:ABSTRACT [fake_override,val] + $this: VALUE_PARAMETER DELEGATED_MEMBER name: type:.Test1.Test1> + VALUE_PARAMETER DELEGATED_MEMBER name:a index:0 type:A of .IBase + VALUE_PARAMETER DELEGATED_MEMBER name:b index:1 type:B of .IBase.foo + BLOCK_BODY + CALL 'public abstract fun foo (a: A of .IBase, b: B of .IBase.foo): kotlin.Unit declared in .IBase' type=kotlin.Unit origin=null + : + $this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:.IBase.Test1> visibility:local [final]' type=.IBase.Test1> origin=null + receiver: GET_VAR ': .Test1.Test1> declared in .Test1.foo' type=.Test1.Test1> origin=null + a: GET_VAR 'a: A of .IBase declared in .Test1.foo' type=A of .IBase origin=null + b: GET_VAR 'b: B of .IBase.foo declared in .Test1.foo' type=B of .IBase.foo origin=null + PROPERTY DELEGATED_MEMBER name:id visibility:public modality:OPEN [val] + FUN DELEGATED_MEMBER name: visibility:public modality:OPEN <> ($this:.Test1.Test1>) returnType:kotlin.collections.Map.IBase, C of .IBase.>? + correspondingProperty: PROPERTY DELEGATED_MEMBER name:id visibility:public modality:OPEN [val] overridden: public abstract fun (): kotlin.collections.Map.IBase, C of .IBase.>? declared in .IBase - TYPE_PARAMETER name:C index:0 variance: superTypes:[kotlin.Any?] - $this: VALUE_PARAMETER name: type:.IBase.IBase> - PROPERTY FAKE_OVERRIDE name:x visibility:public modality:ABSTRACT [fake_override,var] - FUN FAKE_OVERRIDE name: visibility:public modality:ABSTRACT ($this:.IBase.IBase>) returnType:D of .Test1.? [fake_override] - correspondingProperty: PROPERTY FAKE_OVERRIDE name:x visibility:public modality:ABSTRACT [fake_override,var] + $this: VALUE_PARAMETER DELEGATED_MEMBER name: type:.Test1.Test1> + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun (): kotlin.collections.Map.IBase, C of .IBase.>? declared in .Test1' + CALL 'public abstract fun (): kotlin.collections.Map.IBase, C of .IBase.>? declared in .IBase' type=kotlin.collections.Map.IBase, C of .IBase.>? origin=null + : + $this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:.IBase.Test1> visibility:local [final]' type=.IBase.Test1> origin=null + receiver: GET_VAR ': .Test1.Test1> declared in .Test1.' type=.Test1.Test1> origin=null + PROPERTY DELEGATED_MEMBER name:x visibility:public modality:OPEN [var] + FUN DELEGATED_MEMBER name: visibility:public modality:OPEN <> ($this:.Test1.Test1>) returnType:D of .IBase.? + correspondingProperty: PROPERTY DELEGATED_MEMBER name:x visibility:public modality:OPEN [var] overridden: public abstract fun (): D of .IBase.? declared in .IBase - TYPE_PARAMETER name:D index:0 variance: superTypes:[kotlin.Any?] - $this: VALUE_PARAMETER name: type:.IBase.IBase> - FUN FAKE_OVERRIDE name: visibility:public modality:ABSTRACT ($this:.IBase.IBase>, :D of .Test1.?) returnType:kotlin.Unit [fake_override] - correspondingProperty: PROPERTY FAKE_OVERRIDE name:x visibility:public modality:ABSTRACT [fake_override,var] + $this: VALUE_PARAMETER DELEGATED_MEMBER name: type:.Test1.Test1> + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun (): D of .IBase.? declared in .Test1' + CALL 'public abstract fun (): D of .IBase.? declared in .IBase' type=D of .IBase.? origin=null + : + $this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:.IBase.Test1> visibility:local [final]' type=.IBase.Test1> origin=null + receiver: GET_VAR ': .Test1.Test1> declared in .Test1.' type=.Test1.Test1> origin=null + FUN DELEGATED_MEMBER name: visibility:public modality:OPEN <> ($this:.Test1.Test1>, :D of .IBase.?) returnType:kotlin.Unit + correspondingProperty: PROPERTY DELEGATED_MEMBER name:x visibility:public modality:OPEN [var] overridden: public abstract fun (: D of .IBase.?): kotlin.Unit declared in .IBase - TYPE_PARAMETER name:D index:0 variance: superTypes:[kotlin.Any?] - $this: VALUE_PARAMETER name: type:.IBase.IBase> - VALUE_PARAMETER name: index:0 type:D of .Test1.? + $this: VALUE_PARAMETER DELEGATED_MEMBER name: type:.Test1.Test1> + VALUE_PARAMETER DELEGATED_MEMBER name: index:0 type:D of .IBase.? + BLOCK_BODY + CALL 'public abstract fun (: D of .IBase.?): kotlin.Unit declared in .IBase' type=kotlin.Unit origin=null + : + $this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:.IBase.Test1> visibility:local [final]' type=.IBase.Test1> origin=null + receiver: GET_VAR ': .Test1.Test1> declared in .Test1.' type=.Test1.Test1> origin=null + : GET_VAR ': D of .IBase.? declared in .Test1.' type=D of .IBase.? origin=null + FIELD DELEGATE name:$$delegate_0 type:.IBase.Test1> visibility:local [final] FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any @@ -94,6 +119,9 @@ FILE fqName: fileName:/delegatedGenericImplementation.kt BLOCK_BODY DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Test2 modality:FINAL visibility:public superTypes:[.IBase]' + SET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:.IBase visibility:local [final]' type=kotlin.Unit origin=EQ + receiver: GET_VAR ': .Test2 declared in .Test2' type=.Test2 origin=null + value: GET_VAR 'j: .IBase declared in .Test2.' type=.IBase origin=null PROPERTY name:j visibility:public modality:FINAL [var] FIELD PROPERTY_BACKING_FIELD name:j type:.IBase visibility:private EXPRESSION_BODY @@ -113,34 +141,56 @@ FILE fqName: fileName:/delegatedGenericImplementation.kt SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:j type:.IBase visibility:private' type=kotlin.Unit origin=null receiver: GET_VAR ': .Test2 declared in .Test2.' type=.Test2 origin=null value: GET_VAR ': .IBase declared in .Test2.' type=.IBase origin=null - FUN FAKE_OVERRIDE name:foo visibility:public modality:ABSTRACT ($this:.IBase.IBase>, a:kotlin.String, b:B of .Test2.foo) returnType:kotlin.Unit [fake_override] + FUN DELEGATED_MEMBER name:foo visibility:public modality:OPEN <> ($this:.Test2, a:A of .IBase, b:B of .IBase.foo) returnType:kotlin.Unit overridden: public abstract fun foo (a: A of .IBase, b: B of .IBase.foo): kotlin.Unit declared in .IBase - TYPE_PARAMETER name:B index:0 variance: superTypes:[kotlin.Any?] - $this: VALUE_PARAMETER name: type:.IBase.IBase> - VALUE_PARAMETER name:a index:0 type:kotlin.String - VALUE_PARAMETER name:b index:1 type:B of .Test2.foo - PROPERTY FAKE_OVERRIDE name:id visibility:public modality:ABSTRACT [fake_override,val] - FUN FAKE_OVERRIDE name: visibility:public modality:ABSTRACT ($this:.IBase.IBase>) returnType:kotlin.collections.Map.Test2.>? [fake_override] - correspondingProperty: PROPERTY FAKE_OVERRIDE name:id visibility:public modality:ABSTRACT [fake_override,val] + $this: VALUE_PARAMETER DELEGATED_MEMBER name: type:.Test2 + VALUE_PARAMETER DELEGATED_MEMBER name:a index:0 type:A of .IBase + VALUE_PARAMETER DELEGATED_MEMBER name:b index:1 type:B of .IBase.foo + BLOCK_BODY + CALL 'public abstract fun foo (a: A of .IBase, b: B of .IBase.foo): kotlin.Unit declared in .IBase' type=kotlin.Unit origin=null + : + $this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:.IBase visibility:local [final]' type=.IBase origin=null + receiver: GET_VAR ': .Test2 declared in .Test2.foo' type=.Test2 origin=null + a: GET_VAR 'a: A of .IBase declared in .Test2.foo' type=A of .IBase origin=null + b: GET_VAR 'b: B of .IBase.foo declared in .Test2.foo' type=B of .IBase.foo origin=null + PROPERTY DELEGATED_MEMBER name:id visibility:public modality:OPEN [val] + FUN DELEGATED_MEMBER name: visibility:public modality:OPEN <> ($this:.Test2) returnType:kotlin.collections.Map.IBase, C of .IBase.>? + correspondingProperty: PROPERTY DELEGATED_MEMBER name:id visibility:public modality:OPEN [val] overridden: public abstract fun (): kotlin.collections.Map.IBase, C of .IBase.>? declared in .IBase - TYPE_PARAMETER name:C index:0 variance: superTypes:[kotlin.Any?] - $this: VALUE_PARAMETER name: type:.IBase.IBase> - PROPERTY FAKE_OVERRIDE name:x visibility:public modality:ABSTRACT [fake_override,var] - FUN FAKE_OVERRIDE name: visibility:public modality:ABSTRACT ($this:.IBase.IBase>) returnType:D of .Test2.? [fake_override] - correspondingProperty: PROPERTY FAKE_OVERRIDE name:x visibility:public modality:ABSTRACT [fake_override,var] + $this: VALUE_PARAMETER DELEGATED_MEMBER name: type:.Test2 + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun (): kotlin.collections.Map.IBase, C of .IBase.>? declared in .Test2' + CALL 'public abstract fun (): kotlin.collections.Map.IBase, C of .IBase.>? declared in .IBase' type=kotlin.collections.Map.IBase, C of .IBase.>? origin=null + : + $this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:.IBase visibility:local [final]' type=.IBase origin=null + receiver: GET_VAR ': .Test2 declared in .Test2.' type=.Test2 origin=null + PROPERTY DELEGATED_MEMBER name:x visibility:public modality:OPEN [var] + FUN DELEGATED_MEMBER name: visibility:public modality:OPEN <> ($this:.Test2) returnType:D of .IBase.? + correspondingProperty: PROPERTY DELEGATED_MEMBER name:x visibility:public modality:OPEN [var] overridden: public abstract fun (): D of .IBase.? declared in .IBase - TYPE_PARAMETER name:D index:0 variance: superTypes:[kotlin.Any?] - $this: VALUE_PARAMETER name: type:.IBase.IBase> - FUN FAKE_OVERRIDE name: visibility:public modality:ABSTRACT ($this:.IBase.IBase>, :D of .Test2.?) returnType:kotlin.Unit [fake_override] - correspondingProperty: PROPERTY FAKE_OVERRIDE name:x visibility:public modality:ABSTRACT [fake_override,var] + $this: VALUE_PARAMETER DELEGATED_MEMBER name: type:.Test2 + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun (): D of .IBase.? declared in .Test2' + CALL 'public abstract fun (): D of .IBase.? declared in .IBase' type=D of .IBase.? origin=null + : + $this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:.IBase visibility:local [final]' type=.IBase origin=null + receiver: GET_VAR ': .Test2 declared in .Test2.' type=.Test2 origin=null + FUN DELEGATED_MEMBER name: visibility:public modality:OPEN <> ($this:.Test2, :D of .IBase.?) returnType:kotlin.Unit + correspondingProperty: PROPERTY DELEGATED_MEMBER name:x visibility:public modality:OPEN [var] overridden: public abstract fun (: D of .IBase.?): kotlin.Unit declared in .IBase - TYPE_PARAMETER name:D index:0 variance: superTypes:[kotlin.Any?] - $this: VALUE_PARAMETER name: type:.IBase.IBase> - VALUE_PARAMETER name: index:0 type:D of .Test2.? + $this: VALUE_PARAMETER DELEGATED_MEMBER name: type:.Test2 + VALUE_PARAMETER DELEGATED_MEMBER name: index:0 type:D of .IBase.? + BLOCK_BODY + CALL 'public abstract fun (: D of .IBase.?): kotlin.Unit declared in .IBase' type=kotlin.Unit origin=null + : + $this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:.IBase visibility:local [final]' type=.IBase origin=null + receiver: GET_VAR ': .Test2 declared in .Test2.' type=.Test2 origin=null + : GET_VAR ': D of .IBase.? declared in .Test2.' type=D of .IBase.? origin=null + FIELD DELEGATE name:$$delegate_0 type:.IBase visibility:local [final] FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any diff --git a/compiler/testData/ir/irText/classes/delegatedImplementation.fir.txt b/compiler/testData/ir/irText/classes/delegatedImplementation.fir.txt index bd634bddc9a..f734c592f27 100644 --- a/compiler/testData/ir/irText/classes/delegatedImplementation.fir.txt +++ b/compiler/testData/ir/irText/classes/delegatedImplementation.fir.txt @@ -200,21 +200,39 @@ FILE fqName: fileName:/delegatedImplementation.kt BLOCK_BODY DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Test1 modality:FINAL visibility:public superTypes:[.IBase]' - FUN FAKE_OVERRIDE name:foo visibility:public modality:ABSTRACT <> ($this:.IBase, x:kotlin.Int, s:kotlin.String) returnType:kotlin.Unit [fake_override] + SET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:.IBase visibility:local [final]' type=kotlin.Unit origin=EQ + receiver: GET_VAR ': .Test1 declared in .Test1' type=.Test1 origin=null + value: GET_OBJECT 'CLASS OBJECT name:BaseImpl modality:FINAL visibility:public superTypes:[.IBase]' type=.BaseImpl + FUN DELEGATED_MEMBER name:foo visibility:public modality:OPEN <> ($this:.Test1, x:kotlin.Int, s:kotlin.String) returnType:kotlin.Unit overridden: public abstract fun foo (x: kotlin.Int, s: kotlin.String): kotlin.Unit declared in .IBase - $this: VALUE_PARAMETER name: type:.IBase - VALUE_PARAMETER name:x index:0 type:kotlin.Int - VALUE_PARAMETER name:s index:1 type:kotlin.String - FUN FAKE_OVERRIDE name:bar visibility:public modality:ABSTRACT <> ($this:.IBase) returnType:kotlin.Int [fake_override] + $this: VALUE_PARAMETER DELEGATED_MEMBER name: type:.Test1 + VALUE_PARAMETER DELEGATED_MEMBER name:x index:0 type:kotlin.Int + VALUE_PARAMETER DELEGATED_MEMBER name:s index:1 type:kotlin.String + BLOCK_BODY + CALL 'public abstract fun foo (x: kotlin.Int, s: kotlin.String): kotlin.Unit declared in .IBase' type=kotlin.Unit origin=null + $this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:.IBase visibility:local [final]' type=.IBase origin=null + receiver: GET_VAR ': .Test1 declared in .Test1.foo' type=.Test1 origin=null + x: GET_VAR 'x: kotlin.Int declared in .Test1.foo' type=kotlin.Int origin=null + s: GET_VAR 's: kotlin.String declared in .Test1.foo' type=kotlin.String origin=null + FUN DELEGATED_MEMBER name:bar visibility:public modality:OPEN <> ($this:.Test1) returnType:kotlin.Int overridden: public abstract fun bar (): kotlin.Int declared in .IBase - $this: VALUE_PARAMETER name: type:.IBase - FUN FAKE_OVERRIDE name:qux visibility:public modality:ABSTRACT <> ($this:.IBase, $receiver:kotlin.String) returnType:kotlin.Unit [fake_override] + $this: VALUE_PARAMETER DELEGATED_MEMBER name: type:.Test1 + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun bar (): kotlin.Int declared in .Test1' + CALL 'public abstract fun bar (): kotlin.Int declared in .IBase' type=kotlin.Int origin=null + $this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:.IBase visibility:local [final]' type=.IBase origin=null + receiver: GET_VAR ': .Test1 declared in .Test1.bar' type=.Test1 origin=null + FUN DELEGATED_MEMBER name:qux visibility:public modality:OPEN <> ($this:.Test1) returnType:kotlin.Unit overridden: public abstract fun qux (): kotlin.Unit declared in .IBase - $this: VALUE_PARAMETER name: type:.IBase - $receiver: VALUE_PARAMETER name: type:kotlin.String + $this: VALUE_PARAMETER DELEGATED_MEMBER name: type:.Test1 + BLOCK_BODY + CALL 'public abstract fun qux (): kotlin.Unit declared in .IBase' type=kotlin.Unit origin=null + $this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:.IBase visibility:local [final]' type=.IBase origin=null + receiver: GET_VAR ': .Test1 declared in .Test1.qux' type=.Test1 origin=null + FIELD DELEGATE name:$$delegate_0 type:.IBase visibility:local [final] FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any @@ -234,21 +252,111 @@ FILE fqName: fileName:/delegatedImplementation.kt BLOCK_BODY DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Test2 modality:FINAL visibility:public superTypes:[.IBase; .IOther]' - FUN FAKE_OVERRIDE name:foo visibility:public modality:ABSTRACT <> ($this:.IBase, x:kotlin.Int, s:kotlin.String) returnType:kotlin.Unit [fake_override] + SET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:.IBase visibility:local [final]' type=kotlin.Unit origin=EQ + receiver: GET_VAR ': .Test2 declared in .Test2' type=.Test2 origin=null + value: GET_OBJECT 'CLASS OBJECT name:BaseImpl modality:FINAL visibility:public superTypes:[.IBase]' type=.BaseImpl + SET_FIELD 'FIELD DELEGATE name:$$delegate_1 type:.IOther visibility:local [final]' type=kotlin.Unit origin=EQ + receiver: GET_VAR ': .Test2 declared in .Test2' type=.Test2 origin=null + value: CALL 'public final fun otherImpl (x0: kotlin.String, y0: kotlin.Int): .IOther declared in ' type=.IOther origin=null + x0: CONST String type=kotlin.String value="" + y0: CONST Int type=kotlin.Int value=42 + FUN DELEGATED_MEMBER name:foo visibility:public modality:OPEN <> ($this:.Test2, x:kotlin.Int, s:kotlin.String) returnType:kotlin.Unit overridden: public abstract fun foo (x: kotlin.Int, s: kotlin.String): kotlin.Unit declared in .IBase - $this: VALUE_PARAMETER name: type:.IBase - VALUE_PARAMETER name:x index:0 type:kotlin.Int - VALUE_PARAMETER name:s index:1 type:kotlin.String - FUN FAKE_OVERRIDE name:bar visibility:public modality:ABSTRACT <> ($this:.IBase) returnType:kotlin.Int [fake_override] + $this: VALUE_PARAMETER DELEGATED_MEMBER name: type:.Test2 + VALUE_PARAMETER DELEGATED_MEMBER name:x index:0 type:kotlin.Int + VALUE_PARAMETER DELEGATED_MEMBER name:s index:1 type:kotlin.String + BLOCK_BODY + CALL 'public abstract fun foo (x: kotlin.Int, s: kotlin.String): kotlin.Unit declared in .IBase' type=kotlin.Unit origin=null + $this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:.IBase visibility:local [final]' type=.IBase origin=null + receiver: GET_VAR ': .Test2 declared in .Test2.foo' type=.Test2 origin=null + x: GET_VAR 'x: kotlin.Int declared in .Test2.foo' type=kotlin.Int origin=null + s: GET_VAR 's: kotlin.String declared in .Test2.foo' type=kotlin.String origin=null + FUN DELEGATED_MEMBER name:bar visibility:public modality:OPEN <> ($this:.Test2) returnType:kotlin.Int overridden: public abstract fun bar (): kotlin.Int declared in .IBase - $this: VALUE_PARAMETER name: type:.IBase - FUN FAKE_OVERRIDE name:qux visibility:public modality:ABSTRACT <> ($this:.IBase, $receiver:kotlin.String) returnType:kotlin.Unit [fake_override] + $this: VALUE_PARAMETER DELEGATED_MEMBER name: type:.Test2 + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun bar (): kotlin.Int declared in .Test2' + CALL 'public abstract fun bar (): kotlin.Int declared in .IBase' type=kotlin.Int origin=null + $this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:.IBase visibility:local [final]' type=.IBase origin=null + receiver: GET_VAR ': .Test2 declared in .Test2.bar' type=.Test2 origin=null + FUN DELEGATED_MEMBER name:qux visibility:public modality:OPEN <> ($this:.Test2) returnType:kotlin.Unit overridden: public abstract fun qux (): kotlin.Unit declared in .IBase - $this: VALUE_PARAMETER name: type:.IBase - $receiver: VALUE_PARAMETER name: type:kotlin.String + $this: VALUE_PARAMETER DELEGATED_MEMBER name: type:.Test2 + BLOCK_BODY + CALL 'public abstract fun qux (): kotlin.Unit declared in .IBase' type=kotlin.Unit origin=null + $this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:.IBase visibility:local [final]' type=.IBase origin=null + receiver: GET_VAR ': .Test2 declared in .Test2.qux' type=.Test2 origin=null + FIELD DELEGATE name:$$delegate_0 type:.IBase visibility:local [final] + PROPERTY DELEGATED_MEMBER name:x visibility:public modality:OPEN [val] + FUN DELEGATED_MEMBER name: visibility:public modality:OPEN <> ($this:.Test2) returnType:kotlin.String + correspondingProperty: PROPERTY DELEGATED_MEMBER name:x visibility:public modality:OPEN [val] + overridden: + public abstract fun (): kotlin.String declared in .IOther + $this: VALUE_PARAMETER DELEGATED_MEMBER name: type:.Test2 + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun (): kotlin.String declared in .Test2' + CALL 'public abstract fun (): kotlin.String declared in .IOther' type=kotlin.String origin=null + $this: GET_FIELD 'FIELD DELEGATE name:$$delegate_1 type:.IOther visibility:local [final]' type=.IOther origin=null + receiver: GET_VAR ': .Test2 declared in .Test2.' type=.Test2 origin=null + PROPERTY DELEGATED_MEMBER name:y visibility:public modality:OPEN [var] + FUN DELEGATED_MEMBER name: visibility:public modality:OPEN <> ($this:.Test2) returnType:kotlin.Int + correspondingProperty: PROPERTY DELEGATED_MEMBER name:y visibility:public modality:OPEN [var] + overridden: + public abstract fun (): kotlin.Int declared in .IOther + $this: VALUE_PARAMETER DELEGATED_MEMBER name: type:.Test2 + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun (): kotlin.Int declared in .Test2' + CALL 'public abstract fun (): kotlin.Int declared in .IOther' type=kotlin.Int origin=null + $this: GET_FIELD 'FIELD DELEGATE name:$$delegate_1 type:.IOther visibility:local [final]' type=.IOther origin=null + receiver: GET_VAR ': .Test2 declared in .Test2.' type=.Test2 origin=null + FUN DELEGATED_MEMBER name: visibility:public modality:OPEN <> ($this:.Test2, :kotlin.Int) returnType:kotlin.Unit + correspondingProperty: PROPERTY DELEGATED_MEMBER name:y visibility:public modality:OPEN [var] + overridden: + public abstract fun (: kotlin.Int): kotlin.Unit declared in .IOther + $this: VALUE_PARAMETER DELEGATED_MEMBER name: type:.Test2 + VALUE_PARAMETER DELEGATED_MEMBER name: index:0 type:kotlin.Int + BLOCK_BODY + CALL 'public abstract fun (: kotlin.Int): kotlin.Unit declared in .IOther' type=kotlin.Unit origin=null + $this: GET_FIELD 'FIELD DELEGATE name:$$delegate_1 type:.IOther visibility:local [final]' type=.IOther origin=null + receiver: GET_VAR ': .Test2 declared in .Test2.' type=.Test2 origin=null + : GET_VAR ': kotlin.Int declared in .Test2.' type=kotlin.Int origin=null + PROPERTY DELEGATED_MEMBER name:z1 visibility:public modality:OPEN [val] + FUN DELEGATED_MEMBER name: visibility:public modality:OPEN <> ($this:.Test2) returnType:kotlin.Int + correspondingProperty: PROPERTY DELEGATED_MEMBER name:z1 visibility:public modality:OPEN [val] + overridden: + public abstract fun (): kotlin.Int declared in .IOther + $this: VALUE_PARAMETER DELEGATED_MEMBER name: type:.Test2 + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun (): kotlin.Int declared in .Test2' + CALL 'public abstract fun (): kotlin.Int declared in .IOther' type=kotlin.Int origin=null + $this: GET_FIELD 'FIELD DELEGATE name:$$delegate_1 type:.IOther visibility:local [final]' type=.IOther origin=null + receiver: GET_VAR ': .Test2 declared in .Test2.' type=.Test2 origin=null + PROPERTY DELEGATED_MEMBER name:z2 visibility:public modality:OPEN [var] + FUN DELEGATED_MEMBER name: visibility:public modality:OPEN <> ($this:.Test2) returnType:kotlin.Int + correspondingProperty: PROPERTY DELEGATED_MEMBER name:z2 visibility:public modality:OPEN [var] + overridden: + public abstract fun (): kotlin.Int declared in .IOther + $this: VALUE_PARAMETER DELEGATED_MEMBER name: type:.Test2 + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun (): kotlin.Int declared in .Test2' + CALL 'public abstract fun (): kotlin.Int declared in .IOther' type=kotlin.Int origin=null + $this: GET_FIELD 'FIELD DELEGATE name:$$delegate_1 type:.IOther visibility:local [final]' type=.IOther origin=null + receiver: GET_VAR ': .Test2 declared in .Test2.' type=.Test2 origin=null + FUN DELEGATED_MEMBER name: visibility:public modality:OPEN <> ($this:.Test2, :kotlin.Int) returnType:kotlin.Unit + correspondingProperty: PROPERTY DELEGATED_MEMBER name:z2 visibility:public modality:OPEN [var] + overridden: + public abstract fun (: kotlin.Int): kotlin.Unit declared in .IOther + $this: VALUE_PARAMETER DELEGATED_MEMBER name: type:.Test2 + VALUE_PARAMETER DELEGATED_MEMBER name: index:0 type:kotlin.Int + BLOCK_BODY + CALL 'public abstract fun (: kotlin.Int): kotlin.Unit declared in .IOther' type=kotlin.Unit origin=null + $this: GET_FIELD 'FIELD DELEGATE name:$$delegate_1 type:.IOther visibility:local [final]' type=.IOther origin=null + receiver: GET_VAR ': .Test2 declared in .Test2.' type=.Test2 origin=null + : GET_VAR ': kotlin.Int declared in .Test2.' type=kotlin.Int origin=null + FIELD DELEGATE name:$$delegate_1 type:.IOther visibility:local [final] FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any @@ -262,39 +370,3 @@ FILE fqName: fileName:/delegatedImplementation.kt overridden: public open fun toString (): kotlin.String declared in kotlin.Any $this: VALUE_PARAMETER name: type:kotlin.Any - PROPERTY FAKE_OVERRIDE name:x visibility:public modality:ABSTRACT [fake_override,val] - FUN FAKE_OVERRIDE name: visibility:public modality:ABSTRACT <> ($this:.IOther) returnType:kotlin.String [fake_override] - correspondingProperty: PROPERTY FAKE_OVERRIDE name:x visibility:public modality:ABSTRACT [fake_override,val] - overridden: - public abstract fun (): kotlin.String declared in .IOther - $this: VALUE_PARAMETER name: type:.IOther - PROPERTY FAKE_OVERRIDE name:y visibility:public modality:ABSTRACT [fake_override,var] - FUN FAKE_OVERRIDE name: visibility:public modality:ABSTRACT <> ($this:.IOther) returnType:kotlin.Int [fake_override] - correspondingProperty: PROPERTY FAKE_OVERRIDE name:y visibility:public modality:ABSTRACT [fake_override,var] - overridden: - public abstract fun (): kotlin.Int declared in .IOther - $this: VALUE_PARAMETER name: type:.IOther - FUN FAKE_OVERRIDE name: visibility:public modality:ABSTRACT <> ($this:.IOther, :kotlin.Int) returnType:kotlin.Unit [fake_override] - correspondingProperty: PROPERTY FAKE_OVERRIDE name:y visibility:public modality:ABSTRACT [fake_override,var] - overridden: - public abstract fun (: kotlin.Int): kotlin.Unit declared in .IOther - $this: VALUE_PARAMETER name: type:.IOther - VALUE_PARAMETER name: index:0 type:kotlin.Int - PROPERTY FAKE_OVERRIDE name:z1 visibility:public modality:ABSTRACT [fake_override,val] - FUN FAKE_OVERRIDE name: visibility:public modality:ABSTRACT <> ($this:.IOther) returnType:kotlin.Int [fake_override] - correspondingProperty: PROPERTY FAKE_OVERRIDE name:z1 visibility:public modality:ABSTRACT [fake_override,val] - overridden: - public abstract fun (): kotlin.Int declared in .IOther - $this: VALUE_PARAMETER name: type:.IOther - PROPERTY FAKE_OVERRIDE name:z2 visibility:public modality:ABSTRACT [fake_override,var] - FUN FAKE_OVERRIDE name: visibility:public modality:ABSTRACT <> ($this:.IOther) returnType:kotlin.Int [fake_override] - correspondingProperty: PROPERTY FAKE_OVERRIDE name:z2 visibility:public modality:ABSTRACT [fake_override,var] - overridden: - public abstract fun (): kotlin.Int declared in .IOther - $this: VALUE_PARAMETER name: type:.IOther - FUN FAKE_OVERRIDE name: visibility:public modality:ABSTRACT <> ($this:.IOther, :kotlin.Int) returnType:kotlin.Unit [fake_override] - correspondingProperty: PROPERTY FAKE_OVERRIDE name:z2 visibility:public modality:ABSTRACT [fake_override,var] - overridden: - public abstract fun (: kotlin.Int): kotlin.Unit declared in .IOther - $this: VALUE_PARAMETER name: type:.IOther - VALUE_PARAMETER name: index:0 type:kotlin.Int diff --git a/compiler/testData/ir/irText/classes/delegatedImplementationWithExplicitOverride.fir.txt b/compiler/testData/ir/irText/classes/delegatedImplementationWithExplicitOverride.fir.txt index af4196370d7..b6a1c6158fb 100644 --- a/compiler/testData/ir/irText/classes/delegatedImplementationWithExplicitOverride.fir.txt +++ b/compiler/testData/ir/irText/classes/delegatedImplementationWithExplicitOverride.fir.txt @@ -53,15 +53,23 @@ FILE fqName: fileName:/delegatedImplementationWithExplicitOverride.kt BLOCK_BODY DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:C modality:FINAL visibility:public superTypes:[.IFooBar]' + SET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:.IFooBar visibility:local [final]' type=kotlin.Unit origin=EQ + receiver: GET_VAR ': .C declared in .C' type=.C origin=null + value: GET_OBJECT 'CLASS OBJECT name:FooBarImpl modality:FINAL visibility:public superTypes:[.IFooBar]' type=.FooBarImpl FUN name:bar visibility:public modality:FINAL <> ($this:.C) returnType:kotlin.Unit overridden: public abstract fun bar (): kotlin.Unit declared in .IFooBar $this: VALUE_PARAMETER name: type:.C BLOCK_BODY - FUN FAKE_OVERRIDE name:foo visibility:public modality:ABSTRACT <> ($this:.IFooBar) returnType:kotlin.Unit [fake_override] + FUN DELEGATED_MEMBER name:foo visibility:public modality:OPEN <> ($this:.C) returnType:kotlin.Unit overridden: public abstract fun foo (): kotlin.Unit declared in .IFooBar - $this: VALUE_PARAMETER name: type:.IFooBar + $this: VALUE_PARAMETER DELEGATED_MEMBER name: type:.C + BLOCK_BODY + CALL 'public abstract fun foo (): kotlin.Unit declared in .IFooBar' type=kotlin.Unit origin=null + $this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:.IFooBar visibility:local [final]' type=.IFooBar origin=null + receiver: GET_VAR ': .C declared in .C.foo' type=.C origin=null + FIELD DELEGATE name:$$delegate_0 type:.IFooBar visibility:local [final] FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any diff --git a/compiler/testData/ir/irText/classes/implicitNotNullOnDelegatedImplementation.fir.txt b/compiler/testData/ir/irText/classes/implicitNotNullOnDelegatedImplementation.fir.txt index dfce6019233..b5deaa2de8b 100644 --- a/compiler/testData/ir/irText/classes/implicitNotNullOnDelegatedImplementation.fir.txt +++ b/compiler/testData/ir/irText/classes/implicitNotNullOnDelegatedImplementation.fir.txt @@ -123,10 +123,19 @@ FILE fqName: fileName:/implicitNotNullOnDelegatedImplementation.kt BLOCK_BODY DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:TestJFoo modality:FINAL visibility:public superTypes:[.IFoo]' - FUN FAKE_OVERRIDE name:foo visibility:public modality:ABSTRACT <> ($this:.IFoo) returnType:kotlin.String [fake_override] + SET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:.IFoo visibility:local [final]' type=kotlin.Unit origin=EQ + receiver: GET_VAR ': .TestJFoo declared in .TestJFoo' type=.TestJFoo origin=null + value: CONSTRUCTOR_CALL 'public constructor () [primary] declared in .JFoo' type=.JFoo origin=null + FUN DELEGATED_MEMBER name:foo visibility:public modality:OPEN <> ($this:.TestJFoo) returnType:kotlin.String overridden: public abstract fun foo (): kotlin.String declared in .IFoo - $this: VALUE_PARAMETER name: type:.IFoo + $this: VALUE_PARAMETER DELEGATED_MEMBER name: type:.TestJFoo + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun foo (): kotlin.String declared in .TestJFoo' + CALL 'public abstract fun foo (): kotlin.String declared in .IFoo' type=kotlin.String origin=null + $this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:.IFoo visibility:local [final]' type=.IFoo origin=null + receiver: GET_VAR ': .TestJFoo declared in .TestJFoo.foo' type=.TestJFoo origin=null + FIELD DELEGATE name:$$delegate_0 type:.IFoo visibility:local [final] FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any @@ -146,10 +155,19 @@ FILE fqName: fileName:/implicitNotNullOnDelegatedImplementation.kt BLOCK_BODY DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:TestK1 modality:FINAL visibility:public superTypes:[.IFoo]' - FUN FAKE_OVERRIDE name:foo visibility:public modality:ABSTRACT <> ($this:.IFoo) returnType:kotlin.String [fake_override] + SET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:.IFoo visibility:local [final]' type=kotlin.Unit origin=EQ + receiver: GET_VAR ': .TestK1 declared in .TestK1' type=.TestK1 origin=null + value: CONSTRUCTOR_CALL 'public constructor () [primary] declared in .K1' type=.K1 origin=null + FUN DELEGATED_MEMBER name:foo visibility:public modality:OPEN <> ($this:.TestK1) returnType:kotlin.String overridden: public abstract fun foo (): kotlin.String declared in .IFoo - $this: VALUE_PARAMETER name: type:.IFoo + $this: VALUE_PARAMETER DELEGATED_MEMBER name: type:.TestK1 + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun foo (): kotlin.String declared in .TestK1' + CALL 'public abstract fun foo (): kotlin.String declared in .IFoo' type=kotlin.String origin=null + $this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:.IFoo visibility:local [final]' type=.IFoo origin=null + receiver: GET_VAR ': .TestK1 declared in .TestK1.foo' type=.TestK1 origin=null + FIELD DELEGATE name:$$delegate_0 type:.IFoo visibility:local [final] FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any @@ -169,10 +187,19 @@ FILE fqName: fileName:/implicitNotNullOnDelegatedImplementation.kt BLOCK_BODY DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:TestK2 modality:FINAL visibility:public superTypes:[.IFoo]' - FUN FAKE_OVERRIDE name:foo visibility:public modality:ABSTRACT <> ($this:.IFoo) returnType:kotlin.String [fake_override] + SET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:.IFoo visibility:local [final]' type=kotlin.Unit origin=EQ + receiver: GET_VAR ': .TestK2 declared in .TestK2' type=.TestK2 origin=null + value: CONSTRUCTOR_CALL 'public constructor () [primary] declared in .K2' type=.K2 origin=null + FUN DELEGATED_MEMBER name:foo visibility:public modality:OPEN <> ($this:.TestK2) returnType:kotlin.String overridden: public abstract fun foo (): kotlin.String declared in .IFoo - $this: VALUE_PARAMETER name: type:.IFoo + $this: VALUE_PARAMETER DELEGATED_MEMBER name: type:.TestK2 + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun foo (): kotlin.String declared in .TestK2' + CALL 'public abstract fun foo (): kotlin.String declared in .IFoo' type=kotlin.String origin=null + $this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:.IFoo visibility:local [final]' type=.IFoo origin=null + receiver: GET_VAR ': .TestK2 declared in .TestK2.foo' type=.TestK2 origin=null + FIELD DELEGATE name:$$delegate_0 type:.IFoo visibility:local [final] FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any @@ -192,10 +219,19 @@ FILE fqName: fileName:/implicitNotNullOnDelegatedImplementation.kt BLOCK_BODY DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:TestK3 modality:FINAL visibility:public superTypes:[.IFoo]' - FUN FAKE_OVERRIDE name:foo visibility:public modality:ABSTRACT <> ($this:.IFoo) returnType:kotlin.String [fake_override] + SET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:.IFoo visibility:local [final]' type=kotlin.Unit origin=EQ + receiver: GET_VAR ': .TestK3 declared in .TestK3' type=.TestK3 origin=null + value: CONSTRUCTOR_CALL 'public constructor () [primary] declared in .K3' type=.K3 origin=null + FUN DELEGATED_MEMBER name:foo visibility:public modality:OPEN <> ($this:.TestK3) returnType:kotlin.String overridden: public abstract fun foo (): kotlin.String declared in .IFoo - $this: VALUE_PARAMETER name: type:.IFoo + $this: VALUE_PARAMETER DELEGATED_MEMBER name: type:.TestK3 + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun foo (): kotlin.String declared in .TestK3' + CALL 'public abstract fun foo (): kotlin.String declared in .IFoo' type=kotlin.String origin=null + $this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:.IFoo visibility:local [final]' type=.IFoo origin=null + receiver: GET_VAR ': .TestK3 declared in .TestK3.foo' type=.TestK3 origin=null + FIELD DELEGATE name:$$delegate_0 type:.IFoo visibility:local [final] FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any @@ -215,10 +251,19 @@ FILE fqName: fileName:/implicitNotNullOnDelegatedImplementation.kt BLOCK_BODY DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:TestK4 modality:FINAL visibility:public superTypes:[.IFoo]' - FUN FAKE_OVERRIDE name:foo visibility:public modality:ABSTRACT <> ($this:.IFoo) returnType:kotlin.String [fake_override] + SET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:.IFoo visibility:local [final]' type=kotlin.Unit origin=EQ + receiver: GET_VAR ': .TestK4 declared in .TestK4' type=.TestK4 origin=null + value: CONSTRUCTOR_CALL 'public constructor () [primary] declared in .K4' type=.K4 origin=null + FUN DELEGATED_MEMBER name:foo visibility:public modality:OPEN <> ($this:.TestK4) returnType:kotlin.String overridden: public abstract fun foo (): kotlin.String declared in .IFoo - $this: VALUE_PARAMETER name: type:.IFoo + $this: VALUE_PARAMETER DELEGATED_MEMBER name: type:.TestK4 + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun foo (): kotlin.String declared in .TestK4' + CALL 'public abstract fun foo (): kotlin.String declared in .IFoo' type=kotlin.String origin=null + $this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:.IFoo visibility:local [final]' type=.IFoo origin=null + receiver: GET_VAR ': .TestK4 declared in .TestK4.foo' type=.TestK4 origin=null + FIELD DELEGATE name:$$delegate_0 type:.IFoo visibility:local [final] FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any diff --git a/compiler/testData/ir/irText/declarations/kt35550.fir.txt b/compiler/testData/ir/irText/declarations/kt35550.fir.txt index e3228c73ed2..8fb040c1089 100644 --- a/compiler/testData/ir/irText/declarations/kt35550.fir.txt +++ b/compiler/testData/ir/irText/declarations/kt35550.fir.txt @@ -30,12 +30,22 @@ FILE fqName: fileName:/kt35550.kt BLOCK_BODY DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:A modality:FINAL visibility:public superTypes:[.I]' - PROPERTY FAKE_OVERRIDE name:id visibility:public modality:OPEN [fake_override,val] - FUN FAKE_OVERRIDE name: visibility:public modality:OPEN <> ($this:.I) returnType:T of .I. [fake_override] - correspondingProperty: PROPERTY FAKE_OVERRIDE name:id visibility:public modality:OPEN [fake_override,val] + SET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:.I visibility:local [final]' type=kotlin.Unit origin=EQ + receiver: GET_VAR ': .A declared in .A' type=.A origin=null + value: GET_VAR 'i: .I declared in .A.' type=.I origin=null + PROPERTY DELEGATED_MEMBER name:id visibility:public modality:OPEN [val] + FUN DELEGATED_MEMBER name: visibility:public modality:OPEN <> ($this:.A) returnType:T of .I. + correspondingProperty: PROPERTY DELEGATED_MEMBER name:id visibility:public modality:OPEN [val] overridden: public open fun (): T of .I. declared in .I - $this: VALUE_PARAMETER name: type:.I + $this: VALUE_PARAMETER DELEGATED_MEMBER name: type:.A + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun (): T of .I. declared in .A' + CALL 'public open fun (): T of .I. declared in .I' type=T of .I. origin=null + : + $this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:.I visibility:local [final]' type=.I origin=null + receiver: GET_VAR ': .A declared in .A.' type=.A origin=null + FIELD DELEGATE name:$$delegate_0 type:.I visibility:local [final] FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any diff --git a/compiler/testData/ir/irText/declarations/parameters/delegatedMembers.fir.txt b/compiler/testData/ir/irText/declarations/parameters/delegatedMembers.fir.txt index 10838c93c8a..853e4d287c0 100644 --- a/compiler/testData/ir/irText/declarations/parameters/delegatedMembers.fir.txt +++ b/compiler/testData/ir/irText/declarations/parameters/delegatedMembers.fir.txt @@ -35,24 +35,44 @@ FILE fqName: fileName:/delegatedMembers.kt BLOCK_BODY DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Test modality:FINAL visibility:public superTypes:[.IBase.Test>]' - FUN FAKE_OVERRIDE name:foo visibility:public modality:ABSTRACT <> ($this:.IBase.IBase>, x:kotlin.Int) returnType:kotlin.Unit [fake_override] + SET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:.IBase.Test> visibility:local [final]' type=kotlin.Unit origin=EQ + receiver: GET_VAR ': .Test.Test> declared in .Test' type=.Test.Test> origin=null + value: GET_VAR 'impl: .IBase.Test> declared in .Test.' type=.IBase.Test> origin=null + FUN DELEGATED_MEMBER name:foo visibility:public modality:OPEN <> ($this:.Test.Test>, x:kotlin.Int) returnType:kotlin.Unit overridden: public abstract fun foo (x: kotlin.Int): kotlin.Unit declared in .IBase - $this: VALUE_PARAMETER name: type:.IBase.IBase> - VALUE_PARAMETER name:x index:0 type:kotlin.Int - PROPERTY FAKE_OVERRIDE name:bar visibility:public modality:ABSTRACT [fake_override,val] - FUN FAKE_OVERRIDE name: visibility:public modality:ABSTRACT <> ($this:.IBase.IBase>) returnType:kotlin.Int [fake_override] - correspondingProperty: PROPERTY FAKE_OVERRIDE name:bar visibility:public modality:ABSTRACT [fake_override,val] + $this: VALUE_PARAMETER DELEGATED_MEMBER name: type:.Test.Test> + VALUE_PARAMETER DELEGATED_MEMBER name:x index:0 type:kotlin.Int + BLOCK_BODY + CALL 'public abstract fun foo (x: kotlin.Int): kotlin.Unit declared in .IBase' type=kotlin.Unit origin=null + $this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:.IBase.Test> visibility:local [final]' type=.IBase.Test> origin=null + receiver: GET_VAR ': .Test.Test> declared in .Test.foo' type=.Test.Test> origin=null + x: GET_VAR 'x: kotlin.Int declared in .Test.foo' type=kotlin.Int origin=null + PROPERTY DELEGATED_MEMBER name:bar visibility:public modality:OPEN [val] + FUN DELEGATED_MEMBER name: visibility:public modality:OPEN <> ($this:.Test.Test>) returnType:kotlin.Int + correspondingProperty: PROPERTY DELEGATED_MEMBER name:bar visibility:public modality:OPEN [val] overridden: public abstract fun (): kotlin.Int declared in .IBase - $this: VALUE_PARAMETER name: type:.IBase.IBase> - FUN FAKE_OVERRIDE name:qux visibility:public modality:ABSTRACT ($this:.IBase.IBase>, t:TT of .Test, x:X of .Test.qux) returnType:kotlin.Unit [fake_override] + $this: VALUE_PARAMETER DELEGATED_MEMBER name: type:.Test.Test> + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun (): kotlin.Int declared in .Test' + CALL 'public abstract fun (): kotlin.Int declared in .IBase' type=kotlin.Int origin=null + $this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:.IBase.Test> visibility:local [final]' type=.IBase.Test> origin=null + receiver: GET_VAR ': .Test.Test> declared in .Test.' type=.Test.Test> origin=null + FUN DELEGATED_MEMBER name:qux visibility:public modality:OPEN <> ($this:.Test.Test>, t:T of .IBase, x:X of .IBase.qux) returnType:kotlin.Unit overridden: public abstract fun qux (t: T of .IBase, x: X of .IBase.qux): kotlin.Unit declared in .IBase - TYPE_PARAMETER name:X index:0 variance: superTypes:[kotlin.Any?] - $this: VALUE_PARAMETER name: type:.IBase.IBase> - VALUE_PARAMETER name:t index:0 type:TT of .Test - VALUE_PARAMETER name:x index:1 type:X of .Test.qux + $this: VALUE_PARAMETER DELEGATED_MEMBER name: type:.Test.Test> + VALUE_PARAMETER DELEGATED_MEMBER name:t index:0 type:T of .IBase + VALUE_PARAMETER DELEGATED_MEMBER name:x index:1 type:X of .IBase.qux + BLOCK_BODY + CALL 'public abstract fun qux (t: T of .IBase, x: X of .IBase.qux): kotlin.Unit declared in .IBase' type=kotlin.Unit origin=null + : + $this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:.IBase.Test> visibility:local [final]' type=.IBase.Test> origin=null + receiver: GET_VAR ': .Test.Test> declared in .Test.qux' type=.Test.Test> origin=null + t: GET_VAR 't: T of .IBase declared in .Test.qux' type=T of .IBase origin=null + x: GET_VAR 'x: X of .IBase.qux declared in .Test.qux' type=X of .IBase.qux origin=null + FIELD DELEGATE name:$$delegate_0 type:.IBase.Test> visibility:local [final] FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any