From 213f951da3f5fb853715b8e09c9c7187f0a4bb3f Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Thu, 11 Jul 2019 19:21:11 +0300 Subject: [PATCH] FIR: partial implementation of delegate resolve #KT-32217 Fixed --- .../kotlin/fir/symbols/StandardClassIds.kt | 4 + .../jetbrains/kotlin/fir/dump/HtmlFirDump.kt | 2 +- .../kotlin/fir/backend/ConversionUtils.kt | 7 +- .../fir/backend/Fir2IrDeclarationStorage.kt | 14 +++ .../kotlin/fir/backend/Fir2IrVisitor.kt | 93 ++++++++++++++----- .../fir/java/declarations/FirJavaField.kt | 9 ++ .../kotlin/fir/builder/ConversionUtils.kt | 78 +++++++++++++++- .../kotlin/fir/builder/RawFirBuilder.kt | 18 ++-- .../deserialization/FirMemberDeserializer.kt | 8 +- .../kotlin/fir/resolve/calls/Synthetics.kt | 7 +- .../transformers/FirBodyResolveTransformer.kt | 57 ++++++------ .../FirStatusResolveTransformer.kt | 2 +- .../resolve/stdlib/simpleDelegatedToMap.kt | 5 + .../resolve/stdlib/simpleDelegatedToMap.txt | 25 +++++ .../testData/resolve/stdlib/simpleLazy.kt | 9 ++ .../testData/resolve/stdlib/simpleLazy.txt | 16 ++++ ...FirResolveTestCaseWithStdlibGenerated.java | 10 ++ .../kotlin/fir/FirDelegateFieldReference.kt | 25 +++++ .../org/jetbrains/kotlin/fir/FirRenderer.kt | 10 +- .../kotlin/fir/declarations/FirProperty.kt | 9 +- .../fir/declarations/FirValueParameter.kt | 5 + .../impl/FirDefaultSetterValueParameter.kt | 3 + .../impl/FirMemberPropertyImpl.kt | 16 +++- .../impl/FirModifiableAccessorsOwner.kt | 17 ++++ .../impl/FirValueParameterImpl.kt | 3 + .../fir/declarations/impl/FirVariableImpl.kt | 25 ++++- .../kotlin/fir/expressions/FirVariable.kt | 12 +++ .../FirDelegateFieldReferenceImpl.kt | 18 ++++ .../fir/symbols/impl/FirVariableSymbol.kt | 6 ++ .../types/impl/FirImplicitBuiltinTypeRef.kt | 11 ++- .../fir/visitors/FirTransformerGenerated.kt | 8 ++ .../fir/visitors/FirVisitorGenerated.kt | 4 + .../fir/visitors/FirVisitorVoidGenerated.kt | 8 ++ .../delegateFieldWithAnnotations.fir.txt | 18 +++- ...edPropertyAccessorsWithAnnotations.fir.txt | 40 +++++--- ...DelegatedPropertiesWithAnnotations.fir.txt | 3 +- .../declarations/classLevelProperties.fir.txt | 41 +++++--- .../declarations/delegatedProperties.fir.txt | 81 ++++++++++------ .../localDelegatedProperties.fir.txt | 6 +- .../packageLevelProperties.fir.txt | 38 +++++--- .../differentReceivers.fir.txt | 30 ++++-- .../localDifferentReceivers.fir.txt | 6 +- .../provideDelegate/member.fir.txt | 12 ++- .../provideDelegate/memberExtension.fir.txt | 11 ++- .../provideDelegate/topLevel.fir.txt | 12 ++- .../boundCallableReferences.fir.txt | 7 +- .../callableRefToGenericMember.fir.txt | 6 +- ...lableReferenceToImportedFromObject.fir.txt | 9 +- .../callableReferenceTypeArguments.fir.txt | 6 +- .../expressions/genericPropertyRef.fir.txt | 30 ++++-- .../expressions/propertyReferences.fir.txt | 89 ++++++++++-------- .../expressions/reflectionLiterals.fir.txt | 6 +- .../expressions/sam/samConstructors.fir.txt | 2 +- .../sam/samConversionsWithSmartCasts.fir.txt | 2 +- .../expressions/sam/samOperators.fir.txt | 16 ++-- .../genericPropertyReferenceType.fir.txt | 4 +- 56 files changed, 753 insertions(+), 266 deletions(-) create mode 100644 compiler/fir/resolve/testData/resolve/stdlib/simpleDelegatedToMap.kt create mode 100644 compiler/fir/resolve/testData/resolve/stdlib/simpleDelegatedToMap.txt create mode 100644 compiler/fir/resolve/testData/resolve/stdlib/simpleLazy.kt create mode 100644 compiler/fir/resolve/testData/resolve/stdlib/simpleLazy.txt create mode 100644 compiler/fir/tree/src/org/jetbrains/kotlin/fir/FirDelegateFieldReference.kt create mode 100644 compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/impl/FirModifiableAccessorsOwner.kt create mode 100644 compiler/fir/tree/src/org/jetbrains/kotlin/fir/references/FirDelegateFieldReferenceImpl.kt diff --git a/compiler/fir/cones/src/org/jetbrains/kotlin/fir/symbols/StandardClassIds.kt b/compiler/fir/cones/src/org/jetbrains/kotlin/fir/symbols/StandardClassIds.kt index 51043112f4c..e374d181d91 100644 --- a/compiler/fir/cones/src/org/jetbrains/kotlin/fir/symbols/StandardClassIds.kt +++ b/compiler/fir/cones/src/org/jetbrains/kotlin/fir/symbols/StandardClassIds.kt @@ -12,7 +12,9 @@ import org.jetbrains.kotlin.name.Name object StandardClassIds { private val BASE_KOTLIN_PACKAGE = FqName("kotlin") + private val BASE_REFLECT_PACKAGE = BASE_KOTLIN_PACKAGE.child(Name.identifier("reflect")) private fun String.baseId() = ClassId(BASE_KOTLIN_PACKAGE, Name.identifier(this)) + private fun String.reflectId() = ClassId(BASE_REFLECT_PACKAGE, Name.identifier(this)) private fun Name.arrayId() = ClassId(Array.packageFqName, Name.identifier(identifier + Array.shortClassName.identifier)) val Nothing = "Nothing".baseId() @@ -33,6 +35,8 @@ object StandardClassIds { val String = "String".baseId() + val KProperty = "KProperty".reflectId() + fun byName(name: String) = name.baseId() val primitiveArrayTypeByElementType: Map = mutableMapOf().apply { diff --git a/compiler/fir/dump/src/org/jetbrains/kotlin/fir/dump/HtmlFirDump.kt b/compiler/fir/dump/src/org/jetbrains/kotlin/fir/dump/HtmlFirDump.kt index 2dbbf508df9..0c4e7af4c42 100644 --- a/compiler/fir/dump/src/org/jetbrains/kotlin/fir/dump/HtmlFirDump.kt +++ b/compiler/fir/dump/src/org/jetbrains/kotlin/fir/dump/HtmlFirDump.kt @@ -848,7 +848,7 @@ class HtmlFirDump internal constructor(private var linkResolver: FirLinkResolver } withIdentLevel { - generate(property.getter) + property.getter?.let { generate(it) } property.setter?.let { generate(it) } } } 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 aa97b6ec837..30d346776cf 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 @@ -107,7 +107,8 @@ fun FirNamedReference.toSymbol(declarationStorage: Fir2IrDeclarationStorage): Ir is FirFunctionSymbol<*> -> return callableSymbol.toFunctionSymbol(declarationStorage) is FirPropertySymbol -> return callableSymbol.toPropertyOrFieldSymbol(declarationStorage) is FirFieldSymbol -> return callableSymbol.toPropertyOrFieldSymbol(declarationStorage) - is FirBackingFieldSymbol -> return callableSymbol.toPropertyOrFieldSymbol(declarationStorage) + is FirBackingFieldSymbol -> return callableSymbol.toBackingFieldSymbol(declarationStorage) + is FirDelegateFieldSymbol<*> -> return callableSymbol.toBackingFieldSymbol(declarationStorage) is FirVariableSymbol<*> -> return callableSymbol.toValueSymbol(declarationStorage) } } @@ -130,6 +131,10 @@ fun FirVariableSymbol<*>.toPropertyOrFieldSymbol(declarationStorage: Fir2IrDecla return declarationStorage.getIrPropertyOrFieldSymbol(this) } +fun FirVariableSymbol<*>.toBackingFieldSymbol(declarationStorage: Fir2IrDeclarationStorage): IrSymbol { + return declarationStorage.getIrBackingFieldSymbol(this) +} + fun FirVariableSymbol<*>.toValueSymbol(declarationStorage: Fir2IrDeclarationStorage): IrValueSymbol { return declarationStorage.getIrValueSymbol(this) } 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 1939964b8ad..09ee4bce692 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 @@ -541,6 +541,20 @@ class Fir2IrDeclarationStorage( } } + fun getIrBackingFieldSymbol(firVariableSymbol: FirVariableSymbol<*>): IrSymbol { + return when (val fir = firVariableSymbol.fir) { + is FirProperty -> { + val irProperty = getIrProperty(fir).apply { + setAndModifyParent(findIrParent(fir)) + } + irSymbolTable.referenceField(irProperty.backingField!!.descriptor) + } + else -> { + getIrVariableSymbol(fir) + } + } + } + private fun getIrVariableSymbol(firVariable: FirVariable<*>): IrVariableSymbol { val irDeclaration = localStorage.getVariable(firVariable) ?: throw IllegalArgumentException("Cannot find variable ${firVariable.render()} in local storage") 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 6d31961b4d8..782c83e122d 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 @@ -456,8 +456,37 @@ internal class Fir2IrVisitor( } } + private fun IrProperty.createBackingField( + property: FirProperty, + origin: IrDeclarationOrigin, + descriptor: PropertyDescriptor, + visibility: Visibility, + name: Name, + isFinal: Boolean, + firInitializerExpression: FirExpression?, + type: IrType? = null + ): IrField { + val inferredType = type ?: firInitializerExpression!!.typeRef.toIrType(session, declarationStorage) + return symbolTable.declareField( + startOffset, endOffset, origin, descriptor, inferredType + ) { symbol -> + IrFieldImpl( + startOffset, endOffset, origin, symbol, + name, inferredType, + visibility, isFinal = isFinal, isExternal = false, + isStatic = property.isStatic || parent !is IrClass + ) + }.setParentByParentStack().withParent { + declarationStorage.enterScope(descriptor) + val initializerExpression = firInitializerExpression?.toIrExpression() + this.initializer = initializerExpression?.let { IrExpressionBodyImpl(it) } + declarationStorage.leaveScope(descriptor) + } + } + private fun IrProperty.setPropertyContent(descriptor: PropertyDescriptor, property: FirProperty): IrProperty { val initializer = property.initializer + val delegate = property.delegate val irParent = this.parent val type = property.returnTypeRef.toIrType(session, declarationStorage) // TODO: this checks are very preliminary, FIR resolve should determine backing field presence itself @@ -465,27 +494,20 @@ internal class Fir2IrVisitor( if (initializer != null || property.getter is FirDefaultPropertyGetter || property.isVar && property.setter is FirDefaultPropertySetter ) { - val backingOrigin = IrDeclarationOrigin.PROPERTY_BACKING_FIELD - backingField = symbolTable.declareField( - startOffset, endOffset, backingOrigin, descriptor, type - ) { symbol -> - IrFieldImpl( - startOffset, endOffset, backingOrigin, symbol, - property.name, type, property.visibility, - isFinal = property.isVal, isExternal = false, - isStatic = property.isStatic || irParent !is IrClass - ) - }.setParentByParentStack().withParent { - declarationStorage.enterScope(descriptor) - val initializerExpression = initializer?.toIrExpression() - this.initializer = initializerExpression?.let { IrExpressionBodyImpl(it) } - declarationStorage.leaveScope(descriptor) - } + backingField = createBackingField( + property, IrDeclarationOrigin.PROPERTY_BACKING_FIELD, descriptor, + property.visibility, property.name, property.isVal, initializer, type + ) + } else if (delegate != null) { + backingField = createBackingField( + property, IrDeclarationOrigin.DELEGATE, descriptor, + Visibilities.PRIVATE, Name.identifier("${property.name}\$delegate"), true, delegate + ) } } - getter = property.getter.accept(this@Fir2IrVisitor, type) as IrSimpleFunction + getter = property.getter?.let { convertPropertyAccessor(it, type, delegate != null) } if (property.isVar) { - setter = property.setter!!.accept(this@Fir2IrVisitor, type) as IrSimpleFunction + setter = property.setter?.let { convertPropertyAccessor(it, type, delegate != null) } } property.annotations.forEach { annotations += it.accept(this@Fir2IrVisitor, null) as IrConstructorCall @@ -511,10 +533,11 @@ internal class Fir2IrVisitor( private fun createPropertyAccessor( propertyAccessor: FirPropertyAccessor, startOffset: Int, endOffset: Int, - correspondingProperty: IrProperty, isDefault: Boolean, propertyType: IrType + correspondingProperty: IrProperty, isDefault: Boolean, hasDelegate: Boolean, propertyType: IrType ): IrSimpleFunction { val origin = when { isDefault -> IrDeclarationOrigin.DEFAULT_PROPERTY_ACCESSOR + hasDelegate -> IrDeclarationOrigin.DELEGATED_PROPERTY_ACCESSOR else -> IrDeclarationOrigin.DEFINED } val isSetter = propertyAccessor.isSetter @@ -581,13 +604,13 @@ internal class Fir2IrVisitor( } } - override fun visitPropertyAccessor(propertyAccessor: FirPropertyAccessor, data: Any?): IrElement { + private fun convertPropertyAccessor(propertyAccessor: FirPropertyAccessor, type: IrType, hasDelegate: Boolean): IrSimpleFunction { val correspondingProperty = propertyStack.last() return propertyAccessor.convertWithOffsets { startOffset, endOffset -> createPropertyAccessor( propertyAccessor, startOffset, endOffset, correspondingProperty, isDefault = propertyAccessor is FirDefaultPropertyGetter || propertyAccessor is FirDefaultPropertySetter, - propertyType = data as IrType + hasDelegate = hasDelegate, propertyType = type ) } } @@ -750,6 +773,34 @@ internal class Fir2IrVisitor( return qualifiedAccessExpression.toIrExpression(qualifiedAccessExpression.typeRef).applyReceivers(qualifiedAccessExpression) } + override fun visitCallableReferenceAccess(callableReferenceAccess: FirCallableReferenceAccess, data: Any?): IrElement { + val symbol = callableReferenceAccess.calleeReference.toSymbol(declarationStorage) + val type = callableReferenceAccess.typeRef.toIrType(this@Fir2IrVisitor.session, declarationStorage) + return callableReferenceAccess.convertWithOffsets { startOffset, endOffset -> + when (symbol) { + is IrPropertySymbol -> { + IrPropertyReferenceImpl( + startOffset, endOffset, type, symbol, 0, + symbol.owner.backingField?.symbol, + symbol.owner.getter?.symbol, + symbol.owner.setter?.symbol + ) + } + is IrFunctionSymbol -> { + IrFunctionReferenceImpl( + startOffset, endOffset, type, symbol, + symbol.descriptor, 0 + ) + } + else -> { + IrErrorCallExpressionImpl( + startOffset, endOffset, type, "Unsupported callable reference: ${callableReferenceAccess.render()}" + ) + } + } + } + } + private fun generateErrorCallExpression(startOffset: Int, endOffset: Int, calleeReference: FirReference): IrErrorCallExpression { return IrErrorCallExpressionImpl( startOffset, endOffset, IrErrorTypeImpl(null, emptyList(), Variance.INVARIANT), diff --git a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/declarations/FirJavaField.kt b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/declarations/FirJavaField.kt index b0555504da3..bfa445b09e1 100644 --- a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/declarations/FirJavaField.kt +++ b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/declarations/FirJavaField.kt @@ -11,8 +11,10 @@ import org.jetbrains.kotlin.fir.FirSession import org.jetbrains.kotlin.fir.declarations.FirField import org.jetbrains.kotlin.fir.declarations.impl.FirAbstractCallableMember import org.jetbrains.kotlin.fir.expressions.FirExpression +import org.jetbrains.kotlin.fir.symbols.impl.FirDelegateFieldSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirFieldSymbol import org.jetbrains.kotlin.fir.types.FirTypeRef +import org.jetbrains.kotlin.fir.visitors.FirTransformer import org.jetbrains.kotlin.name.Name class FirJavaField( @@ -40,7 +42,14 @@ class FirJavaField( override val initializer: FirExpression? get() = null + override val delegateFieldSymbol: FirDelegateFieldSymbol? + get() = null + init { status.isStatic = isStatic } + + override fun transformChildrenWithoutAccessors(transformer: FirTransformer, data: D) { + transformChildren(transformer, data) + } } \ No newline at end of file diff --git a/compiler/fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/ConversionUtils.kt b/compiler/fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/ConversionUtils.kt index a71389cf957..a619b122da7 100644 --- a/compiler/fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/ConversionUtils.kt +++ b/compiler/fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/ConversionUtils.kt @@ -8,20 +8,25 @@ package org.jetbrains.kotlin.fir.builder import com.intellij.psi.PsiElement import com.intellij.psi.tree.IElementType import org.jetbrains.kotlin.KtNodeTypes +import org.jetbrains.kotlin.descriptors.Visibilities +import org.jetbrains.kotlin.fir.FirFunctionTarget import org.jetbrains.kotlin.fir.FirReference import org.jetbrains.kotlin.fir.FirSession import org.jetbrains.kotlin.fir.FirWhenSubject +import org.jetbrains.kotlin.fir.declarations.impl.FirModifiableAccessorsOwner +import org.jetbrains.kotlin.fir.declarations.impl.FirPropertyAccessorImpl +import org.jetbrains.kotlin.fir.declarations.impl.FirValueParameterImpl import org.jetbrains.kotlin.fir.declarations.impl.FirVariableImpl import org.jetbrains.kotlin.fir.expressions.* import org.jetbrains.kotlin.fir.expressions.impl.* -import org.jetbrains.kotlin.fir.references.FirErrorNamedReference -import org.jetbrains.kotlin.fir.references.FirExplicitThisReference -import org.jetbrains.kotlin.fir.references.FirResolvedCallableReferenceImpl -import org.jetbrains.kotlin.fir.references.FirSimpleNamedReference +import org.jetbrains.kotlin.fir.references.* import org.jetbrains.kotlin.fir.symbols.impl.FirVariableSymbol +import org.jetbrains.kotlin.fir.types.ConeStarProjection import org.jetbrains.kotlin.fir.types.FirTypeRef import org.jetbrains.kotlin.fir.types.impl.FirImplicitBooleanTypeRef +import org.jetbrains.kotlin.fir.types.impl.FirImplicitKPropertyTypeRef import org.jetbrains.kotlin.fir.types.impl.FirImplicitTypeRefImpl +import org.jetbrains.kotlin.fir.types.impl.FirImplicitUnitTypeRef import org.jetbrains.kotlin.ir.expressions.IrConstKind import org.jetbrains.kotlin.lexer.KtTokens import org.jetbrains.kotlin.name.Name @@ -563,4 +568,67 @@ internal fun KtExpression?.generateAssignment( return FirVariableAssignmentImpl(session, psi, value, operation).apply { lValue = initializeLValue(session, this@generateAssignment) { convert() as? FirQualifiedAccess } } -} \ No newline at end of file +} + +internal fun FirModifiableAccessorsOwner.generateAccessorsByDelegate(session: FirSession, member: Boolean) { + val variable = this as FirVariable<*> + val delegateFieldSymbol = delegateFieldSymbol ?: return + fun delegateAccess() = FirQualifiedAccessExpressionImpl(session, null).apply { + calleeReference = FirDelegateFieldReferenceImpl(session, null, delegateFieldSymbol) + } + + fun thisRef() = + if (member) FirQualifiedAccessExpressionImpl(session, null).apply { + calleeReference = FirExplicitThisReference(session, null, null) + } + else FirConstExpressionImpl(session, null, IrConstKind.Null, null) + + fun propertyRef() = FirCallableReferenceAccessImpl(session, null).apply { + calleeReference = FirResolvedCallableReferenceImpl(session, null, variable.name, variable.symbol) + typeRef = FirImplicitKPropertyTypeRef(session, null, ConeStarProjection) + } + + getter = (getter as? FirPropertyAccessorImpl) + ?: FirPropertyAccessorImpl(session, null, true, Visibilities.UNKNOWN, FirImplicitTypeRefImpl(session, null)).apply Accessor@{ + body = FirSingleExpressionBlock( + session, + FirReturnExpressionImpl( + session, null, + FirFunctionCallImpl(session, null).apply { + explicitReceiver = delegateAccess() + calleeReference = FirSimpleNamedReference(session, null, GET_VALUE) + arguments += thisRef() + arguments += propertyRef() + } + ).apply { + target = FirFunctionTarget(null) + target.bind(this@Accessor) + } + ) + } + setter = (setter as? FirPropertyAccessorImpl) + ?: FirPropertyAccessorImpl(session, null, false, Visibilities.UNKNOWN, FirImplicitUnitTypeRef(session, null)).apply { + val parameter = FirValueParameterImpl( + session, null, DELEGATED_SETTER_PARAM, + FirImplicitTypeRefImpl(session, null), + defaultValue = null, isCrossinline = false, + isNoinline = false, isVararg = false + ) + valueParameters += parameter + body = FirSingleExpressionBlock( + session, FirFunctionCallImpl(session, null).apply { + explicitReceiver = delegateAccess() + calleeReference = FirSimpleNamedReference(session, null, SET_VALUE) + arguments += thisRef() + arguments += propertyRef() + arguments += FirQualifiedAccessExpressionImpl(session, null).apply { + calleeReference = FirResolvedCallableReferenceImpl(session, psi, DELEGATED_SETTER_PARAM, parameter.symbol) + } + } + ) + } +} + +private val GET_VALUE = Name.identifier("getValue") +private val SET_VALUE = Name.identifier("setValue") +private val DELEGATED_SETTER_PARAM = Name.special("") \ No newline at end of file diff --git a/compiler/fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/RawFirBuilder.kt b/compiler/fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/RawFirBuilder.kt index bf6087a890a..b71c8ba010a 100644 --- a/compiler/fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/RawFirBuilder.kt +++ b/compiler/fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/RawFirBuilder.kt @@ -70,7 +70,7 @@ class RawFirBuilder(val session: FirSession, val stubMode: Boolean) { } private inner class Visitor : KtVisitor() { - private inline fun KtElement?.convertSafe(): R? = + private inline fun KtElement?. convertSafe(): R? = this?.accept(this@Visitor, Unit) as? R private inline fun KtElement.convert(): R = @@ -285,10 +285,11 @@ class RawFirBuilder(val session: FirSession, val stubMode: Boolean) { this@RawFirBuilder.session, this@toFirProperty, nameAsSafeName, firParameter.symbol ) }, - getter = FirDefaultPropertyGetter(session, this, type, visibility), - setter = if (isMutable) FirDefaultPropertySetter(session, this, type, visibility) else null, delegate = null - ) + ).apply { + getter = FirDefaultPropertyGetter(this@RawFirBuilder.session, this@toFirProperty, type, visibility) + setter = if (isMutable) FirDefaultPropertySetter(this@RawFirBuilder.session, this@toFirProperty, type, visibility) else null + } extractAnnotationsTo(firProperty) return firProperty } @@ -782,7 +783,9 @@ class RawFirBuilder(val session: FirSession, val stubMode: Boolean) { isVar, initializer, delegate = property.delegate?.expression?.toFirExpression("Incorrect delegate expression") - ) + ).apply { + generateAccessorsByDelegate(this@RawFirBuilder.session, member = false) + } } else { FirMemberPropertyImpl( session, @@ -800,13 +803,14 @@ class RawFirBuilder(val session: FirSession, val stubMode: Boolean) { propertyType, isVar, initializer, - property.getter.toFirPropertyAccessor(property, propertyType, isGetter = true), - if (isVar) property.setter.toFirPropertyAccessor(property, propertyType, isGetter = false) else null, if (property.hasDelegate()) { { property.delegate?.expression }.toFirExpression("Should have delegate") } else null ).apply { property.extractTypeParametersTo(this) + getter = property.getter.toFirPropertyAccessor(property, propertyType, isGetter = true) + setter = if (isVar) property.setter.toFirPropertyAccessor(property, propertyType, isGetter = false) else null + generateAccessorsByDelegate(this@RawFirBuilder.session, member = !property.isTopLevel) } } property.extractAnnotationsTo(firProperty) diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/deserialization/FirMemberDeserializer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/deserialization/FirMemberDeserializer.kt index cc53faa4cba..a5978a14e49 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/deserialization/FirMemberDeserializer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/deserialization/FirMemberDeserializer.kt @@ -173,14 +173,14 @@ class FirMemberDeserializer(private val c: FirDeserializationContext) { returnTypeRef = returnTypeRef, isVar = isVar, initializer = null, - getter = FirDefaultPropertyGetter(c.session, null, returnTypeRef, ProtoEnumFlags.visibility(Flags.VISIBILITY.get(getterFlags))), - setter = if (isVar) { - FirDefaultPropertySetter(c.session, null, returnTypeRef, ProtoEnumFlags.visibility(Flags.VISIBILITY.get(setterFlags))) - } else null, delegate = null ).apply { typeParameters += local.typeDeserializer.ownTypeParameters.map { it.fir } annotations += c.annotationDeserializer.loadPropertyAnnotations(proto, local.nameResolver) + getter = FirDefaultPropertyGetter(c.session, null, returnTypeRef, ProtoEnumFlags.visibility(Flags.VISIBILITY.get(getterFlags))) + setter = if (isVar) { + FirDefaultPropertySetter(c.session, null, returnTypeRef, ProtoEnumFlags.visibility(Flags.VISIBILITY.get(setterFlags))) + } else null } } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/Synthetics.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/Synthetics.kt index 0c542ee968d..35bb1807f64 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/Synthetics.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/Synthetics.kt @@ -61,10 +61,11 @@ class FirSyntheticPropertiesScope( returnTypeRef = returnTypeRef, isVar = true, initializer = null, - getter = FirDefaultPropertyGetter(session, null, returnTypeRef, fir.visibility), - setter = FirDefaultPropertySetter(session, null, returnTypeRef, fir.visibility), delegate = null - ) + ).apply { + getter = FirDefaultPropertyGetter(this@FirSyntheticPropertiesScope.session, null, returnTypeRef, fir.visibility) + setter = FirDefaultPropertySetter(this@FirSyntheticPropertiesScope.session, null, returnTypeRef, fir.visibility) + } return processor(synthetic) } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirBodyResolveTransformer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirBodyResolveTransformer.kt index 03665fd8935..50c25312d4a 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirBodyResolveTransformer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirBodyResolveTransformer.kt @@ -414,6 +414,11 @@ open class FirBodyResolveTransformer( } return qualifiedAccessExpression.compose() } + is FirDelegateFieldReference -> { + val delegateFieldSymbol = callee.coneSymbol + qualifiedAccessExpression.resultType = delegateFieldSymbol.delegate.typeRef + return qualifiedAccessExpression.compose() + } is FirResolvedCallableReference -> { if (qualifiedAccessExpression.typeRef !is FirResolvedTypeRef) { storeTypeFromCallee(qualifiedAccessExpression) @@ -1020,21 +1025,10 @@ open class FirBodyResolveTransformer( } ) } - variable.delegate != null -> { - // TODO: type from delegate + variable.getter != null && variable.getter !is FirDefaultPropertyAccessor -> { variable.transformReturnTypeRef( this, - FirErrorTypeRefImpl( - session, - null, - "Not supported: type from delegate" - ) - ) - } - variable is FirProperty && variable.getter !is FirDefaultPropertyAccessor -> { - variable.transformReturnTypeRef( - this, - when (val resultType = variable.getter.returnTypeRef) { + when (val resultType = variable.getter?.returnTypeRef) { is FirImplicitTypeRef -> FirErrorTypeRefImpl( session, null, @@ -1050,15 +1044,31 @@ open class FirBodyResolveTransformer( ) } } - if (variable is FirProperty && variable.getter.returnTypeRef is FirImplicitTypeRef) { - variable.getter.transformReturnTypeRef(this, variable.returnTypeRef) + if (variable.getter?.returnTypeRef is FirImplicitTypeRef) { + variable.getter?.transformReturnTypeRef(this, variable.returnTypeRef) } } } + private fun > FirVariable.transformAccessors() { + var enhancedTypeRef = returnTypeRef + getter?.transform(this@FirBodyResolveTransformer, enhancedTypeRef) + if (returnTypeRef is FirImplicitTypeRef) { + storeVariableReturnType(this) + enhancedTypeRef = returnTypeRef + } + setter?.let { + it.transform(this@FirBodyResolveTransformer, enhancedTypeRef) + it.valueParameters[0].transformReturnTypeRef(StoreType, enhancedTypeRef) + } + } + override fun > transformVariable(variable: FirVariable, data: Any?): CompositeTransformResult { - val variable = super.transformVariable(variable, variable.returnTypeRef).single as FirVariable<*> - storeVariableReturnType(variable) + variable.transformChildrenWithoutAccessors(this, variable.returnTypeRef) + if (variable.initializer != null) { + storeVariableReturnType(variable) + } + variable.transformAccessors() if (variable !is FirProperty) { localScopes.lastOrNull()?.storeDeclaration(variable) } @@ -1075,23 +1085,14 @@ open class FirBodyResolveTransformer( localScopes.addIfNotNull(primaryConstructorParametersScope) withContainer(property) { property.transformChildrenWithoutAccessors(this, returnTypeRef) - if (property.returnTypeRef is FirImplicitTypeRef && property.initializer != null) { + if (property.initializer != null) { storeVariableReturnType(property) } withScopeCleanup(localScopes) { localScopes.add(FirLocalScope().apply { storeBackingField(property) }) - var enhancedTypeRef = property.returnTypeRef - property.getter.transform(this, enhancedTypeRef) - if (property.returnTypeRef is FirImplicitTypeRef) { - storeVariableReturnType(property) - enhancedTypeRef = property.returnTypeRef - } - property.setter?.let { - it.transform(this, enhancedTypeRef) - it.valueParameters[0].transformReturnTypeRef(StoreType, enhancedTypeRef) - } + property.transformAccessors() } } property.compose() 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 db86f0027a6..e9fa9b70ebe 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 @@ -43,7 +43,7 @@ class FirStatusResolveTransformer : FirAbstractTreeTransformer() { Modality.FINAL this is FirNamedFunction && body == null -> Modality.ABSTRACT - this is FirProperty && initializer == null && getter.body == null && setter?.body == null -> + this is FirProperty && initializer == null && getter?.body == null && setter?.body == null -> Modality.ABSTRACT else -> Modality.OPEN diff --git a/compiler/fir/resolve/testData/resolve/stdlib/simpleDelegatedToMap.kt b/compiler/fir/resolve/testData/resolve/stdlib/simpleDelegatedToMap.kt new file mode 100644 index 00000000000..09535d63d34 --- /dev/null +++ b/compiler/fir/resolve/testData/resolve/stdlib/simpleDelegatedToMap.kt @@ -0,0 +1,5 @@ +class C(val map: MutableMap) { + var foo by map +} + +var bar by hashMapOf() \ No newline at end of file diff --git a/compiler/fir/resolve/testData/resolve/stdlib/simpleDelegatedToMap.txt b/compiler/fir/resolve/testData/resolve/stdlib/simpleDelegatedToMap.txt new file mode 100644 index 00000000000..a64f00c433c --- /dev/null +++ b/compiler/fir/resolve/testData/resolve/stdlib/simpleDelegatedToMap.txt @@ -0,0 +1,25 @@ +FILE: simpleDelegatedToMap.kt + public final class C : R|kotlin/Any| { + public constructor(map: R|kotlin/collections/MutableMap|): R|C| { + super() + } + + public final val map: R|kotlin/collections/MutableMap| = R|/map| + public get(): R|kotlin/collections/MutableMap| + + public final var foo: by R|/map| + public get(): { + ^ D|/C.foo|.#(this#, ::R|/C.foo|) + } + public set(: ): R|kotlin/Unit| { + D|/C.foo|.#(this#, ::R|/C.foo|, R|/|) + } + + } + public final var bar: by R|kotlin/collections/hashMapOf|() + public get(): { + ^ D|/bar|.#(Null(null), ::R|/bar|) + } + public set(: ): R|kotlin/Unit| { + D|/bar|.#(Null(null), ::R|/bar|, R|/|) + } diff --git a/compiler/fir/resolve/testData/resolve/stdlib/simpleLazy.kt b/compiler/fir/resolve/testData/resolve/stdlib/simpleLazy.kt new file mode 100644 index 00000000000..21681446568 --- /dev/null +++ b/compiler/fir/resolve/testData/resolve/stdlib/simpleLazy.kt @@ -0,0 +1,9 @@ +//val x = lazy { "Hello" }.getValue(null, throw null) +val x by lazy { "Hello" } + +fun foo() { + x.length + + val y by lazy { "Bye" } + y.length +} \ No newline at end of file diff --git a/compiler/fir/resolve/testData/resolve/stdlib/simpleLazy.txt b/compiler/fir/resolve/testData/resolve/stdlib/simpleLazy.txt new file mode 100644 index 00000000000..c1d5a15e543 --- /dev/null +++ b/compiler/fir/resolve/testData/resolve/stdlib/simpleLazy.txt @@ -0,0 +1,16 @@ +FILE: simpleLazy.kt + public final val x: R|kotlin/String|by R|kotlin/lazy|( = lazy@fun (): R|kotlin/String| { + String(Hello) + } + ) + public get(): R|kotlin/String| { + ^ D|/x|.R|kotlin/getValue|(Null(null), ::R|/x|) + } + public final fun foo(): R|kotlin/Unit| { + R|/x|.R|kotlin/String.length| + lval y: R|kotlin/String|by R|kotlin/lazy|( = lazy@fun (): R|kotlin/String| { + String(Bye) + } + ) + R|/y|.R|kotlin/String.length| + } diff --git a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirResolveTestCaseWithStdlibGenerated.java b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirResolveTestCaseWithStdlibGenerated.java index 2a22bb85a40..74d730484a7 100644 --- a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirResolveTestCaseWithStdlibGenerated.java +++ b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirResolveTestCaseWithStdlibGenerated.java @@ -94,6 +94,16 @@ public class FirResolveTestCaseWithStdlibGenerated extends AbstractFirResolveTes runTest("compiler/fir/resolve/testData/resolve/stdlib/reflectionClass.kt"); } + @TestMetadata("simpleDelegatedToMap.kt") + public void testSimpleDelegatedToMap() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/stdlib/simpleDelegatedToMap.kt"); + } + + @TestMetadata("simpleLazy.kt") + public void testSimpleLazy() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/stdlib/simpleLazy.kt"); + } + @TestMetadata("topLevelResolve.kt") public void testTopLevelResolve() throws Exception { runTest("compiler/fir/resolve/testData/resolve/stdlib/topLevelResolve.kt"); diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/FirDelegateFieldReference.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/FirDelegateFieldReference.kt new file mode 100644 index 00000000000..15b36b0672c --- /dev/null +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/FirDelegateFieldReference.kt @@ -0,0 +1,25 @@ +/* + * Copyright 2010-2019 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 + +import org.jetbrains.kotlin.fir.symbols.impl.FirDelegateFieldSymbol +import org.jetbrains.kotlin.fir.visitors.FirVisitor +import org.jetbrains.kotlin.name.Name + +interface FirDelegateFieldReference : FirResolvedCallableReference { + + override val name: Name + get() = NAME + + override val coneSymbol: FirDelegateFieldSymbol<*> + + override fun accept(visitor: FirVisitor, data: D): R = + visitor.visitDelegateFieldReference(this, data) + + companion object { + val NAME = Name.identifier("\$delegate") + } +} \ No newline at end of file diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/FirRenderer.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/FirRenderer.kt index 70ae38f8c72..8e5844484b1 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/FirRenderer.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/FirRenderer.kt @@ -346,8 +346,8 @@ class FirRenderer(builder: StringBuilder) : FirVisitorVoid() { visitVariable(property) println() pushIndent() - property.getter.accept(this) - if (property.getter.body == null) { + property.getter?.accept(this) + if (property.getter?.body == null) { println() } if (property.isVar) { @@ -804,6 +804,12 @@ class FirRenderer(builder: StringBuilder) : FirVisitorVoid() { print("|") } + override fun visitDelegateFieldReference(delegateFieldReference: FirDelegateFieldReference) { + print("D|") + print(delegateFieldReference.coneSymbol.callableId) + print("|") + } + override fun visitResolvedCallableReference(resolvedCallableReference: FirResolvedCallableReference) { print("R|") val isFakeOverride = (resolvedCallableReference.coneSymbol as? FirNamedFunctionSymbol)?.isFakeOverride == true diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/FirProperty.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/FirProperty.kt index e9ffb67c626..b521a60bb49 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/FirProperty.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/FirProperty.kt @@ -23,14 +23,13 @@ interface FirProperty : override val isOverride: Boolean get() = status.isOverride // Should it be nullable or have some default? - val getter: FirPropertyAccessor + override val getter: FirPropertyAccessor? - val setter: FirPropertyAccessor? + override val setter: FirPropertyAccessor? + // TODO: it should be probably nullable val backingFieldSymbol: FirBackingFieldSymbol - fun transformChildrenWithoutAccessors(transformer: FirTransformer, data: D) - override fun accept(visitor: FirVisitor, data: D): R = visitor.visitProperty(this, data) @@ -38,7 +37,7 @@ interface FirProperty : super.acceptChildren(visitor, data) initializer?.accept(visitor, data) delegate?.accept(visitor, data) - getter.accept(visitor, data) + getter?.accept(visitor, data) setter?.accept(visitor, data) } } \ No newline at end of file diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/FirValueParameter.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/FirValueParameter.kt index b2cd5c07616..e34587f6af8 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/FirValueParameter.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/FirValueParameter.kt @@ -10,6 +10,7 @@ import org.jetbrains.kotlin.fir.VisitedSupertype import org.jetbrains.kotlin.fir.expressions.FirExpression import org.jetbrains.kotlin.fir.expressions.FirVariable import org.jetbrains.kotlin.fir.symbols.impl.FirVariableSymbol +import org.jetbrains.kotlin.fir.visitors.FirTransformer import org.jetbrains.kotlin.fir.visitors.FirVisitor @BaseTransformedType @@ -24,6 +25,10 @@ interface FirValueParameter : @VisitedSupertype FirDeclaration, FirTypedDeclarat override val symbol: FirVariableSymbol + override fun transformChildrenWithoutAccessors(transformer: FirTransformer, data: D) { + transformChildren(transformer, data) + } + override fun accept(visitor: FirVisitor, data: D): R = visitor.visitValueParameter(this, data) diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/impl/FirDefaultSetterValueParameter.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/impl/FirDefaultSetterValueParameter.kt index b3f467f0927..95ffd21d328 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/impl/FirDefaultSetterValueParameter.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/impl/FirDefaultSetterValueParameter.kt @@ -10,6 +10,7 @@ import org.jetbrains.kotlin.fir.FirElement import org.jetbrains.kotlin.fir.FirSession import org.jetbrains.kotlin.fir.declarations.FirValueParameter import org.jetbrains.kotlin.fir.expressions.FirExpression +import org.jetbrains.kotlin.fir.symbols.impl.FirDelegateFieldSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirVariableSymbol import org.jetbrains.kotlin.fir.transformSingle import org.jetbrains.kotlin.fir.types.FirTypeRef @@ -33,6 +34,8 @@ class FirDefaultSetterValueParameter( get() = null override val receiverTypeRef: FirTypeRef? get() = null + override val delegateFieldSymbol: FirDelegateFieldSymbol? + get() = null override val isCrossinline = false diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/impl/FirMemberPropertyImpl.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/impl/FirMemberPropertyImpl.kt index 32588a0e96e..7382c8192cb 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/impl/FirMemberPropertyImpl.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/impl/FirMemberPropertyImpl.kt @@ -14,6 +14,7 @@ import org.jetbrains.kotlin.fir.declarations.FirProperty import org.jetbrains.kotlin.fir.declarations.FirPropertyAccessor import org.jetbrains.kotlin.fir.expressions.FirExpression import org.jetbrains.kotlin.fir.symbols.impl.FirBackingFieldSymbol +import org.jetbrains.kotlin.fir.symbols.impl.FirDelegateFieldSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirPropertySymbol import org.jetbrains.kotlin.fir.transformInplace import org.jetbrains.kotlin.fir.transformSingle @@ -37,17 +38,24 @@ class FirMemberPropertyImpl( returnTypeRef: FirTypeRef, override val isVar: Boolean, override var initializer: FirExpression?, - override var getter: FirPropertyAccessor, - override var setter: FirPropertyAccessor?, override var delegate: FirExpression? ) : FirAbstractCallableMember( session, psi, name, visibility, modality, isExpect, isActual, isOverride, receiverTypeRef, returnTypeRef -), FirProperty { +), FirProperty, FirModifiableAccessorsOwner { + // TODO: backing field may not exist override val backingFieldSymbol = FirBackingFieldSymbol(symbol.callableId) + override val delegateFieldSymbol: FirDelegateFieldSymbol? = + delegate?.let { FirDelegateFieldSymbol(symbol.callableId) } + + override var getter: FirPropertyAccessor? = null + + override var setter: FirPropertyAccessor? = null + init { symbol.bind(this) backingFieldSymbol.bind(this) + delegateFieldSymbol?.bind(this) status.isConst = isConst status.isLateInit = isLateInit } @@ -63,7 +71,7 @@ class FirMemberPropertyImpl( } override fun transformChildren(transformer: FirTransformer, data: D): FirElement { - getter = getter.transformSingle(transformer, data) + getter = getter?.transformSingle(transformer, data) setter = setter?.transformSingle(transformer, data) transformChildrenWithoutAccessors(transformer, data) // Everything other (annotations, etc.) is done above diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/impl/FirModifiableAccessorsOwner.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/impl/FirModifiableAccessorsOwner.kt new file mode 100644 index 00000000000..c355fa28956 --- /dev/null +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/impl/FirModifiableAccessorsOwner.kt @@ -0,0 +1,17 @@ +/* + * Copyright 2010-2019 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.declarations.impl + +import org.jetbrains.kotlin.fir.declarations.FirPropertyAccessor +import org.jetbrains.kotlin.fir.symbols.impl.FirDelegateFieldSymbol + +interface FirModifiableAccessorsOwner { + var getter: FirPropertyAccessor? + + var setter: FirPropertyAccessor? + + val delegateFieldSymbol: FirDelegateFieldSymbol<*>? +} \ No newline at end of file diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/impl/FirValueParameterImpl.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/impl/FirValueParameterImpl.kt index 3aa3ffe5e5f..4acdb8a7fee 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/impl/FirValueParameterImpl.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/impl/FirValueParameterImpl.kt @@ -10,6 +10,7 @@ import org.jetbrains.kotlin.fir.FirElement import org.jetbrains.kotlin.fir.FirSession import org.jetbrains.kotlin.fir.declarations.FirValueParameter import org.jetbrains.kotlin.fir.expressions.FirExpression +import org.jetbrains.kotlin.fir.symbols.impl.FirDelegateFieldSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirVariableSymbol import org.jetbrains.kotlin.fir.transformSingle import org.jetbrains.kotlin.fir.types.FirTypeRef @@ -40,6 +41,8 @@ open class FirValueParameterImpl( get() = null override val receiverTypeRef: FirTypeRef? get() = null + override val delegateFieldSymbol: FirDelegateFieldSymbol? + get() = null override fun transformChildren(transformer: FirTransformer, data: D): FirElement { returnTypeRef = returnTypeRef.transformSingle(transformer, data) diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/impl/FirVariableImpl.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/impl/FirVariableImpl.kt index 3763ace3b19..2c9ab076ef6 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/impl/FirVariableImpl.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/impl/FirVariableImpl.kt @@ -8,9 +8,13 @@ package org.jetbrains.kotlin.fir.declarations.impl import com.intellij.psi.PsiElement import org.jetbrains.kotlin.fir.FirElement import org.jetbrains.kotlin.fir.FirSession +import org.jetbrains.kotlin.fir.declarations.FirProperty +import org.jetbrains.kotlin.fir.declarations.FirPropertyAccessor import org.jetbrains.kotlin.fir.expressions.FirExpression import org.jetbrains.kotlin.fir.expressions.FirVariable +import org.jetbrains.kotlin.fir.symbols.impl.FirDelegateFieldSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirVariableSymbol +import org.jetbrains.kotlin.fir.transformInplace import org.jetbrains.kotlin.fir.transformSingle import org.jetbrains.kotlin.fir.types.FirTypeRef import org.jetbrains.kotlin.fir.visitors.FirTransformer @@ -25,21 +29,36 @@ class FirVariableImpl( override var initializer: FirExpression?, override val symbol: FirVariableSymbol = FirVariableSymbol(name), override var delegate: FirExpression? = null -) : FirAbstractNamedAnnotatedDeclaration(session, psiElement, name), FirVariable { +) : FirAbstractNamedAnnotatedDeclaration(session, psiElement, name), FirVariable, FirModifiableAccessorsOwner { + + override val delegateFieldSymbol: FirDelegateFieldSymbol? = + delegate?.let { FirDelegateFieldSymbol(symbol.callableId) } + + override var getter: FirPropertyAccessor? = null + + override var setter: FirPropertyAccessor? = null init { symbol.bind(this) + delegateFieldSymbol?.bind(this) } override val receiverTypeRef: FirTypeRef? get() = null - override fun transformChildren(transformer: FirTransformer, data: D): FirElement { + override fun transformChildrenWithoutAccessors(transformer: FirTransformer, data: D) { returnTypeRef = returnTypeRef.transformSingle(transformer, data) initializer = initializer?.transformSingle(transformer, data) delegate = delegate?.transformSingle(transformer, data) + annotations.transformInplace(transformer, data) + } - return super.transformChildren(transformer, data) + override fun transformChildren(transformer: FirTransformer, data: D): FirElement { + getter = getter?.transformSingle(transformer, data) + setter = setter?.transformSingle(transformer, data) + transformChildrenWithoutAccessors(transformer, data) + // Everything other (annotations, etc.) is done above + return this } override fun transformReturnTypeRef(transformer: FirTransformer, data: D) { diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/expressions/FirVariable.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/expressions/FirVariable.kt index 482db834078..32748768e38 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/expressions/FirVariable.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/expressions/FirVariable.kt @@ -7,7 +7,9 @@ package org.jetbrains.kotlin.fir.expressions import org.jetbrains.kotlin.fir.VisitedSupertype import org.jetbrains.kotlin.fir.declarations.* +import org.jetbrains.kotlin.fir.symbols.impl.FirDelegateFieldSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirVariableSymbol +import org.jetbrains.kotlin.fir.visitors.FirTransformer import org.jetbrains.kotlin.fir.visitors.FirVisitor interface FirVariable> : @@ -23,12 +25,22 @@ interface FirVariable> : override val symbol: FirVariableSymbol + val getter: FirPropertyAccessor? get() = null + + val setter: FirPropertyAccessor? get() = null + + val delegateFieldSymbol: FirDelegateFieldSymbol? + + fun transformChildrenWithoutAccessors(transformer: FirTransformer, data: D) + override fun accept(visitor: FirVisitor, data: D): R = visitor.visitVariable(this, data) override fun acceptChildren(visitor: FirVisitor, data: D) { initializer?.accept(visitor, data) delegate?.accept(visitor, data) + getter?.accept(visitor, data) + setter?.accept(visitor, data) super.acceptChildren(visitor, data) } } \ No newline at end of file diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/references/FirDelegateFieldReferenceImpl.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/references/FirDelegateFieldReferenceImpl.kt new file mode 100644 index 00000000000..57a3c2163d2 --- /dev/null +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/references/FirDelegateFieldReferenceImpl.kt @@ -0,0 +1,18 @@ +/* + * Copyright 2010-2019 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.references + +import com.intellij.psi.PsiElement +import org.jetbrains.kotlin.fir.FirAbstractElement +import org.jetbrains.kotlin.fir.FirDelegateFieldReference +import org.jetbrains.kotlin.fir.FirSession +import org.jetbrains.kotlin.fir.symbols.impl.FirDelegateFieldSymbol + +class FirDelegateFieldReferenceImpl( + session: FirSession, + psi: PsiElement?, + override val coneSymbol: FirDelegateFieldSymbol<*> +) : FirAbstractElement(session, psi), FirDelegateFieldReference \ No newline at end of file diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/symbols/impl/FirVariableSymbol.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/symbols/impl/FirVariableSymbol.kt index 96a11177535..a84b9a33a48 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/symbols/impl/FirVariableSymbol.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/symbols/impl/FirVariableSymbol.kt @@ -7,6 +7,7 @@ package org.jetbrains.kotlin.fir.symbols.impl import org.jetbrains.kotlin.fir.declarations.FirField import org.jetbrains.kotlin.fir.declarations.FirProperty +import org.jetbrains.kotlin.fir.expressions.FirExpression import org.jetbrains.kotlin.fir.expressions.FirVariable import org.jetbrains.kotlin.fir.symbols.CallableId import org.jetbrains.kotlin.fir.symbols.ConePropertySymbol @@ -23,4 +24,9 @@ open class FirPropertySymbol(callableId: CallableId) : ConePropertySymbol, FirVa class FirBackingFieldSymbol(callableId: CallableId) : FirVariableSymbol(callableId) +class FirDelegateFieldSymbol>(callableId: CallableId) : FirVariableSymbol(callableId) { + val delegate: FirExpression + get() = fir.delegate!! +} + class FirFieldSymbol(callableId: CallableId) : FirVariableSymbol(callableId) diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/types/impl/FirImplicitBuiltinTypeRef.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/types/impl/FirImplicitBuiltinTypeRef.kt index 915b6d69d8d..2bc608ffaa0 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/types/impl/FirImplicitBuiltinTypeRef.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/types/impl/FirImplicitBuiltinTypeRef.kt @@ -12,18 +12,20 @@ import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall import org.jetbrains.kotlin.fir.symbols.ConeClassLikeLookupTagImpl import org.jetbrains.kotlin.fir.symbols.StandardClassIds import org.jetbrains.kotlin.fir.types.ConeKotlinType +import org.jetbrains.kotlin.fir.types.ConeKotlinTypeProjection import org.jetbrains.kotlin.fir.types.FirResolvedTypeRef import org.jetbrains.kotlin.name.ClassId sealed class FirImplicitBuiltinTypeRef( session: FirSession, psi: PsiElement?, - val id: ClassId + val id: ClassId, + typeArguments: Array = emptyArray() ) : FirResolvedTypeRef, FirAbstractElement(session, psi) { override val annotations: List get() = emptyList() - override val type: ConeKotlinType = ConeClassTypeImpl(ConeClassLikeLookupTagImpl(id), emptyArray(), false) + override val type: ConeKotlinType = ConeClassTypeImpl(ConeClassLikeLookupTagImpl(id), typeArguments, false) } class FirImplicitUnitTypeRef( @@ -61,3 +63,8 @@ class FirImplicitStringTypeRef( psi: PsiElement? ) : FirImplicitBuiltinTypeRef(session, psi, StandardClassIds.String) +class FirImplicitKPropertyTypeRef( + session: FirSession, + psi: PsiElement?, + typeArgument: ConeKotlinTypeProjection +) : FirImplicitBuiltinTypeRef(session, psi, StandardClassIds.KProperty, arrayOf(typeArgument)) \ No newline at end of file diff --git a/compiler/fir/tree/visitors/org/jetbrains/kotlin/fir/visitors/FirTransformerGenerated.kt b/compiler/fir/tree/visitors/org/jetbrains/kotlin/fir/visitors/FirTransformerGenerated.kt index 947d5212f46..b94799ebeb5 100644 --- a/compiler/fir/tree/visitors/org/jetbrains/kotlin/fir/visitors/FirTransformerGenerated.kt +++ b/compiler/fir/tree/visitors/org/jetbrains/kotlin/fir/visitors/FirTransformerGenerated.kt @@ -168,6 +168,10 @@ abstract class FirTransformer : FirVisitor { + return transformResolvedCallableReference(delegateFieldReference, data) + } + open fun transformSuperReference(superReference: E, data: D): CompositeTransformResult { return transformReference(superReference, data) } @@ -552,6 +556,10 @@ abstract class FirTransformer : FirVisitor { + return transformDelegateFieldReference(delegateFieldReference, data) + } + final override fun visitDelegatedConstructorCall(delegatedConstructorCall: FirDelegatedConstructorCall, data: D): CompositeTransformResult { return transformDelegatedConstructorCall(delegatedConstructorCall, data) } diff --git a/compiler/fir/tree/visitors/org/jetbrains/kotlin/fir/visitors/FirVisitorGenerated.kt b/compiler/fir/tree/visitors/org/jetbrains/kotlin/fir/visitors/FirVisitorGenerated.kt index c4bab0eda35..3f4e927107d 100644 --- a/compiler/fir/tree/visitors/org/jetbrains/kotlin/fir/visitors/FirVisitorGenerated.kt +++ b/compiler/fir/tree/visitors/org/jetbrains/kotlin/fir/visitors/FirVisitorGenerated.kt @@ -168,6 +168,10 @@ abstract class FirVisitor { return visitResolvedCallableReference(backingFieldReference, data) } + open fun visitDelegateFieldReference(delegateFieldReference: FirDelegateFieldReference, data: D): R { + return visitResolvedCallableReference(delegateFieldReference, data) + } + open fun visitSuperReference(superReference: FirSuperReference, data: D): R { return visitReference(superReference, data) } diff --git a/compiler/fir/tree/visitors/org/jetbrains/kotlin/fir/visitors/FirVisitorVoidGenerated.kt b/compiler/fir/tree/visitors/org/jetbrains/kotlin/fir/visitors/FirVisitorVoidGenerated.kt index ceefa8a2d39..624a9d8168b 100644 --- a/compiler/fir/tree/visitors/org/jetbrains/kotlin/fir/visitors/FirVisitorVoidGenerated.kt +++ b/compiler/fir/tree/visitors/org/jetbrains/kotlin/fir/visitors/FirVisitorVoidGenerated.kt @@ -168,6 +168,10 @@ abstract class FirVisitorVoid : FirVisitor() { visitResolvedCallableReference(backingFieldReference, null) } + open fun visitDelegateFieldReference(delegateFieldReference: FirDelegateFieldReference) { + visitResolvedCallableReference(delegateFieldReference, null) + } + open fun visitSuperReference(superReference: FirSuperReference) { visitReference(superReference, null) } @@ -552,6 +556,10 @@ abstract class FirVisitorVoid : FirVisitor() { visitDefaultPropertyAccessor(defaultPropertyAccessor) } + final override fun visitDelegateFieldReference(delegateFieldReference: FirDelegateFieldReference, data: Nothing?) { + visitDelegateFieldReference(delegateFieldReference) + } + final override fun visitDelegatedConstructorCall(delegatedConstructorCall: FirDelegatedConstructorCall, data: Nothing?) { visitDelegatedConstructorCall(delegatedConstructorCall) } diff --git a/compiler/testData/ir/irText/declarations/annotations/delegateFieldWithAnnotations.fir.txt b/compiler/testData/ir/irText/declarations/annotations/delegateFieldWithAnnotations.fir.txt index 3361f42f53f..552ee99e812 100644 --- a/compiler/testData/ir/irText/declarations/annotations/delegateFieldWithAnnotations.fir.txt +++ b/compiler/testData/ir/irText/declarations/annotations/delegateFieldWithAnnotations.fir.txt @@ -18,10 +18,18 @@ FILE fqName: fileName:/delegateFieldWithAnnotations.kt PROPERTY name:test1 visibility:public modality:FINAL [delegated,val] annotations: Ann - FIELD PROPERTY_BACKING_FIELD name:test1 type:IrErrorType visibility:public [final,static] - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:IrErrorType + FIELD DELEGATE name:test1$delegate type:kotlin.Lazy visibility:private [final,static] + EXPRESSION_BODY + CALL 'public final fun lazy (initializer: kotlin.Function0>): kotlin.Lazy> declared in kotlin' type=kotlin.Lazy origin=null + initializer: FUN_EXPR type=kotlin.Function0 origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:kotlin.Int + BLOCK_BODY + CONST Int type=kotlin.Int value=42 + FUN DELEGATED_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.Int correspondingProperty: PROPERTY name:test1 visibility:public modality:FINAL [delegated,val] BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): IrErrorType declared in ' - GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:test1 type:IrErrorType visibility:public [final,static] ' type=IrErrorType origin=null - + RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in ' + CALL 'public final fun getValue (thisRef: kotlin.Any?, property: kotlin.reflect.KProperty<*>): T of [inline] declared in kotlin' type=kotlin.Int origin=null + $receiver: GET_FIELD 'FIELD DELEGATE name:test1$delegate type:kotlin.Lazy visibility:private [final,static] ' type=kotlin.Lazy origin=GET_PROPERTY + thisRef: CONST Null type=kotlin.Nothing? value=null + property: PROPERTY_REFERENCE 'public final test1: kotlin.Int [delegated,val]' field='FIELD DELEGATE name:test1$delegate type:kotlin.Lazy visibility:private [final,static] ' getter=null setter=null type=kotlin.reflect.KProperty<*> origin=null diff --git a/compiler/testData/ir/irText/declarations/annotations/delegatedPropertyAccessorsWithAnnotations.fir.txt b/compiler/testData/ir/irText/declarations/annotations/delegatedPropertyAccessorsWithAnnotations.fir.txt index d1651a86212..fa9f24f592d 100644 --- a/compiler/testData/ir/irText/declarations/annotations/delegatedPropertyAccessorsWithAnnotations.fir.txt +++ b/compiler/testData/ir/irText/declarations/annotations/delegatedPropertyAccessorsWithAnnotations.fir.txt @@ -84,27 +84,41 @@ FILE fqName: fileName:/delegatedPropertyAccessorsWithAnnotations.kt PROPERTY name:test1 visibility:public modality:FINAL [delegated,val] annotations: A(x = 'test1.get') - FIELD PROPERTY_BACKING_FIELD name:test1 type:IrErrorType visibility:public [final,static] - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:IrErrorType + FIELD DELEGATE name:test1$delegate type:.Cell visibility:private [final,static] + EXPRESSION_BODY + CONSTRUCTOR_CALL 'public constructor (value: kotlin.Int) [primary] declared in .Cell' type=.Cell origin=null + value: CONST Int type=kotlin.Int value=1 + FUN DELEGATED_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.Int correspondingProperty: PROPERTY name:test1 visibility:public modality:FINAL [delegated,val] BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): IrErrorType declared in ' - GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:test1 type:IrErrorType visibility:public [final,static] ' type=IrErrorType origin=null + RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in ' + CALL 'public final fun getValue (thisRef: kotlin.Any?, kProp: kotlin.Any?): kotlin.Int declared in .Cell' type=kotlin.Int origin=null + $this: GET_FIELD 'FIELD DELEGATE name:test1$delegate type:.Cell visibility:private [final,static] ' type=.Cell origin=GET_PROPERTY + thisRef: CONST Null type=kotlin.Nothing? value=null + kProp: PROPERTY_REFERENCE 'public final test1: kotlin.Int [delegated,val]' field='FIELD DELEGATE name:test1$delegate type:.Cell visibility:private [final,static] ' getter=null setter=null type=kotlin.reflect.KProperty<*> origin=null PROPERTY name:test2 visibility:public modality:FINAL [delegated,var] annotations: A(x = 'test2.get') A(x = 'test2.set') A(x = 'test2.set.param') - FIELD PROPERTY_BACKING_FIELD name:test2 type:IrErrorType visibility:public [static] - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:IrErrorType + FIELD DELEGATE name:test2$delegate type:.Cell visibility:private [final,static] + EXPRESSION_BODY + CONSTRUCTOR_CALL 'public constructor (value: kotlin.Int) [primary] declared in .Cell' type=.Cell origin=null + value: CONST Int type=kotlin.Int value=2 + FUN DELEGATED_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.Int correspondingProperty: PROPERTY name:test2 visibility:public modality:FINAL [delegated,var] BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): IrErrorType declared in ' - GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:test2 type:IrErrorType visibility:public [static] ' type=IrErrorType origin=null - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> (:IrErrorType) returnType:kotlin.Unit + RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in ' + CALL 'public final fun getValue (thisRef: kotlin.Any?, kProp: kotlin.Any?): kotlin.Int declared in .Cell' type=kotlin.Int origin=null + $this: GET_FIELD 'FIELD DELEGATE name:test2$delegate type:.Cell visibility:private [final,static] ' type=.Cell origin=GET_PROPERTY + thisRef: CONST Null type=kotlin.Nothing? value=null + kProp: PROPERTY_REFERENCE 'public final test2: kotlin.Int [delegated,var]' field='FIELD DELEGATE name:test2$delegate type:.Cell visibility:private [final,static] ' getter=null setter=null type=kotlin.reflect.KProperty<*> origin=null + FUN DELEGATED_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> (:kotlin.Int) returnType:kotlin.Unit correspondingProperty: PROPERTY name:test2 visibility:public modality:FINAL [delegated,var] - VALUE_PARAMETER name: index:0 type:IrErrorType + VALUE_PARAMETER name: index:0 type:kotlin.Int BLOCK_BODY - SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:test2 type:IrErrorType visibility:public [static] ' type=kotlin.Unit origin=null - value: GET_VAR ': IrErrorType declared in .' type=IrErrorType origin=null - + CALL 'public final fun setValue (thisRef: kotlin.Any?, kProp: kotlin.Any?, newValue: kotlin.Int): kotlin.Unit declared in .Cell' type=kotlin.Unit origin=null + $this: GET_FIELD 'FIELD DELEGATE name:test2$delegate type:.Cell visibility:private [final,static] ' type=.Cell origin=GET_PROPERTY + thisRef: CONST Null type=kotlin.Nothing? value=null + kProp: PROPERTY_REFERENCE 'public final test2: kotlin.Int [delegated,var]' field='FIELD DELEGATE name:test2$delegate type:.Cell visibility:private [final,static] ' getter='public final fun (): kotlin.Int declared in ' setter=null type=kotlin.reflect.KProperty<*> origin=null + newValue: GET_VAR ': kotlin.Int declared in .' type=kotlin.Int origin=null diff --git a/compiler/testData/ir/irText/declarations/annotations/localDelegatedPropertiesWithAnnotations.fir.txt b/compiler/testData/ir/irText/declarations/annotations/localDelegatedPropertiesWithAnnotations.fir.txt index 21236aaa770..e52d4d19711 100644 --- a/compiler/testData/ir/irText/declarations/annotations/localDelegatedPropertiesWithAnnotations.fir.txt +++ b/compiler/testData/ir/irText/declarations/annotations/localDelegatedPropertiesWithAnnotations.fir.txt @@ -30,5 +30,4 @@ FILE fqName: fileName:/localDelegatedPropertiesWithAnnotations.kt FUN name:foo visibility:public modality:FINAL <> (m:kotlin.collections.Map) returnType:kotlin.Unit VALUE_PARAMETER name:m index:0 type:kotlin.collections.Map BLOCK_BODY - VAR name:test type:IrErrorType [val] - + VAR name:test type:kotlin.Int [val] diff --git a/compiler/testData/ir/irText/declarations/classLevelProperties.fir.txt b/compiler/testData/ir/irText/declarations/classLevelProperties.fir.txt index a6438a2bc31..3c41415a459 100644 --- a/compiler/testData/ir/irText/declarations/classLevelProperties.fir.txt +++ b/compiler/testData/ir/irText/declarations/classLevelProperties.fir.txt @@ -83,31 +83,44 @@ FILE fqName: fileName:/classLevelProperties.kt correspondingProperty: PROPERTY name:test6 visibility:public modality:FINAL [val] $this: VALUE_PARAMETER name: type:.C PROPERTY name:test7 visibility:public modality:FINAL [delegated,val] - FIELD PROPERTY_BACKING_FIELD name:test7 type:IrErrorType visibility:public [final] - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.C) returnType:IrErrorType + FIELD DELEGATE name:test7$delegate type:kotlin.Lazy visibility:private [final] + EXPRESSION_BODY + CALL 'public final fun lazy (initializer: kotlin.Function0>): kotlin.Lazy> declared in kotlin' type=kotlin.Lazy origin=null + initializer: FUN_EXPR type=kotlin.Function0 origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> ($this:.C) returnType:kotlin.Int + $this: VALUE_PARAMETER name: type:.C + BLOCK_BODY + CONST Int type=kotlin.Int value=42 + FUN DELEGATED_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.C) returnType:kotlin.Int correspondingProperty: PROPERTY name:test7 visibility:public modality:FINAL [delegated,val] $this: VALUE_PARAMETER name: type:.C BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): IrErrorType declared in .C' - GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:test7 type:IrErrorType visibility:public [final] ' type=IrErrorType origin=null - receiver: GET_VAR ': .C declared in .C.' type=.C origin=null + RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in .C' + CALL 'public final fun getValue (thisRef: kotlin.Any?, property: kotlin.reflect.KProperty<*>): T of [inline] declared in kotlin' type=kotlin.Int origin=null + $receiver: GET_FIELD 'FIELD DELEGATE name:test7$delegate type:kotlin.Lazy visibility:private [final] ' type=kotlin.Lazy origin=GET_PROPERTY + thisRef: ERROR_CALL 'Unresolved reference: this#' type=.C + property: PROPERTY_REFERENCE 'public final test7: kotlin.Int [delegated,val]' field='FIELD DELEGATE name:test7$delegate type:kotlin.Lazy visibility:private [final] ' getter=null setter=null type=kotlin.reflect.KProperty<*> origin=null PROPERTY name:test8 visibility:public modality:FINAL [delegated,var] - FIELD PROPERTY_BACKING_FIELD name:test8 type:IrErrorType visibility:public - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.C) returnType:IrErrorType + FIELD DELEGATE name:test8$delegate type:java.util.HashMap visibility:private [final] + EXPRESSION_BODY + CALL 'public final fun hashMapOf (): java.util.HashMap, V of > [inline] declared in kotlin.collections' type=java.util.HashMap origin=null + FUN DELEGATED_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.C) returnType:IrErrorType correspondingProperty: PROPERTY name:test8 visibility:public modality:FINAL [delegated,var] $this: VALUE_PARAMETER name: type:.C BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun (): IrErrorType declared in .C' - GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:test8 type:IrErrorType visibility:public ' type=IrErrorType origin=null - receiver: GET_VAR ': .C declared in .C.' type=.C origin=null - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.C, :IrErrorType) returnType:kotlin.Unit + ERROR_CALL 'Unresolved reference: #' type=IrErrorType + ERROR_CALL 'Unresolved reference: this#' type=.C + PROPERTY_REFERENCE 'public final test8: IrErrorType [delegated,var]' field='FIELD DELEGATE name:test8$delegate type:java.util.HashMap visibility:private [final] ' getter=null setter=null type=kotlin.reflect.KProperty<*> origin=null + FUN DELEGATED_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.C, :IrErrorType) returnType:kotlin.Unit correspondingProperty: PROPERTY name:test8 visibility:public modality:FINAL [delegated,var] $this: VALUE_PARAMETER name: type:.C - VALUE_PARAMETER name: index:0 type:IrErrorType + VALUE_PARAMETER name: index:0 type:IrErrorType BLOCK_BODY - SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:test8 type:IrErrorType visibility:public ' type=kotlin.Unit origin=null - receiver: GET_VAR ': .C declared in .C.' type=.C origin=null - value: GET_VAR ': IrErrorType declared in .C.' type=IrErrorType origin=null + ERROR_CALL 'Unresolved reference: #' type=IrErrorType + ERROR_CALL 'Unresolved reference: this#' type=.C + PROPERTY_REFERENCE 'public final test8: IrErrorType [delegated,var]' field='FIELD DELEGATE name:test8$delegate type:java.util.HashMap visibility:private [final] ' getter='public final fun (): IrErrorType declared in .C' setter=null type=kotlin.reflect.KProperty<*> origin=null + GET_VAR ': IrErrorType declared in .C.' type=IrErrorType origin=null FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean overridden: public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in kotlin.Any diff --git a/compiler/testData/ir/irText/declarations/delegatedProperties.fir.txt b/compiler/testData/ir/irText/declarations/delegatedProperties.fir.txt index 40fa969f179..dfbaf1e6762 100644 --- a/compiler/testData/ir/irText/declarations/delegatedProperties.fir.txt +++ b/compiler/testData/ir/irText/declarations/delegatedProperties.fir.txt @@ -1,11 +1,20 @@ FILE fqName: fileName:/delegatedProperties.kt PROPERTY name:test1 visibility:public modality:FINAL [delegated,val] - FIELD PROPERTY_BACKING_FIELD name:test1 type:IrErrorType visibility:public [final,static] - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:IrErrorType + FIELD DELEGATE name:test1$delegate type:kotlin.Lazy visibility:private [final,static] + EXPRESSION_BODY + CALL 'public final fun lazy (initializer: kotlin.Function0>): kotlin.Lazy> declared in kotlin' type=kotlin.Lazy origin=null + initializer: FUN_EXPR type=kotlin.Function0 origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:kotlin.Int + BLOCK_BODY + CONST Int type=kotlin.Int value=42 + FUN DELEGATED_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.Int correspondingProperty: PROPERTY name:test1 visibility:public modality:FINAL [delegated,val] BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): IrErrorType declared in ' - GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:test1 type:IrErrorType visibility:public [final,static] ' type=IrErrorType origin=null + RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in ' + CALL 'public final fun getValue (thisRef: kotlin.Any?, property: kotlin.reflect.KProperty<*>): T of [inline] declared in kotlin' type=kotlin.Int origin=null + $receiver: GET_FIELD 'FIELD DELEGATE name:test1$delegate type:kotlin.Lazy visibility:private [final,static] ' type=kotlin.Lazy origin=GET_PROPERTY + thisRef: CONST Null type=kotlin.Nothing? value=null + property: PROPERTY_REFERENCE 'public final test1: kotlin.Int [delegated,val]' field='FIELD DELEGATE name:test1$delegate type:kotlin.Lazy visibility:private [final,static] ' getter=null setter=null type=kotlin.reflect.KProperty<*> origin=null CLASS CLASS name:C modality:FINAL visibility:public superTypes:[kotlin.Any] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.C CONSTRUCTOR visibility:public <> (map:kotlin.collections.MutableMap) returnType:.C [primary] @@ -25,32 +34,45 @@ FILE fqName: fileName:/delegatedProperties.kt GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:map type:kotlin.collections.MutableMap visibility:public [final] ' type=kotlin.collections.MutableMap origin=null receiver: GET_VAR ': .C declared in .C.' type=.C origin=null PROPERTY name:test2 visibility:public modality:FINAL [delegated,val] - FIELD PROPERTY_BACKING_FIELD name:test2 type:IrErrorType visibility:public [final] - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.C) returnType:IrErrorType + FIELD DELEGATE name:test2$delegate type:kotlin.Lazy visibility:private [final] + EXPRESSION_BODY + CALL 'public final fun lazy (initializer: kotlin.Function0>): kotlin.Lazy> declared in kotlin' type=kotlin.Lazy origin=null + initializer: FUN_EXPR type=kotlin.Function0 origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> ($this:.C) returnType:kotlin.Int + $this: VALUE_PARAMETER name: type:.C + BLOCK_BODY + CONST Int type=kotlin.Int value=42 + FUN DELEGATED_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.C) returnType:kotlin.Int correspondingProperty: PROPERTY name:test2 visibility:public modality:FINAL [delegated,val] $this: VALUE_PARAMETER name: type:.C BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): IrErrorType declared in .C' - GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:test2 type:IrErrorType visibility:public [final] ' type=IrErrorType origin=null - receiver: GET_VAR ': .C declared in .C.' type=.C origin=null + RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in .C' + CALL 'public final fun getValue (thisRef: kotlin.Any?, property: kotlin.reflect.KProperty<*>): T of [inline] declared in kotlin' type=kotlin.Int origin=null + $receiver: GET_FIELD 'FIELD DELEGATE name:test2$delegate type:kotlin.Lazy visibility:private [final] ' type=kotlin.Lazy origin=GET_PROPERTY + thisRef: ERROR_CALL 'Unresolved reference: this#' type=.C + property: PROPERTY_REFERENCE 'public final test2: kotlin.Int [delegated,val]' field='FIELD DELEGATE name:test2$delegate type:kotlin.Lazy visibility:private [final] ' getter=null setter=null type=kotlin.reflect.KProperty<*> origin=null PROPERTY name:test3 visibility:public modality:FINAL [delegated,var] - FIELD PROPERTY_BACKING_FIELD name:test3 type:IrErrorType visibility:public - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.C) returnType:IrErrorType + FIELD DELEGATE name:test3$delegate type:kotlin.collections.MutableMap visibility:private [final] + EXPRESSION_BODY + GET_VAR 'map: kotlin.collections.MutableMap declared in .C.' type=kotlin.collections.MutableMap origin=null + FUN DELEGATED_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.C) returnType:IrErrorType correspondingProperty: PROPERTY name:test3 visibility:public modality:FINAL [delegated,var] $this: VALUE_PARAMETER name: type:.C BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun (): IrErrorType declared in .C' - GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:test3 type:IrErrorType visibility:public ' type=IrErrorType origin=null - receiver: GET_VAR ': .C declared in .C.' type=.C origin=null - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.C, :IrErrorType) returnType:kotlin.Unit + ERROR_CALL 'Unresolved reference: #' type=IrErrorType + ERROR_CALL 'Unresolved reference: this#' type=.C + PROPERTY_REFERENCE 'public final test3: IrErrorType [delegated,var]' field='FIELD DELEGATE name:test3$delegate type:kotlin.collections.MutableMap visibility:private [final] ' getter=null setter=null type=kotlin.reflect.KProperty<*> origin=null + FUN DELEGATED_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.C, :IrErrorType) returnType:kotlin.Unit correspondingProperty: PROPERTY name:test3 visibility:public modality:FINAL [delegated,var] $this: VALUE_PARAMETER name: type:.C - VALUE_PARAMETER name: index:0 type:IrErrorType + VALUE_PARAMETER name: index:0 type:IrErrorType BLOCK_BODY - SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:test3 type:IrErrorType visibility:public ' type=kotlin.Unit origin=null - receiver: GET_VAR ': .C declared in .C.' type=.C origin=null - value: GET_VAR ': IrErrorType declared in .C.' type=IrErrorType origin=null - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean + ERROR_CALL 'Unresolved reference: #' type=IrErrorType + ERROR_CALL 'Unresolved reference: this#' type=.C + PROPERTY_REFERENCE 'public final test3: IrErrorType [delegated,var]' field='FIELD DELEGATE name:test3$delegate type:kotlin.collections.MutableMap visibility:private [final] ' getter='public final fun (): IrErrorType declared in .C' setter=null type=kotlin.reflect.KProperty<*> origin=null + GET_VAR ': IrErrorType declared in .C.' type=IrErrorType origin=null + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean overridden: public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in kotlin.Any $this: VALUE_PARAMETER name: type:kotlin.Any @@ -64,16 +86,21 @@ FILE fqName: fileName:/delegatedProperties.kt public open fun toString (): kotlin.String declared in kotlin.Any $this: VALUE_PARAMETER name: type:kotlin.Any PROPERTY name:test4 visibility:public modality:FINAL [delegated,var] - FIELD PROPERTY_BACKING_FIELD name:test4 type:IrErrorType visibility:public [static] - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:IrErrorType + FIELD DELEGATE name:test4$delegate type:java.util.HashMap visibility:private [final,static] + EXPRESSION_BODY + CALL 'public final fun hashMapOf (): java.util.HashMap, V of > [inline] declared in kotlin.collections' type=java.util.HashMap origin=null + FUN DELEGATED_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:IrErrorType correspondingProperty: PROPERTY name:test4 visibility:public modality:FINAL [delegated,var] BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun (): IrErrorType declared in ' - GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:test4 type:IrErrorType visibility:public [static] ' type=IrErrorType origin=null - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> (:IrErrorType) returnType:kotlin.Unit + ERROR_CALL 'Unresolved reference: #' type=IrErrorType + CONST Null type=kotlin.Nothing? value=null + PROPERTY_REFERENCE 'public final test4: IrErrorType [delegated,var]' field='FIELD DELEGATE name:test4$delegate type:java.util.HashMap visibility:private [final,static] ' getter=null setter=null type=kotlin.reflect.KProperty<*> origin=null + FUN DELEGATED_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> (:IrErrorType) returnType:kotlin.Unit correspondingProperty: PROPERTY name:test4 visibility:public modality:FINAL [delegated,var] - VALUE_PARAMETER name: index:0 type:IrErrorType + VALUE_PARAMETER name: index:0 type:IrErrorType BLOCK_BODY - SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:test4 type:IrErrorType visibility:public [static] ' type=kotlin.Unit origin=null - value: GET_VAR ': IrErrorType declared in .' type=IrErrorType origin=null - + ERROR_CALL 'Unresolved reference: #' type=IrErrorType + CONST Null type=kotlin.Nothing? value=null + PROPERTY_REFERENCE 'public final test4: IrErrorType [delegated,var]' field='FIELD DELEGATE name:test4$delegate type:java.util.HashMap visibility:private [final,static] ' getter='public final fun (): IrErrorType declared in ' setter=null type=kotlin.reflect.KProperty<*> origin=null + GET_VAR ': IrErrorType declared in .' type=IrErrorType origin=null diff --git a/compiler/testData/ir/irText/declarations/localDelegatedProperties.fir.txt b/compiler/testData/ir/irText/declarations/localDelegatedProperties.fir.txt index 7813f945695..a1fe28dde8b 100644 --- a/compiler/testData/ir/irText/declarations/localDelegatedProperties.fir.txt +++ b/compiler/testData/ir/irText/declarations/localDelegatedProperties.fir.txt @@ -1,9 +1,9 @@ FILE fqName: fileName:/localDelegatedProperties.kt FUN name:test1 visibility:public modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY - VAR name:x type:IrErrorType [val] - ERROR_CALL 'Unresolved reference: #' type=IrErrorType - GET_VAR 'val x: IrErrorType [val] declared in .test1' type=IrErrorType origin=null + VAR name:x type:kotlin.Int [val] + CALL 'public final fun println (message: kotlin.Int): kotlin.Unit [inline] declared in kotlin.io' type=kotlin.Unit origin=null + message: GET_VAR 'val x: kotlin.Int [val] declared in .test1' type=kotlin.Int origin=null FUN name:test2 visibility:public modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY VAR name:x type:IrErrorType [var] diff --git a/compiler/testData/ir/irText/declarations/packageLevelProperties.fir.txt b/compiler/testData/ir/irText/declarations/packageLevelProperties.fir.txt index 6ade103189b..c238468d417 100644 --- a/compiler/testData/ir/irText/declarations/packageLevelProperties.fir.txt +++ b/compiler/testData/ir/irText/declarations/packageLevelProperties.fir.txt @@ -63,23 +63,37 @@ FILE fqName: fileName:/packageLevelProperties.kt FUN name: visibility:public modality:FINAL <> () returnType:kotlin.Int correspondingProperty: PROPERTY name:test6 visibility:public modality:FINAL [val] PROPERTY name:test7 visibility:public modality:FINAL [delegated,val] - FIELD PROPERTY_BACKING_FIELD name:test7 type:IrErrorType visibility:public [final,static] - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:IrErrorType + FIELD DELEGATE name:test7$delegate type:kotlin.Lazy visibility:private [final,static] + EXPRESSION_BODY + CALL 'public final fun lazy (initializer: kotlin.Function0>): kotlin.Lazy> declared in kotlin' type=kotlin.Lazy origin=null + initializer: FUN_EXPR type=kotlin.Function0 origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:kotlin.Int + BLOCK_BODY + CONST Int type=kotlin.Int value=42 + FUN DELEGATED_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.Int correspondingProperty: PROPERTY name:test7 visibility:public modality:FINAL [delegated,val] BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): IrErrorType declared in ' - GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:test7 type:IrErrorType visibility:public [final,static] ' type=IrErrorType origin=null + RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in ' + CALL 'public final fun getValue (thisRef: kotlin.Any?, property: kotlin.reflect.KProperty<*>): T of [inline] declared in kotlin' type=kotlin.Int origin=null + $receiver: GET_FIELD 'FIELD DELEGATE name:test7$delegate type:kotlin.Lazy visibility:private [final,static] ' type=kotlin.Lazy origin=GET_PROPERTY + thisRef: CONST Null type=kotlin.Nothing? value=null + property: PROPERTY_REFERENCE 'public final test7: kotlin.Int [delegated,val]' field='FIELD DELEGATE name:test7$delegate type:kotlin.Lazy visibility:private [final,static] ' getter=null setter=null type=kotlin.reflect.KProperty<*> origin=null PROPERTY name:test8 visibility:public modality:FINAL [delegated,var] - FIELD PROPERTY_BACKING_FIELD name:test8 type:IrErrorType visibility:public [static] - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:IrErrorType + FIELD DELEGATE name:test8$delegate type:java.util.HashMap visibility:private [final,static] + EXPRESSION_BODY + CALL 'public final fun hashMapOf (): java.util.HashMap, V of > [inline] declared in kotlin.collections' type=java.util.HashMap origin=null + FUN DELEGATED_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:IrErrorType correspondingProperty: PROPERTY name:test8 visibility:public modality:FINAL [delegated,var] BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun (): IrErrorType declared in ' - GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:test8 type:IrErrorType visibility:public [static] ' type=IrErrorType origin=null - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> (:IrErrorType) returnType:kotlin.Unit + ERROR_CALL 'Unresolved reference: #' type=IrErrorType + CONST Null type=kotlin.Nothing? value=null + PROPERTY_REFERENCE 'public final test8: IrErrorType [delegated,var]' field='FIELD DELEGATE name:test8$delegate type:java.util.HashMap visibility:private [final,static] ' getter=null setter=null type=kotlin.reflect.KProperty<*> origin=null + FUN DELEGATED_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> (:IrErrorType) returnType:kotlin.Unit correspondingProperty: PROPERTY name:test8 visibility:public modality:FINAL [delegated,var] - VALUE_PARAMETER name: index:0 type:IrErrorType + VALUE_PARAMETER name: index:0 type:IrErrorType BLOCK_BODY - SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:test8 type:IrErrorType visibility:public [static] ' type=kotlin.Unit origin=null - value: GET_VAR ': IrErrorType declared in .' type=IrErrorType origin=null - + ERROR_CALL 'Unresolved reference: #' type=IrErrorType + CONST Null type=kotlin.Nothing? value=null + PROPERTY_REFERENCE 'public final test8: IrErrorType [delegated,var]' field='FIELD DELEGATE name:test8$delegate type:java.util.HashMap visibility:private [final,static] ' getter='public final fun (): IrErrorType declared in ' setter=null type=kotlin.reflect.KProperty<*> origin=null + GET_VAR ': IrErrorType declared in .' type=IrErrorType origin=null diff --git a/compiler/testData/ir/irText/declarations/provideDelegate/differentReceivers.fir.txt b/compiler/testData/ir/irText/declarations/provideDelegate/differentReceivers.fir.txt index bdeca59a139..413a4e270e8 100644 --- a/compiler/testData/ir/irText/declarations/provideDelegate/differentReceivers.fir.txt +++ b/compiler/testData/ir/irText/declarations/provideDelegate/differentReceivers.fir.txt @@ -46,24 +46,34 @@ FILE fqName: fileName:/differentReceivers.kt RETURN type=kotlin.Nothing from='public final fun getValue (receiver: kotlin.Any?, p: kotlin.Any): kotlin.String declared in ' ERROR_CALL 'Unresolved reference: this#' type=kotlin.String PROPERTY name:testO visibility:public modality:FINAL [delegated,val] - FIELD PROPERTY_BACKING_FIELD name:testO type:IrErrorType visibility:public [final,static] - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:IrErrorType + FIELD DELEGATE name:testO$delegate type:.MyClass visibility:private [final,static] + EXPRESSION_BODY + CONSTRUCTOR_CALL 'public constructor (value: kotlin.String) [primary] declared in .MyClass' type=.MyClass origin=null + value: CONST String type=kotlin.String value="O" + FUN DELEGATED_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:IrErrorType correspondingProperty: PROPERTY name:testO visibility:public modality:FINAL [delegated,val] BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun (): IrErrorType declared in ' - GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:testO type:IrErrorType visibility:public [final,static] ' type=IrErrorType origin=null - PROPERTY name:testK visibility:public modality:FINAL [delegated,val] - FIELD PROPERTY_BACKING_FIELD name:testK type:IrErrorType visibility:public [final,static] - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:IrErrorType + ERROR_CALL 'Unresolved reference: #' type=IrErrorType + CONST Null type=kotlin.Nothing? value=null + PROPERTY_REFERENCE 'public final testO: IrErrorType [delegated,val]' field='FIELD DELEGATE name:testO$delegate type:.MyClass visibility:private [final,static] ' getter=null setter=null type=kotlin.reflect.KProperty<*> origin=null + PROPERTY name:testK visibility:public modality:FINAL [delegated,val] + FIELD DELEGATE name:testK$delegate type:kotlin.String visibility:private [final,static] + EXPRESSION_BODY + CONST String type=kotlin.String value="K" + FUN DELEGATED_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.String correspondingProperty: PROPERTY name:testK visibility:public modality:FINAL [delegated,val] BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): IrErrorType declared in ' - GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:testK type:IrErrorType visibility:public [final,static] ' type=IrErrorType origin=null + RETURN type=kotlin.Nothing from='public final fun (): kotlin.String declared in ' + CALL 'public final fun getValue (receiver: kotlin.Any?, p: kotlin.Any): kotlin.String declared in ' type=kotlin.String origin=null + $receiver: GET_FIELD 'FIELD DELEGATE name:testK$delegate type:kotlin.String visibility:private [final,static] ' type=kotlin.String origin=GET_PROPERTY + receiver: CONST Null type=kotlin.Nothing? value=null + p: PROPERTY_REFERENCE 'public final testK: kotlin.String [delegated,val]' field='FIELD DELEGATE name:testK$delegate type:kotlin.String visibility:private [final,static] ' getter=null setter=null type=kotlin.reflect.KProperty<*> origin=null PROPERTY name:testOK visibility:public modality:FINAL [val] FIELD PROPERTY_BACKING_FIELD name:testOK type:IrErrorType visibility:public [final,static] EXPRESSION_BODY - ERROR_CALL 'Unresolved reference: #' type=IrErrorType - CALL 'public final fun (): IrErrorType declared in ' type=IrErrorType origin=null + ERROR_CALL 'Unresolved reference: #' type=IrErrorType + CALL 'public final fun (): kotlin.String declared in ' type=kotlin.String origin=null FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:IrErrorType correspondingProperty: PROPERTY name:testOK visibility:public modality:FINAL [val] BLOCK_BODY diff --git a/compiler/testData/ir/irText/declarations/provideDelegate/localDifferentReceivers.fir.txt b/compiler/testData/ir/irText/declarations/provideDelegate/localDifferentReceivers.fir.txt index 12e567135d7..18e79c09d3c 100644 --- a/compiler/testData/ir/irText/declarations/provideDelegate/localDifferentReceivers.fir.txt +++ b/compiler/testData/ir/irText/declarations/provideDelegate/localDifferentReceivers.fir.txt @@ -48,10 +48,10 @@ FILE fqName: fileName:/localDifferentReceivers.kt FUN name:box visibility:public modality:FINAL <> () returnType:kotlin.String BLOCK_BODY VAR name:testO type:IrErrorType [val] - VAR name:testK type:IrErrorType [val] + VAR name:testK type:kotlin.String [val] VAR name:testOK type:IrErrorType [val] - ERROR_CALL 'Unresolved reference: #' type=IrErrorType - GET_VAR 'val testK: IrErrorType [val] declared in .box' type=IrErrorType origin=null + ERROR_CALL 'Unresolved reference: #' type=IrErrorType + GET_VAR 'val testK: kotlin.String [val] declared in .box' type=kotlin.String origin=null RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in ' GET_VAR 'val testOK: IrErrorType [val] declared in .box' type=IrErrorType origin=null diff --git a/compiler/testData/ir/irText/declarations/provideDelegate/member.fir.txt b/compiler/testData/ir/irText/declarations/provideDelegate/member.fir.txt index 64829f52232..710c845a156 100644 --- a/compiler/testData/ir/irText/declarations/provideDelegate/member.fir.txt +++ b/compiler/testData/ir/irText/declarations/provideDelegate/member.fir.txt @@ -83,14 +83,18 @@ FILE fqName: fileName:/member.kt DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Host modality:FINAL visibility:public superTypes:[kotlin.Any]' PROPERTY name:testMember visibility:public modality:FINAL [delegated,val] - FIELD PROPERTY_BACKING_FIELD name:testMember type:IrErrorType visibility:public [final] - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.Host) returnType:IrErrorType + FIELD DELEGATE name:testMember$delegate type:.DelegateProvider visibility:private [final] + EXPRESSION_BODY + CONSTRUCTOR_CALL 'public constructor (value: kotlin.String) [primary] declared in .DelegateProvider' type=.DelegateProvider origin=null + value: CONST String type=kotlin.String value="OK" + FUN DELEGATED_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.Host) returnType:IrErrorType correspondingProperty: PROPERTY name:testMember visibility:public modality:FINAL [delegated,val] $this: VALUE_PARAMETER name: type:.Host BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun (): IrErrorType declared in .Host' - GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:testMember type:IrErrorType visibility:public [final] ' type=IrErrorType origin=null - receiver: GET_VAR ': .Host declared in .Host.' type=.Host origin=null + ERROR_CALL 'Unresolved reference: #' type=IrErrorType + ERROR_CALL 'Unresolved reference: this#' type=.Host + PROPERTY_REFERENCE 'public final testMember: IrErrorType [delegated,val]' field='FIELD DELEGATE name:testMember$delegate type:.DelegateProvider visibility:private [final] ' getter=null setter=null type=kotlin.reflect.KProperty<*> origin=null FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean overridden: public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in kotlin.Any diff --git a/compiler/testData/ir/irText/declarations/provideDelegate/memberExtension.fir.txt b/compiler/testData/ir/irText/declarations/provideDelegate/memberExtension.fir.txt index fd9ab362d22..64bfce3587b 100644 --- a/compiler/testData/ir/irText/declarations/provideDelegate/memberExtension.fir.txt +++ b/compiler/testData/ir/irText/declarations/provideDelegate/memberExtension.fir.txt @@ -55,14 +55,17 @@ FILE fqName: fileName:/memberExtension.kt CONSTRUCTOR_CALL 'public constructor (s: kotlin.String) [primary] declared in .Host.StringDelegate' type=.Host.StringDelegate origin=null s: ERROR_CALL 'Unresolved reference: this#' type=kotlin.String PROPERTY name:plusK visibility:public modality:FINAL [delegated,val] - FIELD PROPERTY_BACKING_FIELD name:plusK type:IrErrorType visibility:public [final] - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.Host) returnType:IrErrorType + FIELD DELEGATE name:plusK$delegate type:IrErrorType visibility:private [final] + EXPRESSION_BODY + CONST String type=IrErrorType value="K" + FUN DELEGATED_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.Host) returnType:IrErrorType correspondingProperty: PROPERTY name:plusK visibility:public modality:FINAL [delegated,val] $this: VALUE_PARAMETER name: type:.Host BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun (): IrErrorType declared in .Host' - GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:plusK type:IrErrorType visibility:public [final] ' type=IrErrorType origin=null - receiver: GET_VAR ': .Host declared in .Host.' type=.Host origin=null + ERROR_CALL 'Unresolved reference: #' type=IrErrorType + ERROR_CALL 'Unresolved reference: this#' type=.Host + PROPERTY_REFERENCE 'public final plusK: IrErrorType [delegated,val]' field='FIELD DELEGATE name:plusK$delegate type:IrErrorType visibility:private [final] ' getter=null setter=null type=kotlin.reflect.KProperty<*> origin=null PROPERTY name:ok visibility:public modality:FINAL [val] FIELD PROPERTY_BACKING_FIELD name:ok type:IrErrorType visibility:public [final] EXPRESSION_BODY diff --git a/compiler/testData/ir/irText/declarations/provideDelegate/topLevel.fir.txt b/compiler/testData/ir/irText/declarations/provideDelegate/topLevel.fir.txt index 5f14c58d04a..fc72e651417 100644 --- a/compiler/testData/ir/irText/declarations/provideDelegate/topLevel.fir.txt +++ b/compiler/testData/ir/irText/declarations/provideDelegate/topLevel.fir.txt @@ -77,10 +77,14 @@ FILE fqName: fileName:/topLevel.kt public open fun toString (): kotlin.String declared in kotlin.Any $this: VALUE_PARAMETER name: type:kotlin.Any PROPERTY name:testTopLevel visibility:public modality:FINAL [delegated,val] - FIELD PROPERTY_BACKING_FIELD name:testTopLevel type:IrErrorType visibility:public [final,static] - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:IrErrorType + FIELD DELEGATE name:testTopLevel$delegate type:.DelegateProvider visibility:private [final,static] + EXPRESSION_BODY + CONSTRUCTOR_CALL 'public constructor (value: kotlin.String) [primary] declared in .DelegateProvider' type=.DelegateProvider origin=null + value: CONST String type=kotlin.String value="OK" + FUN DELEGATED_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:IrErrorType correspondingProperty: PROPERTY name:testTopLevel visibility:public modality:FINAL [delegated,val] BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun (): IrErrorType declared in ' - GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:testTopLevel type:IrErrorType visibility:public [final,static] ' type=IrErrorType origin=null - + ERROR_CALL 'Unresolved reference: #' type=IrErrorType + CONST Null type=kotlin.Nothing? value=null + PROPERTY_REFERENCE 'public final testTopLevel: IrErrorType [delegated,val]' field='FIELD DELEGATE name:testTopLevel$delegate type:.DelegateProvider visibility:private [final,static] ' getter=null setter=null type=kotlin.reflect.KProperty<*> origin=null diff --git a/compiler/testData/ir/irText/expressions/boundCallableReferences.fir.txt b/compiler/testData/ir/irText/expressions/boundCallableReferences.fir.txt index 0658133d0e1..abf30578ad2 100644 --- a/compiler/testData/ir/irText/expressions/boundCallableReferences.fir.txt +++ b/compiler/testData/ir/irText/expressions/boundCallableReferences.fir.txt @@ -38,7 +38,7 @@ FILE fqName: fileName:/boundCallableReferences.kt PROPERTY name:test1 visibility:public modality:FINAL [val] FIELD PROPERTY_BACKING_FIELD name:test1 type:IrErrorType visibility:public [final,static] EXPRESSION_BODY - ERROR_CALL 'Unresolved reference: #' type=IrErrorType + ERROR_CALL 'Unsupported callable reference: R|/A.A|()::#' type=IrErrorType FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:IrErrorType correspondingProperty: PROPERTY name:test1 visibility:public modality:FINAL [val] BLOCK_BODY @@ -47,8 +47,7 @@ FILE fqName: fileName:/boundCallableReferences.kt PROPERTY name:test2 visibility:public modality:FINAL [val] FIELD PROPERTY_BACKING_FIELD name:test2 type:kotlin.Int visibility:public [final,static] EXPRESSION_BODY - CALL 'public final fun (): kotlin.Int declared in .A' type=kotlin.Int origin=null - $this: CONSTRUCTOR_CALL 'public constructor () [primary] declared in .A' type=.A origin=null + PROPERTY_REFERENCE 'public final bar: kotlin.Int [val]' field='FIELD PROPERTY_BACKING_FIELD name:bar type:kotlin.Int visibility:public [final] ' getter='public final fun (): kotlin.Int declared in .A' setter=null type=kotlin.Int origin=null FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.Int correspondingProperty: PROPERTY name:test2 visibility:public modality:FINAL [val] BLOCK_BODY @@ -57,7 +56,7 @@ FILE fqName: fileName:/boundCallableReferences.kt PROPERTY name:test3 visibility:public modality:FINAL [val] FIELD PROPERTY_BACKING_FIELD name:test3 type:IrErrorType visibility:public [final,static] EXPRESSION_BODY - ERROR_CALL 'Unresolved reference: #' type=IrErrorType + ERROR_CALL 'Unsupported callable reference: R|/A.A|()::#' type=IrErrorType FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:IrErrorType correspondingProperty: PROPERTY name:test3 visibility:public modality:FINAL [val] BLOCK_BODY diff --git a/compiler/testData/ir/irText/expressions/callableRefToGenericMember.fir.txt b/compiler/testData/ir/irText/expressions/callableRefToGenericMember.fir.txt index c709f0da076..a21be92e3e4 100644 --- a/compiler/testData/ir/irText/expressions/callableRefToGenericMember.fir.txt +++ b/compiler/testData/ir/irText/expressions/callableRefToGenericMember.fir.txt @@ -36,7 +36,7 @@ FILE fqName: fileName:/callableRefToGenericMember.kt PROPERTY name:test1 visibility:public modality:FINAL [val] FIELD PROPERTY_BACKING_FIELD name:test1 type:IrErrorType visibility:public [final,static] EXPRESSION_BODY - ERROR_CALL 'Unresolved reference: #' type=IrErrorType + ERROR_CALL 'Unsupported callable reference: R|/A.A|()::#' type=IrErrorType FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:IrErrorType correspondingProperty: PROPERTY name:test1 visibility:public modality:FINAL [val] BLOCK_BODY @@ -45,9 +45,7 @@ FILE fqName: fileName:/callableRefToGenericMember.kt PROPERTY name:test2 visibility:public modality:FINAL [val] FIELD PROPERTY_BACKING_FIELD name:test2 type:kotlin.Int visibility:public [final,static] EXPRESSION_BODY - CALL 'public final fun (): kotlin.Int declared in .A' type=kotlin.Int origin=null - $this: CONSTRUCTOR_CALL 'public constructor () [primary] declared in .A' type=.A origin=null - : + PROPERTY_REFERENCE 'public final bar: kotlin.Int [val]' field='FIELD PROPERTY_BACKING_FIELD name:bar type:kotlin.Int visibility:public [final] ' getter='public final fun (): kotlin.Int declared in .A' setter=null type=kotlin.Int origin=null FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.Int correspondingProperty: PROPERTY name:test2 visibility:public modality:FINAL [val] BLOCK_BODY diff --git a/compiler/testData/ir/irText/expressions/callableReferenceToImportedFromObject.fir.txt b/compiler/testData/ir/irText/expressions/callableReferenceToImportedFromObject.fir.txt index 66812bd2b0d..7312ad6b305 100644 --- a/compiler/testData/ir/irText/expressions/callableReferenceToImportedFromObject.fir.txt +++ b/compiler/testData/ir/irText/expressions/callableReferenceToImportedFromObject.fir.txt @@ -37,7 +37,7 @@ FILE fqName:test fileName:/callableReferenceToImportedFromObject.kt PROPERTY name:test1 visibility:public modality:FINAL [val] FIELD PROPERTY_BACKING_FIELD name:test1 type:kotlin.String visibility:public [final,static] EXPRESSION_BODY - CALL 'public final fun (): kotlin.String declared in test.Foo' type=kotlin.String origin=null + PROPERTY_REFERENCE 'public final a: kotlin.String [val]' field='FIELD PROPERTY_BACKING_FIELD name:a type:kotlin.String visibility:public [final] ' getter='public final fun (): kotlin.String declared in test.Foo' setter=null type=kotlin.String origin=null FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.String correspondingProperty: PROPERTY name:test1 visibility:public modality:FINAL [val] BLOCK_BODY @@ -46,8 +46,7 @@ FILE fqName:test fileName:/callableReferenceToImportedFromObject.kt PROPERTY name:test1a visibility:public modality:FINAL [val] FIELD PROPERTY_BACKING_FIELD name:test1a type:kotlin.String visibility:public [final,static] EXPRESSION_BODY - CALL 'public final fun (): kotlin.String declared in test.Foo' type=kotlin.String origin=null - $this: GET_OBJECT 'CLASS OBJECT name:Foo modality:FINAL visibility:public superTypes:[kotlin.Any]' type=test.Foo + PROPERTY_REFERENCE 'public final a: kotlin.String [val]' field='FIELD PROPERTY_BACKING_FIELD name:a type:kotlin.String visibility:public [final] ' getter='public final fun (): kotlin.String declared in test.Foo' setter=null type=kotlin.String origin=null FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.String correspondingProperty: PROPERTY name:test1a visibility:public modality:FINAL [val] BLOCK_BODY @@ -56,7 +55,7 @@ FILE fqName:test fileName:/callableReferenceToImportedFromObject.kt PROPERTY name:test2 visibility:public modality:FINAL [val] FIELD PROPERTY_BACKING_FIELD name:test2 type:IrErrorType visibility:public [final,static] EXPRESSION_BODY - ERROR_CALL 'Unresolved reference: #' type=IrErrorType + ERROR_CALL 'Unsupported callable reference: ::#' type=IrErrorType FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:IrErrorType correspondingProperty: PROPERTY name:test2 visibility:public modality:FINAL [val] BLOCK_BODY @@ -65,7 +64,7 @@ FILE fqName:test fileName:/callableReferenceToImportedFromObject.kt PROPERTY name:test2a visibility:public modality:FINAL [val] FIELD PROPERTY_BACKING_FIELD name:test2a type:IrErrorType visibility:public [final,static] EXPRESSION_BODY - ERROR_CALL 'Unresolved reference: #' type=IrErrorType + ERROR_CALL 'Unsupported callable reference: Q|test/Foo|::#' type=IrErrorType FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:IrErrorType correspondingProperty: PROPERTY name:test2a visibility:public modality:FINAL [val] BLOCK_BODY diff --git a/compiler/testData/ir/irText/expressions/callableReferenceTypeArguments.fir.txt b/compiler/testData/ir/irText/expressions/callableReferenceTypeArguments.fir.txt index e5f3d64d5d5..d53634c8158 100644 --- a/compiler/testData/ir/irText/expressions/callableReferenceTypeArguments.fir.txt +++ b/compiler/testData/ir/irText/expressions/callableReferenceTypeArguments.fir.txt @@ -34,7 +34,7 @@ FILE fqName: fileName:/callableReferenceTypeArguments.kt PROPERTY name:test1 visibility:public modality:FINAL [val] FIELD PROPERTY_BACKING_FIELD name:test1 type:kotlin.Function1 visibility:public [final,static] EXPRESSION_BODY - ERROR_CALL 'Unresolved reference: #' type=IrErrorType + ERROR_CALL 'Unsupported callable reference: ::#' type=IrErrorType FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.Function1 correspondingProperty: PROPERTY name:test1 visibility:public modality:FINAL [val] BLOCK_BODY @@ -43,7 +43,7 @@ FILE fqName: fileName:/callableReferenceTypeArguments.kt PROPERTY name:test2 visibility:public modality:FINAL [val] FIELD PROPERTY_BACKING_FIELD name:test2 type:kotlin.Function1, kotlin.Unit> visibility:public [final,static] EXPRESSION_BODY - ERROR_CALL 'Unresolved reference: #' type=IrErrorType + ERROR_CALL 'Unsupported callable reference: ::#' type=IrErrorType FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.Function1, kotlin.Unit> correspondingProperty: PROPERTY name:test2 visibility:public modality:FINAL [val] BLOCK_BODY @@ -52,7 +52,7 @@ FILE fqName: fileName:/callableReferenceTypeArguments.kt PROPERTY name:test3 visibility:public modality:FINAL [val] FIELD PROPERTY_BACKING_FIELD name:test3 type:kotlin.Function1 visibility:public [final,static] EXPRESSION_BODY - ERROR_CALL 'Unresolved reference: #' type=IrErrorType + ERROR_CALL 'Unsupported callable reference: ::#' type=IrErrorType FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.Function1 correspondingProperty: PROPERTY name:test3 visibility:public modality:FINAL [val] BLOCK_BODY diff --git a/compiler/testData/ir/irText/expressions/genericPropertyRef.fir.txt b/compiler/testData/ir/irText/expressions/genericPropertyRef.fir.txt index 5a8099aef50..5874885ad06 100644 --- a/compiler/testData/ir/irText/expressions/genericPropertyRef.fir.txt +++ b/compiler/testData/ir/irText/expressions/genericPropertyRef.fir.txt @@ -65,19 +65,31 @@ FILE fqName: fileName:/genericPropertyRef.kt public open fun toString (): kotlin.String declared in kotlin.Any $this: VALUE_PARAMETER name: type:kotlin.Any PROPERTY name:additionalText visibility:public modality:FINAL [delegated,val] - FIELD PROPERTY_BACKING_FIELD name:additionalText type:IrErrorType visibility:public [final,static] - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:IrErrorType + FIELD DELEGATE name:additionalText$delegate type:.DVal visibility:private [final,static] + EXPRESSION_BODY + CONSTRUCTOR_CALL 'public constructor (kmember: kotlin.Any) [primary] declared in .DVal' type=.DVal origin=null + kmember: PROPERTY_REFERENCE 'public final text: kotlin.String? [var]' field='FIELD PROPERTY_BACKING_FIELD name:text type:kotlin.String? visibility:public ' getter='public final fun (): kotlin.String? declared in .Value' setter='public final fun (: kotlin.String?): kotlin.Unit declared in .Value' type=kotlin.String? origin=null + FUN DELEGATED_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.Int correspondingProperty: PROPERTY name:additionalText visibility:public modality:FINAL [delegated,val] BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): IrErrorType declared in ' - GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:additionalText type:IrErrorType visibility:public [final,static] ' type=IrErrorType origin=null + RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in ' + CALL 'public final fun getValue (t: kotlin.Any?, p: kotlin.Any): kotlin.Int declared in .DVal' type=kotlin.Int origin=null + $this: GET_FIELD 'FIELD DELEGATE name:additionalText$delegate type:.DVal visibility:private [final,static] ' type=.DVal origin=GET_PROPERTY + t: CONST Null type=kotlin.Nothing? value=null + p: PROPERTY_REFERENCE 'public final additionalText: kotlin.Int [delegated,val]' field='FIELD DELEGATE name:additionalText$delegate type:.DVal visibility:private [final,static] ' getter=null setter=null type=kotlin.reflect.KProperty<*> origin=null PROPERTY name:additionalValue visibility:public modality:FINAL [delegated,val] - FIELD PROPERTY_BACKING_FIELD name:additionalValue type:IrErrorType visibility:public [final,static] - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:IrErrorType + FIELD DELEGATE name:additionalValue$delegate type:.DVal visibility:private [final,static] + EXPRESSION_BODY + CONSTRUCTOR_CALL 'public constructor (kmember: kotlin.Any) [primary] declared in .DVal' type=.DVal origin=null + kmember: PROPERTY_REFERENCE 'public final value: T of .Value [var]' field='FIELD PROPERTY_BACKING_FIELD name:value type:T of .Value visibility:public ' getter='public final fun (): T of .Value declared in .Value' setter='public final fun (: T of .Value): kotlin.Unit declared in .Value' type=T of .Value origin=null + FUN DELEGATED_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.Int correspondingProperty: PROPERTY name:additionalValue visibility:public modality:FINAL [delegated,val] BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): IrErrorType declared in ' - GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:additionalValue type:IrErrorType visibility:public [final,static] ' type=IrErrorType origin=null + RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in ' + CALL 'public final fun getValue (t: kotlin.Any?, p: kotlin.Any): kotlin.Int declared in .DVal' type=kotlin.Int origin=null + $this: GET_FIELD 'FIELD DELEGATE name:additionalValue$delegate type:.DVal visibility:private [final,static] ' type=.DVal origin=GET_PROPERTY + t: CONST Null type=kotlin.Nothing? value=null + p: PROPERTY_REFERENCE 'public final additionalValue: kotlin.Int [delegated,val]' field='FIELD DELEGATE name:additionalValue$delegate type:.DVal visibility:private [final,static] ' getter=null setter=null type=kotlin.reflect.KProperty<*> origin=null CLASS CLASS name:DVal modality:FINAL visibility:public superTypes:[kotlin.Any] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.DVal CONSTRUCTOR visibility:public <> (kmember:kotlin.Any) returnType:.DVal [primary] @@ -163,7 +175,7 @@ FILE fqName: fileName:/genericPropertyRef.kt PROPERTY name:barRef visibility:public modality:FINAL [val] FIELD PROPERTY_BACKING_FIELD name:barRef type:kotlin.String.Companion visibility:public [final,static] EXPRESSION_BODY - CALL 'public final fun (): T of declared in ' type=kotlin.String.Companion origin=null + PROPERTY_REFERENCE 'public final bar: T of [var]' field=null getter='public final fun (): T of declared in ' setter='public final fun (value: T of ): kotlin.Unit declared in ' type=kotlin.String.Companion origin=null FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.String.Companion correspondingProperty: PROPERTY name:barRef visibility:public modality:FINAL [val] BLOCK_BODY diff --git a/compiler/testData/ir/irText/expressions/propertyReferences.fir.txt b/compiler/testData/ir/irText/expressions/propertyReferences.fir.txt index 91b6440439d..5eab1c6266b 100644 --- a/compiler/testData/ir/irText/expressions/propertyReferences.fir.txt +++ b/compiler/testData/ir/irText/expressions/propertyReferences.fir.txt @@ -92,7 +92,7 @@ FILE fqName: fileName:/propertyReferences.kt PROPERTY name:test_valWithBackingField visibility:public modality:FINAL [val] FIELD PROPERTY_BACKING_FIELD name:test_valWithBackingField type:kotlin.Int visibility:public [final,static] EXPRESSION_BODY - CALL 'public final fun (): kotlin.Int declared in ' type=kotlin.Int origin=null + PROPERTY_REFERENCE 'public final valWithBackingField: kotlin.Int [val]' field='FIELD PROPERTY_BACKING_FIELD name:valWithBackingField type:kotlin.Int visibility:public [final,static] ' getter='public final fun (): kotlin.Int declared in ' setter=null type=kotlin.Int origin=null FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.Int correspondingProperty: PROPERTY name:test_valWithBackingField visibility:public modality:FINAL [val] BLOCK_BODY @@ -116,7 +116,7 @@ FILE fqName: fileName:/propertyReferences.kt PROPERTY name:test_varWithBackingField visibility:public modality:FINAL [val] FIELD PROPERTY_BACKING_FIELD name:test_varWithBackingField type:kotlin.Int visibility:public [final,static] EXPRESSION_BODY - CALL 'public final fun (): kotlin.Int declared in ' type=kotlin.Int origin=null + PROPERTY_REFERENCE 'public final varWithBackingField: kotlin.Int [var]' field='FIELD PROPERTY_BACKING_FIELD name:varWithBackingField type:kotlin.Int visibility:public [static] ' getter='public final fun (): kotlin.Int declared in ' setter='public final fun (: kotlin.Int): kotlin.Unit declared in ' type=kotlin.Int origin=null FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.Int correspondingProperty: PROPERTY name:test_varWithBackingField visibility:public modality:FINAL [val] BLOCK_BODY @@ -130,7 +130,7 @@ FILE fqName: fileName:/propertyReferences.kt correspondingProperty: PROPERTY name:varWithBackingFieldAndAccessors visibility:public modality:FINAL [var] BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in ' - ERROR_CALL 'No getter found for F|/varWithBackingFieldAndAccessors|' type=kotlin.Int + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:varWithBackingFieldAndAccessors type:kotlin.Int visibility:public [static] ' type=kotlin.Int origin=GET_PROPERTY FUN name: visibility:public modality:FINAL <> (value:kotlin.Int) returnType:kotlin.Unit correspondingProperty: PROPERTY name:varWithBackingFieldAndAccessors visibility:public modality:FINAL [var] VALUE_PARAMETER name:value index:0 type:kotlin.Int @@ -140,7 +140,7 @@ FILE fqName: fileName:/propertyReferences.kt PROPERTY name:test_varWithBackingFieldAndAccessors visibility:public modality:FINAL [val] FIELD PROPERTY_BACKING_FIELD name:test_varWithBackingFieldAndAccessors type:kotlin.Int visibility:public [final,static] EXPRESSION_BODY - CALL 'public final fun (): kotlin.Int declared in ' type=kotlin.Int origin=null + PROPERTY_REFERENCE 'public final varWithBackingFieldAndAccessors: kotlin.Int [var]' field='FIELD PROPERTY_BACKING_FIELD name:varWithBackingFieldAndAccessors type:kotlin.Int visibility:public [static] ' getter='public final fun (): kotlin.Int declared in ' setter='public final fun (value: kotlin.Int): kotlin.Unit declared in ' type=kotlin.Int origin=null FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.Int correspondingProperty: PROPERTY name:test_varWithBackingFieldAndAccessors visibility:public modality:FINAL [val] BLOCK_BODY @@ -155,7 +155,7 @@ FILE fqName: fileName:/propertyReferences.kt PROPERTY name:test_valWithAccessors visibility:public modality:FINAL [val] FIELD PROPERTY_BACKING_FIELD name:test_valWithAccessors type:kotlin.Int visibility:public [final,static] EXPRESSION_BODY - CALL 'public final fun (): kotlin.Int declared in ' type=kotlin.Int origin=null + PROPERTY_REFERENCE 'public final valWithAccessors: kotlin.Int [val]' field=null getter='public final fun (): kotlin.Int declared in ' setter=null type=kotlin.Int origin=null FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.Int correspondingProperty: PROPERTY name:test_valWithAccessors visibility:public modality:FINAL [val] BLOCK_BODY @@ -174,50 +174,63 @@ FILE fqName: fileName:/propertyReferences.kt PROPERTY name:test_varWithAccessors visibility:public modality:FINAL [val] FIELD PROPERTY_BACKING_FIELD name:test_varWithAccessors type:kotlin.Int visibility:public [final,static] EXPRESSION_BODY - CALL 'public final fun (): kotlin.Int declared in ' type=kotlin.Int origin=null + PROPERTY_REFERENCE 'public final varWithAccessors: kotlin.Int [var]' field=null getter='public final fun (): kotlin.Int declared in ' setter='public final fun (value: kotlin.Int): kotlin.Unit declared in ' type=kotlin.Int origin=null FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.Int correspondingProperty: PROPERTY name:test_varWithAccessors visibility:public modality:FINAL [val] BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in ' GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:test_varWithAccessors type:kotlin.Int visibility:public [final,static] ' type=kotlin.Int origin=null PROPERTY name:delegatedVal visibility:public modality:FINAL [delegated,val] - FIELD PROPERTY_BACKING_FIELD name:delegatedVal type:IrErrorType visibility:public [final,static] - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:IrErrorType + FIELD DELEGATE name:delegatedVal$delegate type:.Delegate visibility:private [final,static] + EXPRESSION_BODY + GET_OBJECT 'CLASS OBJECT name:Delegate modality:FINAL visibility:public superTypes:[kotlin.Any]' type=.Delegate + FUN DELEGATED_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.Int correspondingProperty: PROPERTY name:delegatedVal visibility:public modality:FINAL [delegated,val] BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): IrErrorType declared in ' - GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:delegatedVal type:IrErrorType visibility:public [final,static] ' type=IrErrorType origin=null + RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in ' + CALL 'public final fun getValue (thisRef: kotlin.Any?, kProp: kotlin.Any): kotlin.Int declared in .Delegate' type=kotlin.Int origin=null + $this: GET_FIELD 'FIELD DELEGATE name:delegatedVal$delegate type:.Delegate visibility:private [final,static] ' type=.Delegate origin=GET_PROPERTY + thisRef: CONST Null type=kotlin.Nothing? value=null + kProp: PROPERTY_REFERENCE 'public final delegatedVal: kotlin.Int [delegated,val]' field='FIELD DELEGATE name:delegatedVal$delegate type:.Delegate visibility:private [final,static] ' getter=null setter=null type=kotlin.reflect.KProperty<*> origin=null PROPERTY name:test_delegatedVal visibility:public modality:FINAL [val] - FIELD PROPERTY_BACKING_FIELD name:test_delegatedVal type:IrErrorType visibility:public [final,static] + FIELD PROPERTY_BACKING_FIELD name:test_delegatedVal type:kotlin.Int visibility:public [final,static] EXPRESSION_BODY - CALL 'public final fun (): IrErrorType declared in ' type=IrErrorType origin=null - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:IrErrorType + PROPERTY_REFERENCE 'public final delegatedVal: kotlin.Int [delegated,val]' field='FIELD DELEGATE name:delegatedVal$delegate type:.Delegate visibility:private [final,static] ' getter='public final fun (): kotlin.Int declared in ' setter=null type=kotlin.Int origin=null + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.Int correspondingProperty: PROPERTY name:test_delegatedVal visibility:public modality:FINAL [val] BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): IrErrorType declared in ' - GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:test_delegatedVal type:IrErrorType visibility:public [final,static] ' type=IrErrorType origin=null + RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in ' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:test_delegatedVal type:kotlin.Int visibility:public [final,static] ' type=kotlin.Int origin=null PROPERTY name:delegatedVar visibility:public modality:FINAL [delegated,var] - FIELD PROPERTY_BACKING_FIELD name:delegatedVar type:IrErrorType visibility:public [static] - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:IrErrorType - correspondingProperty: PROPERTY name:delegatedVar visibility:public modality:FINAL [delegated,var] - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): IrErrorType declared in ' - GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:delegatedVar type:IrErrorType visibility:public [static] ' type=IrErrorType origin=null - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> (:IrErrorType) returnType:kotlin.Unit - correspondingProperty: PROPERTY name:delegatedVar visibility:public modality:FINAL [delegated,var] - VALUE_PARAMETER name: index:0 type:IrErrorType - BLOCK_BODY - SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:delegatedVar type:IrErrorType visibility:public [static] ' type=kotlin.Unit origin=null - value: GET_VAR ': IrErrorType declared in .' type=IrErrorType origin=null - PROPERTY name:test_delegatedVar visibility:public modality:FINAL [val] - FIELD PROPERTY_BACKING_FIELD name:test_delegatedVar type:IrErrorType visibility:public [final,static] + FIELD DELEGATE name:delegatedVar$delegate type:.Delegate visibility:private [final,static] EXPRESSION_BODY - CALL 'public final fun (): IrErrorType declared in ' type=IrErrorType origin=null - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:IrErrorType + GET_OBJECT 'CLASS OBJECT name:Delegate modality:FINAL visibility:public superTypes:[kotlin.Any]' type=.Delegate + FUN DELEGATED_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.Int + correspondingProperty: PROPERTY name:delegatedVar visibility:public modality:FINAL [delegated,var] + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in ' + CALL 'public final fun getValue (thisRef: kotlin.Any?, kProp: kotlin.Any): kotlin.Int declared in .Delegate' type=kotlin.Int origin=null + $this: GET_FIELD 'FIELD DELEGATE name:delegatedVar$delegate type:.Delegate visibility:private [final,static] ' type=.Delegate origin=GET_PROPERTY + thisRef: CONST Null type=kotlin.Nothing? value=null + kProp: PROPERTY_REFERENCE 'public final delegatedVar: kotlin.Int [delegated,var]' field='FIELD DELEGATE name:delegatedVar$delegate type:.Delegate visibility:private [final,static] ' getter=null setter=null type=kotlin.reflect.KProperty<*> origin=null + FUN DELEGATED_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> (:kotlin.Int) returnType:kotlin.Unit + correspondingProperty: PROPERTY name:delegatedVar visibility:public modality:FINAL [delegated,var] + VALUE_PARAMETER name: index:0 type:kotlin.Int + BLOCK_BODY + CALL 'public final fun setValue (thisRef: kotlin.Any?, kProp: kotlin.Any, value: kotlin.Int): kotlin.Unit declared in .Delegate' type=kotlin.Unit origin=null + $this: GET_FIELD 'FIELD DELEGATE name:delegatedVar$delegate type:.Delegate visibility:private [final,static] ' type=.Delegate origin=GET_PROPERTY + thisRef: CONST Null type=kotlin.Nothing? value=null + kProp: PROPERTY_REFERENCE 'public final delegatedVar: kotlin.Int [delegated,var]' field='FIELD DELEGATE name:delegatedVar$delegate type:.Delegate visibility:private [final,static] ' getter='public final fun (): kotlin.Int declared in ' setter=null type=kotlin.reflect.KProperty<*> origin=null + value: GET_VAR ': kotlin.Int declared in .' type=kotlin.Int origin=null + PROPERTY name:test_delegatedVar visibility:public modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:test_delegatedVar type:kotlin.Int visibility:public [final,static] + EXPRESSION_BODY + PROPERTY_REFERENCE 'public final delegatedVar: kotlin.Int [delegated,var]' field='FIELD DELEGATE name:delegatedVar$delegate type:.Delegate visibility:private [final,static] ' getter='public final fun (): kotlin.Int declared in ' setter='public final fun (: kotlin.Int): kotlin.Unit declared in ' type=kotlin.Int origin=null + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.Int correspondingProperty: PROPERTY name:test_delegatedVar visibility:public modality:FINAL [val] BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): IrErrorType declared in ' - GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:test_delegatedVar type:IrErrorType visibility:public [final,static] ' type=IrErrorType origin=null + RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in ' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:test_delegatedVar type:kotlin.Int visibility:public [final,static] ' type=kotlin.Int origin=null PROPERTY name:constVal visibility:public modality:FINAL [val] FIELD PROPERTY_BACKING_FIELD name:constVal type:kotlin.Int visibility:public [final,static] EXPRESSION_BODY @@ -230,7 +243,7 @@ FILE fqName: fileName:/propertyReferences.kt PROPERTY name:test_constVal visibility:public modality:FINAL [val] FIELD PROPERTY_BACKING_FIELD name:test_constVal type:kotlin.Int visibility:public [final,static] EXPRESSION_BODY - CALL 'public final fun (): kotlin.Int declared in ' type=kotlin.Int origin=null + PROPERTY_REFERENCE 'public final constVal: kotlin.Int [val]' field='FIELD PROPERTY_BACKING_FIELD name:constVal type:kotlin.Int visibility:public [final,static] ' getter='public final fun (): kotlin.Int declared in ' setter=null type=kotlin.Int origin=null FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.Int correspondingProperty: PROPERTY name:test_constVal visibility:public modality:FINAL [val] BLOCK_BODY @@ -239,7 +252,7 @@ FILE fqName: fileName:/propertyReferences.kt PROPERTY name:test_J_CONST visibility:public modality:FINAL [val] FIELD PROPERTY_BACKING_FIELD name:test_J_CONST type:kotlin.Int visibility:public [final,static] EXPRESSION_BODY - GET_FIELD 'FIELD IR_EXTERNAL_JAVA_DECLARATION_STUB name:CONST type:kotlin.Int visibility:public [final,static] ' type=kotlin.Int origin=GET_PROPERTY + ERROR_CALL 'Unsupported callable reference: Q|J|::R|/J.CONST|' type=kotlin.Int FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.Int correspondingProperty: PROPERTY name:test_J_CONST visibility:public modality:FINAL [val] BLOCK_BODY @@ -248,7 +261,7 @@ FILE fqName: fileName:/propertyReferences.kt PROPERTY name:test_J_nonConst visibility:public modality:FINAL [val] FIELD PROPERTY_BACKING_FIELD name:test_J_nonConst type:kotlin.Int visibility:public [final,static] EXPRESSION_BODY - GET_FIELD 'FIELD IR_EXTERNAL_JAVA_DECLARATION_STUB name:nonConst type:kotlin.Int visibility:public [static] ' type=kotlin.Int origin=GET_PROPERTY + ERROR_CALL 'Unsupported callable reference: Q|J|::R|/J.nonConst|' type=kotlin.Int FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.Int correspondingProperty: PROPERTY name:test_J_nonConst visibility:public modality:FINAL [val] BLOCK_BODY @@ -257,7 +270,7 @@ FILE fqName: fileName:/propertyReferences.kt PROPERTY name:test_varWithPrivateSet visibility:public modality:FINAL [val] FIELD PROPERTY_BACKING_FIELD name:test_varWithPrivateSet type:IrErrorType visibility:public [final,static] EXPRESSION_BODY - ERROR_CALL 'Unresolved reference: #' type=IrErrorType + ERROR_CALL 'Unsupported callable reference: Q|C|::#' type=IrErrorType FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:IrErrorType correspondingProperty: PROPERTY name:test_varWithPrivateSet visibility:public modality:FINAL [val] BLOCK_BODY @@ -266,7 +279,7 @@ FILE fqName: fileName:/propertyReferences.kt PROPERTY name:test_varWithProtectedSet visibility:public modality:FINAL [val] FIELD PROPERTY_BACKING_FIELD name:test_varWithProtectedSet type:IrErrorType visibility:public [final,static] EXPRESSION_BODY - ERROR_CALL 'Unresolved reference: #' type=IrErrorType + ERROR_CALL 'Unsupported callable reference: Q|C|::#' type=IrErrorType FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:IrErrorType correspondingProperty: PROPERTY name:test_varWithProtectedSet visibility:public modality:FINAL [val] BLOCK_BODY diff --git a/compiler/testData/ir/irText/expressions/reflectionLiterals.fir.txt b/compiler/testData/ir/irText/expressions/reflectionLiterals.fir.txt index 6e0bce645c5..e16c3a81e7b 100644 --- a/compiler/testData/ir/irText/expressions/reflectionLiterals.fir.txt +++ b/compiler/testData/ir/irText/expressions/reflectionLiterals.fir.txt @@ -55,7 +55,7 @@ FILE fqName: fileName:/reflectionLiterals.kt PROPERTY name:test3 visibility:public modality:FINAL [val] FIELD PROPERTY_BACKING_FIELD name:test3 type:IrErrorType visibility:public [final,static] EXPRESSION_BODY - ERROR_CALL 'Unresolved reference: #' type=IrErrorType + ERROR_CALL 'Unsupported callable reference: Q|A|::#' type=IrErrorType FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:IrErrorType correspondingProperty: PROPERTY name:test3 visibility:public modality:FINAL [val] BLOCK_BODY @@ -73,7 +73,7 @@ FILE fqName: fileName:/reflectionLiterals.kt PROPERTY name:test5 visibility:public modality:FINAL [val] FIELD PROPERTY_BACKING_FIELD name:test5 type:IrErrorType visibility:public [final,static] EXPRESSION_BODY - ERROR_CALL 'Unresolved reference: #' type=IrErrorType + ERROR_CALL 'Unsupported callable reference: R|/A.A|()::#' type=IrErrorType FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:IrErrorType correspondingProperty: PROPERTY name:test5 visibility:public modality:FINAL [val] BLOCK_BODY @@ -82,7 +82,7 @@ FILE fqName: fileName:/reflectionLiterals.kt PROPERTY name:test6 visibility:public modality:FINAL [val] FIELD PROPERTY_BACKING_FIELD name:test6 type:IrErrorType visibility:public [final,static] EXPRESSION_BODY - ERROR_CALL 'Unresolved reference: #' type=IrErrorType + ERROR_CALL 'Unsupported callable reference: ::#' type=IrErrorType FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:IrErrorType correspondingProperty: PROPERTY name:test6 visibility:public modality:FINAL [val] BLOCK_BODY diff --git a/compiler/testData/ir/irText/expressions/sam/samConstructors.fir.txt b/compiler/testData/ir/irText/expressions/sam/samConstructors.fir.txt index 1af979f3594..23f6e359a10 100644 --- a/compiler/testData/ir/irText/expressions/sam/samConstructors.fir.txt +++ b/compiler/testData/ir/irText/expressions/sam/samConstructors.fir.txt @@ -19,7 +19,7 @@ FILE fqName: fileName:/samConstructors.kt BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun test3 (): IrErrorType declared in ' ERROR_CALL 'Unresolved reference: #' type=IrErrorType - ERROR_CALL 'Unresolved reference: #' type=IrErrorType + ERROR_CALL 'Unsupported callable reference: ::#' type=IrErrorType FUN name:test4 visibility:public modality:FINAL <> () returnType:IrErrorType BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun test4 (): IrErrorType declared in ' diff --git a/compiler/testData/ir/irText/expressions/sam/samConversionsWithSmartCasts.fir.txt b/compiler/testData/ir/irText/expressions/sam/samConversionsWithSmartCasts.fir.txt index 5c666568d00..810ae58619e 100644 --- a/compiler/testData/ir/irText/expressions/sam/samConversionsWithSmartCasts.fir.txt +++ b/compiler/testData/ir/irText/expressions/sam/samConversionsWithSmartCasts.fir.txt @@ -83,4 +83,4 @@ FILE fqName: fileName:/samConversionsWithSmartCasts.kt BLOCK_BODY CALL 'public open fun run1 (r: java.lang.Runnable?): kotlin.Unit declared in .J' type=kotlin.Unit origin=null $this: CONSTRUCTOR_CALL 'public constructor () [primary] declared in .J' type=.J origin=null - r: ERROR_CALL 'Unresolved reference: #' type=IrErrorType + r: ERROR_CALL 'Unsupported callable reference: ::#' type=IrErrorType diff --git a/compiler/testData/ir/irText/expressions/sam/samOperators.fir.txt b/compiler/testData/ir/irText/expressions/sam/samOperators.fir.txt index e4edfa98248..f2c1d7667f9 100644 --- a/compiler/testData/ir/irText/expressions/sam/samOperators.fir.txt +++ b/compiler/testData/ir/irText/expressions/sam/samOperators.fir.txt @@ -6,23 +6,23 @@ FILE fqName: fileName:/samOperators.kt BLOCK_BODY CALL 'public open fun get (k: java.lang.Runnable?): kotlin.Unit declared in .J' type=kotlin.Unit origin=null $this: ERROR_CALL 'Unresolved reference: this#' type=.J - k: ERROR_CALL 'Unresolved reference: #' type=IrErrorType + k: ERROR_CALL 'Unsupported callable reference: ::#' type=IrErrorType CALL 'public open fun get (k: java.lang.Runnable?, m: java.lang.Runnable?): kotlin.Unit declared in .J' type=kotlin.Unit origin=null $this: ERROR_CALL 'Unresolved reference: this#' type=.J - k: ERROR_CALL 'Unresolved reference: #' type=IrErrorType - m: ERROR_CALL 'Unresolved reference: #' type=IrErrorType + k: ERROR_CALL 'Unsupported callable reference: ::#' type=IrErrorType + m: ERROR_CALL 'Unsupported callable reference: ::#' type=IrErrorType FUN name:test2 visibility:public modality:FINAL <> ($receiver:.J) returnType:kotlin.Unit $receiver: VALUE_PARAMETER name: type:.J BLOCK_BODY CALL 'public open fun set (k: java.lang.Runnable?, v: java.lang.Runnable?): kotlin.Unit declared in .J' type=kotlin.Unit origin=null $this: ERROR_CALL 'Unresolved reference: this#' type=.J - k: ERROR_CALL 'Unresolved reference: #' type=IrErrorType - v: ERROR_CALL 'Unresolved reference: #' type=IrErrorType + k: ERROR_CALL 'Unsupported callable reference: ::#' type=IrErrorType + v: ERROR_CALL 'Unsupported callable reference: ::#' type=IrErrorType CALL 'public open fun set (k: java.lang.Runnable?, m: java.lang.Runnable?, v: java.lang.Runnable?): kotlin.Unit declared in .J' type=kotlin.Unit origin=null $this: ERROR_CALL 'Unresolved reference: this#' type=.J - k: ERROR_CALL 'Unresolved reference: #' type=IrErrorType - m: ERROR_CALL 'Unresolved reference: #' type=IrErrorType - v: ERROR_CALL 'Unresolved reference: #' type=IrErrorType + k: ERROR_CALL 'Unsupported callable reference: ::#' type=IrErrorType + m: ERROR_CALL 'Unsupported callable reference: ::#' type=IrErrorType + v: ERROR_CALL 'Unsupported callable reference: ::#' type=IrErrorType FUN name:test3 visibility:public modality:FINAL <> ($receiver:.J) returnType:kotlin.Unit $receiver: VALUE_PARAMETER name: type:.J BLOCK_BODY diff --git a/compiler/testData/ir/irText/types/genericPropertyReferenceType.fir.txt b/compiler/testData/ir/irText/types/genericPropertyReferenceType.fir.txt index e7db1cd1524..0f92e9d63ce 100644 --- a/compiler/testData/ir/irText/types/genericPropertyReferenceType.fir.txt +++ b/compiler/testData/ir/irText/types/genericPropertyReferenceType.fir.txt @@ -56,11 +56,11 @@ FILE fqName: fileName:/genericPropertyReferenceType.kt FUN name:test1 visibility:public modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY CALL 'public final fun use (p: kotlin.reflect.KMutableProperty): kotlin.Unit declared in ' type=kotlin.Unit origin=null - p: CALL 'public final fun (): IrErrorType declared in ' type=IrErrorType origin=null + p: PROPERTY_REFERENCE 'public final y: IrErrorType [var]' field=null getter='public final fun (): IrErrorType declared in ' setter='public final fun (v: IrErrorType): kotlin.Unit declared in ' type=IrErrorType origin=null FUN name:test2 visibility:public modality:FINAL <> (a:kotlin.Any) returnType:kotlin.Unit VALUE_PARAMETER name:a index:0 type:kotlin.Any BLOCK_BODY TYPE_OP type=.C origin=CAST typeOperand=.C GET_VAR 'a: kotlin.Any declared in .test2' type=kotlin.Any origin=null CALL 'public final fun use (p: kotlin.reflect.KMutableProperty): kotlin.Unit declared in ' type=kotlin.Unit origin=null - p: ERROR_CALL 'Unresolved reference: #' type=IrErrorType + p: ERROR_CALL 'Unsupported callable reference: R|/a|::#' type=IrErrorType