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 a619b122da7..a6514e45fbb 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 @@ -570,9 +570,10 @@ internal fun KtExpression?.generateAssignment( } } -internal fun FirModifiableAccessorsOwner.generateAccessorsByDelegate(session: FirSession, member: Boolean) { +internal fun FirModifiableAccessorsOwner.generateAccessorsByDelegate(session: FirSession, member: Boolean, stubMode: Boolean) { val variable = this as FirVariable<*> val delegateFieldSymbol = delegateFieldSymbol ?: return + val delegate = delegate as? FirWrappedDelegateExpressionImpl ?: return fun delegateAccess() = FirQualifiedAccessExpressionImpl(session, null).apply { calleeReference = FirDelegateFieldReferenceImpl(session, null, delegateFieldSymbol) } @@ -588,6 +589,13 @@ internal fun FirModifiableAccessorsOwner.generateAccessorsByDelegate(session: Fi typeRef = FirImplicitKPropertyTypeRef(session, null, ConeStarProjection) } + delegate.delegateProvider = if (stubMode) FirExpressionStub(session, null) else FirFunctionCallImpl(session, null).apply { + explicitReceiver = delegate.expression + calleeReference = FirSimpleNamedReference(session, null, PROVIDE_DELEGATE) + arguments += thisRef() + arguments += propertyRef() + } + if (stubMode) return getter = (getter as? FirPropertyAccessorImpl) ?: FirPropertyAccessorImpl(session, null, true, Visibilities.UNKNOWN, FirImplicitTypeRefImpl(session, null)).apply Accessor@{ body = FirSingleExpressionBlock( @@ -631,4 +639,5 @@ internal fun FirModifiableAccessorsOwner.generateAccessorsByDelegate(session: Fi private val GET_VALUE = Name.identifier("getValue") private val SET_VALUE = Name.identifier("setValue") +private val PROVIDE_DELEGATE = Name.identifier("provideDelegate") 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 b71c8ba010a..87518b20415 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 = @@ -774,6 +774,7 @@ class RawFirBuilder(val session: FirSession, val stubMode: Boolean) { val initializer = if (property.hasInitializer()) { { property.initializer }.toFirExpression("Should have initializer") } else null + val delegateExpression by lazy { property.delegate?.expression } val firProperty = if (property.isLocal) { FirVariableImpl( session, @@ -782,9 +783,14 @@ class RawFirBuilder(val session: FirSession, val stubMode: Boolean) { propertyType, isVar, initializer, - delegate = property.delegate?.expression?.toFirExpression("Incorrect delegate expression") + delegate = delegateExpression?.let { + FirWrappedDelegateExpressionImpl( + session, it, + it.toFirExpression("Incorrect delegate expression") + ) + } ).apply { - generateAccessorsByDelegate(this@RawFirBuilder.session, member = false) + generateAccessorsByDelegate(this@RawFirBuilder.session, member = false, stubMode = stubMode) } } else { FirMemberPropertyImpl( @@ -804,13 +810,16 @@ class RawFirBuilder(val session: FirSession, val stubMode: Boolean) { isVar, initializer, if (property.hasDelegate()) { - { property.delegate?.expression }.toFirExpression("Should have delegate") + FirWrappedDelegateExpressionImpl( + session, if (stubMode) null else delegateExpression, + { delegateExpression }.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) + generateAccessorsByDelegate(this@RawFirBuilder.session, member = !property.isTopLevel, stubMode = stubMode) } } property.extractAnnotationsTo(firProperty) 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 50c25312d4a..45ac29ca75a 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 @@ -1063,6 +1063,20 @@ open class FirBodyResolveTransformer( } } + override fun transformWrappedDelegateExpression( + wrappedDelegateExpression: FirWrappedDelegateExpression, + data: Any? + ): CompositeTransformResult { + super.transformWrappedDelegateExpression(wrappedDelegateExpression, data) + with(wrappedDelegateExpression) { + val delegateProviderTypeRef = delegateProvider.typeRef + val useDelegateProvider = delegateProviderTypeRef is FirResolvedTypeRef && + delegateProviderTypeRef !is FirErrorTypeRef && + delegateProviderTypeRef.type !is ConeKotlinErrorType + return if (useDelegateProvider) delegateProvider.compose() else expression.compose() + } + } + override fun > transformVariable(variable: FirVariable, data: Any?): CompositeTransformResult { variable.transformChildrenWithoutAccessors(this, variable.returnTypeRef) if (variable.initializer != null) { @@ -1100,7 +1114,7 @@ open class FirBodyResolveTransformer( } override fun transformExpression(expression: FirExpression, data: Any?): CompositeTransformResult { - if (expression.resultType is FirImplicitTypeRef && expression !is FirWrappedArgumentExpression) { + if (expression.resultType is FirImplicitTypeRef && expression !is FirWrappedExpression) { val type = FirErrorTypeRefImpl(session, expression.psi, "Type calculating for ${expression::class} is not supported") expression.resultType = type } diff --git a/compiler/fir/resolve/testData/resolve/stdlib/simpleDelegateProvider.kt b/compiler/fir/resolve/testData/resolve/stdlib/simpleDelegateProvider.kt new file mode 100644 index 00000000000..7474bbf2fae --- /dev/null +++ b/compiler/fir/resolve/testData/resolve/stdlib/simpleDelegateProvider.kt @@ -0,0 +1,9 @@ +class Delegate(val value: String) { + operator fun getValue(thisRef: Any?, property: Any?) = value +} + +class DelegateProvider(val value: String) { + operator fun provideDelegate(thisRef: Any?, property: Any?) = Delegate(value) +} + +val testTopLevel by DelegateProvider("OK") diff --git a/compiler/fir/resolve/testData/resolve/stdlib/simpleDelegateProvider.txt b/compiler/fir/resolve/testData/resolve/stdlib/simpleDelegateProvider.txt new file mode 100644 index 00000000000..53afe52c117 --- /dev/null +++ b/compiler/fir/resolve/testData/resolve/stdlib/simpleDelegateProvider.txt @@ -0,0 +1,31 @@ +FILE: simpleDelegateProvider.kt + public final class Delegate : R|kotlin/Any| { + public constructor(value: R|kotlin/String|): R|Delegate| { + super() + } + + public final val value: R|kotlin/String| = R|/value| + public get(): R|kotlin/String| + + public final operator fun getValue(thisRef: R|kotlin/Any|?, property: R|kotlin/Any|?): R|kotlin/String| { + ^getValue R|/Delegate.value| + } + + } + public final class DelegateProvider : R|kotlin/Any| { + public constructor(value: R|kotlin/String|): R|DelegateProvider| { + super() + } + + public final val value: R|kotlin/String| = R|/value| + public get(): R|kotlin/String| + + public final operator fun provideDelegate(thisRef: R|kotlin/Any|?, property: R|kotlin/Any|?): R|Delegate| { + ^provideDelegate R|/Delegate.Delegate|(R|/DelegateProvider.value|) + } + + } + public final val testTopLevel: R|kotlin/String|by R|/DelegateProvider.DelegateProvider|(String(OK)).R|/DelegateProvider.provideDelegate|(Null(null), ::R|/testTopLevel|) + public get(): R|kotlin/String| { + ^ D|/testTopLevel|.R|/Delegate.getValue|(Null(null), ::R|/testTopLevel|) + } 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 74d730484a7..34b158c2ea4 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,11 @@ public class FirResolveTestCaseWithStdlibGenerated extends AbstractFirResolveTes runTest("compiler/fir/resolve/testData/resolve/stdlib/reflectionClass.kt"); } + @TestMetadata("simpleDelegateProvider.kt") + public void testSimpleDelegateProvider() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/stdlib/simpleDelegateProvider.kt"); + } + @TestMetadata("simpleDelegatedToMap.kt") public void testSimpleDelegatedToMap() throws Exception { runTest("compiler/fir/resolve/testData/resolve/stdlib/simpleDelegatedToMap.kt"); 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 8e5844484b1..f49cdea2610 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/FirRenderer.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/FirRenderer.kt @@ -625,6 +625,10 @@ class FirRenderer(builder: StringBuilder) : FirVisitorVoid() { print("${constExpression.kind}(${constExpression.value})") } + override fun visitWrappedDelegateExpression(wrappedDelegateExpression: FirWrappedDelegateExpression) { + wrappedDelegateExpression.expression.accept(this) + } + override fun visitNamedArgumentExpression(namedArgumentExpression: FirNamedArgumentExpression) { print(namedArgumentExpression.name) print(" = ") 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 2c9ab076ef6..6f63c153133 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,7 +8,6 @@ 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 diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/expressions/FirWrappedArgumentExpression.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/expressions/FirWrappedArgumentExpression.kt index b8695e8b70c..56f7bdb50b7 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/expressions/FirWrappedArgumentExpression.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/expressions/FirWrappedArgumentExpression.kt @@ -13,24 +13,13 @@ import org.jetbrains.kotlin.fir.visitors.FirVisitor abstract class FirWrappedArgumentExpression( session: FirSession, psi: PsiElement? -) : FirExpression(session, psi) { - abstract val expression: FirExpression - +) : FirWrappedExpression(session, psi) { open val isSpread: Boolean get() = false override val typeRef: FirTypeRef get() = expression.typeRef - override fun replaceTypeRef(newTypeRef: FirTypeRef) { - throw AssertionError("We should not try to replace type reference in ${this::class}") - } - override fun accept(visitor: FirVisitor, data: D): R = visitor.visitWrappedArgumentExpression(this, data) - - override fun acceptChildren(visitor: FirVisitor, data: D) { - expression.accept(visitor, data) - super.acceptChildren(visitor, data) - } } \ No newline at end of file diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/expressions/FirWrappedDelegateExpression.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/expressions/FirWrappedDelegateExpression.kt new file mode 100644 index 00000000000..be8bc0d1a90 --- /dev/null +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/expressions/FirWrappedDelegateExpression.kt @@ -0,0 +1,30 @@ +/* + * 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.expressions + +import com.intellij.psi.PsiElement +import org.jetbrains.kotlin.fir.FirSession +import org.jetbrains.kotlin.fir.types.FirTypeRef +import org.jetbrains.kotlin.fir.visitors.FirVisitor + +abstract class FirWrappedDelegateExpression( + session: FirSession, + psi: PsiElement? +) : FirWrappedExpression(session, psi) { + abstract val delegateProvider: FirExpression + + override val typeRef: FirTypeRef + get() = expression.typeRef + + override fun accept(visitor: FirVisitor, data: D): R { + return visitor.visitWrappedDelegateExpression(this, data) + } + + override fun acceptChildren(visitor: FirVisitor, data: D) { + delegateProvider.accept(visitor, data) + super.acceptChildren(visitor, data) + } +} \ No newline at end of file diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/expressions/FirWrappedExpression.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/expressions/FirWrappedExpression.kt new file mode 100644 index 00000000000..bb6c0fcc8fa --- /dev/null +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/expressions/FirWrappedExpression.kt @@ -0,0 +1,30 @@ +/* + * 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.expressions + +import com.intellij.psi.PsiElement +import org.jetbrains.kotlin.fir.FirSession +import org.jetbrains.kotlin.fir.types.FirTypeRef +import org.jetbrains.kotlin.fir.visitors.FirVisitor + +abstract class FirWrappedExpression( + session: FirSession, + psi: PsiElement? +) : FirExpression(session, psi) { + abstract val expression: FirExpression + + override fun replaceTypeRef(newTypeRef: FirTypeRef) { + throw AssertionError("We should not try to replace type reference in ${this::class}") + } + + override fun accept(visitor: FirVisitor, data: D): R = + visitor.visitWrappedExpression(this, data) + + override fun acceptChildren(visitor: FirVisitor, data: D) { + expression.accept(visitor, data) + super.acceptChildren(visitor, data) + } +} \ No newline at end of file diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/expressions/impl/FirWrappedDelegateExpressionImpl.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/expressions/impl/FirWrappedDelegateExpressionImpl.kt new file mode 100644 index 00000000000..b8b62fd1292 --- /dev/null +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/expressions/impl/FirWrappedDelegateExpressionImpl.kt @@ -0,0 +1,29 @@ +/* + * 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.expressions.impl + +import com.intellij.psi.PsiElement +import org.jetbrains.kotlin.fir.FirElement +import org.jetbrains.kotlin.fir.FirSession +import org.jetbrains.kotlin.fir.expressions.FirExpression +import org.jetbrains.kotlin.fir.expressions.FirWrappedDelegateExpression +import org.jetbrains.kotlin.fir.transformSingle +import org.jetbrains.kotlin.fir.visitors.FirTransformer + +class FirWrappedDelegateExpressionImpl( + session: FirSession, + psi: PsiElement?, + override var expression: FirExpression +) : FirWrappedDelegateExpression(session, psi) { + override lateinit var delegateProvider: FirExpression + + override fun transformChildren(transformer: FirTransformer, data: D): FirElement { + expression = expression.transformSingle(transformer, data) + delegateProvider = delegateProvider.transformSingle(transformer, data) + + return super.transformChildren(transformer, data) + } +} \ 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 b94799ebeb5..67fef015c96 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 @@ -320,8 +320,12 @@ abstract class FirTransformer : FirVisitor { + return transformExpression(wrappedExpression, data) + } + open fun transformWrappedArgumentExpression(wrappedArgumentExpression: FirWrappedArgumentExpression, data: D): CompositeTransformResult { - return transformExpression(wrappedArgumentExpression, data) + return transformWrappedExpression(wrappedArgumentExpression, data) } open fun transformLambdaArgumentExpression(lambdaArgumentExpression: FirLambdaArgumentExpression, data: D): CompositeTransformResult { @@ -336,6 +340,10 @@ abstract class FirTransformer : FirVisitor { + return transformWrappedExpression(wrappedDelegateExpression, data) + } + open fun transformClass(klass: FirClass, data: D): CompositeTransformResult { return transformStatement(klass, data) } @@ -872,6 +880,14 @@ abstract class FirTransformer : FirVisitor { + return transformWrappedDelegateExpression(wrappedDelegateExpression, data) + } + + final override fun visitWrappedExpression(wrappedExpression: FirWrappedExpression, data: D): CompositeTransformResult { + return transformWrappedExpression(wrappedExpression, data) + } + final override fun visitElement(element: FirElement, data: D): CompositeTransformResult { return transformElement(element, 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 3f4e927107d..0aa3b9ea75d 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 @@ -320,8 +320,12 @@ abstract class FirVisitor { return visitUnknownTypeExpression(whenSubjectExpression, data) } + open fun visitWrappedExpression(wrappedExpression: FirWrappedExpression, data: D): R { + return visitExpression(wrappedExpression, data) + } + open fun visitWrappedArgumentExpression(wrappedArgumentExpression: FirWrappedArgumentExpression, data: D): R { - return visitExpression(wrappedArgumentExpression, data) + return visitWrappedExpression(wrappedArgumentExpression, data) } open fun visitLambdaArgumentExpression(lambdaArgumentExpression: FirLambdaArgumentExpression, data: D): R { @@ -336,6 +340,10 @@ abstract class FirVisitor { return visitWrappedArgumentExpression(spreadArgumentExpression, data) } + open fun visitWrappedDelegateExpression(wrappedDelegateExpression: FirWrappedDelegateExpression, data: D): R { + return visitWrappedExpression(wrappedDelegateExpression, data) + } + open fun visitClass(klass: FirClass, data: D): R { return visitStatement(klass, 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 624a9d8168b..dd4194ebdb4 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 @@ -320,8 +320,12 @@ abstract class FirVisitorVoid : FirVisitor() { visitUnknownTypeExpression(whenSubjectExpression, null) } + open fun visitWrappedExpression(wrappedExpression: FirWrappedExpression) { + visitExpression(wrappedExpression, null) + } + open fun visitWrappedArgumentExpression(wrappedArgumentExpression: FirWrappedArgumentExpression) { - visitExpression(wrappedArgumentExpression, null) + visitWrappedExpression(wrappedArgumentExpression, null) } open fun visitLambdaArgumentExpression(lambdaArgumentExpression: FirLambdaArgumentExpression) { @@ -336,6 +340,10 @@ abstract class FirVisitorVoid : FirVisitor() { visitWrappedArgumentExpression(spreadArgumentExpression, null) } + open fun visitWrappedDelegateExpression(wrappedDelegateExpression: FirWrappedDelegateExpression) { + visitWrappedExpression(wrappedDelegateExpression, null) + } + open fun visitClass(klass: FirClass) { visitStatement(klass, null) } @@ -872,6 +880,14 @@ abstract class FirVisitorVoid : FirVisitor() { visitWrappedArgumentExpression(wrappedArgumentExpression) } + final override fun visitWrappedDelegateExpression(wrappedDelegateExpression: FirWrappedDelegateExpression, data: Nothing?) { + visitWrappedDelegateExpression(wrappedDelegateExpression) + } + + final override fun visitWrappedExpression(wrappedExpression: FirWrappedExpression, data: Nothing?) { + visitWrappedExpression(wrappedExpression) + } + final override fun visitElement(element: FirElement, data: Nothing?) { visitElement(element) } diff --git a/compiler/testData/ir/irText/declarations/provideDelegate/differentReceivers.fir.txt b/compiler/testData/ir/irText/declarations/provideDelegate/differentReceivers.fir.txt index 413a4e270e8..ebca8c9ff2c 100644 --- a/compiler/testData/ir/irText/declarations/provideDelegate/differentReceivers.fir.txt +++ b/compiler/testData/ir/irText/declarations/provideDelegate/differentReceivers.fir.txt @@ -46,17 +46,21 @@ 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 DELEGATE name:testO$delegate type:.MyClass visibility:private [final,static] + FIELD DELEGATE name:testO$delegate type:kotlin.String 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 + CALL 'public final fun provideDelegate (host: kotlin.Any?, p: kotlin.Any): kotlin.String declared in ' type=kotlin.String origin=null + $receiver: CONSTRUCTOR_CALL 'public constructor (value: kotlin.String) [primary] declared in .MyClass' type=.MyClass origin=null + value: CONST String type=kotlin.String value="O" + host: CONST Null type=kotlin.Nothing? value=null + p: PROPERTY_REFERENCE 'public final testO: kotlin.String [delegated,val]' field=null getter=null setter=null type=kotlin.reflect.KProperty<*> origin=null + FUN DELEGATED_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.String correspondingProperty: PROPERTY name:testO visibility:public modality:FINAL [delegated,val] BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): IrErrorType declared in ' - 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 + 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:testO$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 testO: kotlin.String [delegated,val]' field='FIELD DELEGATE name:testO$delegate type:kotlin.String 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 @@ -70,13 +74,13 @@ FILE fqName: fileName:/differentReceivers.kt 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] + FIELD PROPERTY_BACKING_FIELD name:testOK type:kotlin.String visibility:public [final,static] EXPRESSION_BODY - 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 + CALL 'public final fun plus (other: kotlin.Any?): kotlin.String declared in kotlin.String' type=kotlin.String origin=null + $this: CALL 'public final fun (): kotlin.String declared in ' type=kotlin.String origin=null + other: CALL 'public final fun (): kotlin.String declared in ' type=kotlin.String origin=null + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.String correspondingProperty: PROPERTY name:testOK 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:testOK type:IrErrorType visibility:public [final,static] ' type=IrErrorType origin=null - + RETURN type=kotlin.Nothing from='public final fun (): kotlin.String declared in ' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:testOK type:kotlin.String visibility:public [final,static] ' type=kotlin.String origin=null diff --git a/compiler/testData/ir/irText/declarations/provideDelegate/local.fir.txt b/compiler/testData/ir/irText/declarations/provideDelegate/local.fir.txt index 5a5d5c42440..c421fb95fcd 100644 --- a/compiler/testData/ir/irText/declarations/provideDelegate/local.fir.txt +++ b/compiler/testData/ir/irText/declarations/provideDelegate/local.fir.txt @@ -78,5 +78,4 @@ FILE fqName: fileName:/local.kt $this: VALUE_PARAMETER name: type:kotlin.Any FUN name:foo visibility:public modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY - VAR name:testMember type:IrErrorType [val] - + VAR name:testMember type:kotlin.String [val] diff --git a/compiler/testData/ir/irText/declarations/provideDelegate/localDifferentReceivers.fir.txt b/compiler/testData/ir/irText/declarations/provideDelegate/localDifferentReceivers.fir.txt index 18e79c09d3c..8ba35888b3a 100644 --- a/compiler/testData/ir/irText/declarations/provideDelegate/localDifferentReceivers.fir.txt +++ b/compiler/testData/ir/irText/declarations/provideDelegate/localDifferentReceivers.fir.txt @@ -47,11 +47,11 @@ FILE fqName: fileName:/localDifferentReceivers.kt ERROR_CALL 'Unresolved reference: this#' type=kotlin.String FUN name:box visibility:public modality:FINAL <> () returnType:kotlin.String BLOCK_BODY - VAR name:testO type:IrErrorType [val] + VAR name:testO type:kotlin.String [val] VAR name:testK type:kotlin.String [val] - VAR name:testOK type:IrErrorType [val] - ERROR_CALL 'Unresolved reference: #' type=IrErrorType - GET_VAR 'val testK: kotlin.String [val] declared in .box' type=kotlin.String origin=null + VAR name:testOK type:kotlin.String [val] + CALL 'public final fun plus (other: kotlin.Any?): kotlin.String declared in kotlin.String' type=kotlin.String origin=null + $this: GET_VAR 'val testO: kotlin.String [val] declared in .box' type=kotlin.String origin=null + other: 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 - + GET_VAR 'val testOK: kotlin.String [val] declared in .box' type=kotlin.String 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 710c845a156..2fbc5e2eea8 100644 --- a/compiler/testData/ir/irText/declarations/provideDelegate/member.fir.txt +++ b/compiler/testData/ir/irText/declarations/provideDelegate/member.fir.txt @@ -83,18 +83,22 @@ 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 DELEGATE name:testMember$delegate type:.DelegateProvider visibility:private [final] + FIELD DELEGATE name:testMember$delegate type:.Delegate 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 + CALL 'public final fun provideDelegate (thisRef: kotlin.Any?, property: kotlin.Any?): .Delegate declared in .DelegateProvider' type=.Delegate origin=null + $this: CONSTRUCTOR_CALL 'public constructor (value: kotlin.String) [primary] declared in .DelegateProvider' type=.DelegateProvider origin=null + value: CONST String type=kotlin.String value="OK" + thisRef: ERROR_CALL 'Unresolved reference: this#' type=.Host + property: PROPERTY_REFERENCE 'public final testMember: kotlin.String [delegated,val]' field=null getter=null setter=null type=kotlin.reflect.KProperty<*> origin=null + FUN DELEGATED_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.Host) returnType:kotlin.String 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' - 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 + RETURN type=kotlin.Nothing from='public final fun (): kotlin.String declared in .Host' + CALL 'public final fun getValue (thisRef: kotlin.Any?, property: kotlin.Any?): kotlin.String declared in .Delegate' type=kotlin.String origin=null + $this: GET_FIELD 'FIELD DELEGATE name:testMember$delegate type:.Delegate visibility:private [final] ' type=.Delegate origin=GET_PROPERTY + thisRef: ERROR_CALL 'Unresolved reference: this#' type=.Host + property: PROPERTY_REFERENCE 'public final testMember: kotlin.String [delegated,val]' field='FIELD DELEGATE name:testMember$delegate type:.Delegate 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 64bfce3587b..b496c36bbbc 100644 --- a/compiler/testData/ir/irText/declarations/provideDelegate/memberExtension.fir.txt +++ b/compiler/testData/ir/irText/declarations/provideDelegate/memberExtension.fir.txt @@ -55,17 +55,20 @@ 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 DELEGATE name:plusK$delegate type:IrErrorType visibility:private [final] + FIELD DELEGATE name:plusK$delegate type:.Host.StringDelegate visibility:private [final] EXPRESSION_BODY - CONST String type=IrErrorType value="K" + CALL 'public final fun provideDelegate (host: kotlin.Any?, p: kotlin.Any): .Host.StringDelegate declared in .Host' type=.Host.StringDelegate origin=null + $this: CONST String type=kotlin.String value="K" + host: ERROR_CALL 'Unresolved reference: this#' type=.Host + p: PROPERTY_REFERENCE 'public final plusK: IrErrorType [delegated,val]' field=null getter=null setter=null type=kotlin.reflect.KProperty<*> origin=null 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' - ERROR_CALL 'Unresolved reference: #' type=IrErrorType + 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_REFERENCE 'public final plusK: IrErrorType [delegated,val]' field='FIELD DELEGATE name:plusK$delegate type:.Host.StringDelegate 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 fc72e651417..09a047b1a63 100644 --- a/compiler/testData/ir/irText/declarations/provideDelegate/topLevel.fir.txt +++ b/compiler/testData/ir/irText/declarations/provideDelegate/topLevel.fir.txt @@ -77,14 +77,18 @@ 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 DELEGATE name:testTopLevel$delegate type:.DelegateProvider visibility:private [final,static] + FIELD DELEGATE name:testTopLevel$delegate type:.Delegate 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 + CALL 'public final fun provideDelegate (thisRef: kotlin.Any?, property: kotlin.Any?): .Delegate declared in .DelegateProvider' type=.Delegate origin=null + $this: CONSTRUCTOR_CALL 'public constructor (value: kotlin.String) [primary] declared in .DelegateProvider' type=.DelegateProvider origin=null + value: CONST String type=kotlin.String value="OK" + thisRef: CONST Null type=kotlin.Nothing? value=null + property: PROPERTY_REFERENCE 'public final testTopLevel: kotlin.String [delegated,val]' field=null getter=null setter=null type=kotlin.reflect.KProperty<*> origin=null + FUN DELEGATED_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.String correspondingProperty: PROPERTY name:testTopLevel visibility:public modality:FINAL [delegated,val] BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): IrErrorType declared in ' - 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 + RETURN type=kotlin.Nothing from='public final fun (): kotlin.String declared in ' + CALL 'public final fun getValue (thisRef: kotlin.Any?, property: kotlin.Any?): kotlin.String declared in .Delegate' type=kotlin.String origin=null + $this: GET_FIELD 'FIELD DELEGATE name:testTopLevel$delegate type:.Delegate visibility:private [final,static] ' type=.Delegate origin=GET_PROPERTY + thisRef: CONST Null type=kotlin.Nothing? value=null + property: PROPERTY_REFERENCE 'public final testTopLevel: kotlin.String [delegated,val]' field='FIELD DELEGATE name:testTopLevel$delegate type:.Delegate visibility:private [final,static] ' getter=null setter=null type=kotlin.reflect.KProperty<*> origin=null