diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/CallGenerator.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/CallGenerator.kt index 0f6b851857d..439f62598ce 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/CallGenerator.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/CallGenerator.kt @@ -24,6 +24,7 @@ import org.jetbrains.kotlin.fir.symbols.impl.FirClassSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirFunctionSymbol import org.jetbrains.kotlin.fir.types.* import org.jetbrains.kotlin.ir.declarations.IrFunction +import org.jetbrains.kotlin.ir.declarations.IrProperty import org.jetbrains.kotlin.ir.expressions.IrErrorCallExpression import org.jetbrains.kotlin.ir.expressions.IrExpression import org.jetbrains.kotlin.ir.expressions.IrStatementOrigin @@ -55,7 +56,11 @@ internal class CallGenerator( symbol.owner.backingField?.symbol, symbol.owner.getter?.symbol, symbol.owner.setter?.symbol - ) + ).apply { + if (callableReferenceAccess.explicitReceiver !is FirResolvedQualifier) { + applyReceivers(callableReferenceAccess) + } + } } is IrFunctionSymbol -> { IrFunctionReferenceImpl( @@ -359,6 +364,16 @@ internal class CallGenerator( } this } + is IrNoArgumentsCallableReferenceBase -> { + val ownerPropertyGetter = (symbol.owner as? IrProperty)?.getter + if (ownerPropertyGetter?.dispatchReceiverParameter != null) { + dispatchReceiver = qualifiedAccess.findIrDispatchReceiver() + } + if (ownerPropertyGetter?.extensionReceiverParameter != null) { + extensionReceiver = qualifiedAccess.findIrExtensionReceiver() + } + this + } is IrFieldExpressionBase -> { val ownerField = symbol.owner if (!ownerField.isStatic) { diff --git a/compiler/testData/codegen/box/callableReference/bound/array.kt b/compiler/testData/codegen/box/callableReference/bound/array.kt index af5b86c9d73..2a78bb9cc88 100644 --- a/compiler/testData/codegen/box/callableReference/bound/array.kt +++ b/compiler/testData/codegen/box/callableReference/bound/array.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR open class A { var f: String = "OK" } diff --git a/compiler/testData/codegen/box/callableReference/bound/equals/nullableReceiverInEquals.kt b/compiler/testData/codegen/box/callableReference/bound/equals/nullableReceiverInEquals.kt index 88f4cc64927..7d6676553bb 100644 --- a/compiler/testData/codegen/box/callableReference/bound/equals/nullableReceiverInEquals.kt +++ b/compiler/testData/codegen/box/callableReference/bound/equals/nullableReceiverInEquals.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // IGNORE_BACKEND: JS_IR // TODO: investigate should it be ran for JS or not // IGNORE_BACKEND: JS diff --git a/compiler/testData/codegen/box/callableReference/bound/genericValOnLHS.kt b/compiler/testData/codegen/box/callableReference/bound/genericValOnLHS.kt index ab5ec9a45e8..8911473c689 100644 --- a/compiler/testData/codegen/box/callableReference/bound/genericValOnLHS.kt +++ b/compiler/testData/codegen/box/callableReference/bound/genericValOnLHS.kt @@ -1,5 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR - class Generic

(val p: P) class Host { diff --git a/compiler/testData/codegen/box/callableReference/bound/nullReceiver.kt b/compiler/testData/codegen/box/callableReference/bound/nullReceiver.kt index 90ce5a256a6..0111a54d58b 100644 --- a/compiler/testData/codegen/box/callableReference/bound/nullReceiver.kt +++ b/compiler/testData/codegen/box/callableReference/bound/nullReceiver.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR val String?.ok: String get() = "OK" diff --git a/compiler/testData/codegen/box/callableReference/bound/simpleProperty.kt b/compiler/testData/codegen/box/callableReference/bound/simpleProperty.kt index b853f97cbdf..c271b1c6418 100644 --- a/compiler/testData/codegen/box/callableReference/bound/simpleProperty.kt +++ b/compiler/testData/codegen/box/callableReference/bound/simpleProperty.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR fun box(): String { val f = "kotlin"::length val result = f.get() diff --git a/compiler/testData/codegen/box/callableReference/property/kt15447.kt b/compiler/testData/codegen/box/callableReference/property/kt15447.kt index 76341129f0a..d1d9a817df9 100644 --- a/compiler/testData/codegen/box/callableReference/property/kt15447.kt +++ b/compiler/testData/codegen/box/callableReference/property/kt15447.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR //WITH_RUNTIME fun box(): String { diff --git a/compiler/testData/codegen/box/callableReference/property/receiverEvaluatedOnce.kt b/compiler/testData/codegen/box/callableReference/property/receiverEvaluatedOnce.kt index e2efca35253..3b58ed7b9a5 100644 --- a/compiler/testData/codegen/box/callableReference/property/receiverEvaluatedOnce.kt +++ b/compiler/testData/codegen/box/callableReference/property/receiverEvaluatedOnce.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // WITH_REFLECT import kotlin.reflect.KProperty0 diff --git a/compiler/testData/codegen/box/callableReference/serializability/boundWithNotSerializableReceiver.kt b/compiler/testData/codegen/box/callableReference/serializability/boundWithNotSerializableReceiver.kt index 15e3a1d2735..6610a175a4e 100644 --- a/compiler/testData/codegen/box/callableReference/serializability/boundWithNotSerializableReceiver.kt +++ b/compiler/testData/codegen/box/callableReference/serializability/boundWithNotSerializableReceiver.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // TARGET_BACKEND: JVM // WITH_REFLECT // FULL_JDK diff --git a/compiler/testData/codegen/box/callableReference/serializability/boundWithSerializableReceiver.kt b/compiler/testData/codegen/box/callableReference/serializability/boundWithSerializableReceiver.kt index 11d4905cbe1..88cf4382f61 100644 --- a/compiler/testData/codegen/box/callableReference/serializability/boundWithSerializableReceiver.kt +++ b/compiler/testData/codegen/box/callableReference/serializability/boundWithSerializableReceiver.kt @@ -1,3 +1,4 @@ +// IGNORE_BACKEND_FIR: JVM_IR // TARGET_BACKEND: JVM // WITH_REFLECT diff --git a/compiler/testData/codegen/box/inlineClasses/callableReferences/boundInlineClassMemberVal.kt b/compiler/testData/codegen/box/inlineClasses/callableReferences/boundInlineClassMemberVal.kt index e3e8237af6e..29a89e3ede5 100644 --- a/compiler/testData/codegen/box/inlineClasses/callableReferences/boundInlineClassMemberVal.kt +++ b/compiler/testData/codegen/box/inlineClasses/callableReferences/boundInlineClassMemberVal.kt @@ -1,5 +1,4 @@ // !LANGUAGE: +InlineClasses -// IGNORE_BACKEND_FIR: JVM_IR // WITH_RUNTIME inline class Z(val x: Int) { diff --git a/compiler/testData/codegen/box/inlineClasses/callableReferences/boundInlineClassPrimaryVal.kt b/compiler/testData/codegen/box/inlineClasses/callableReferences/boundInlineClassPrimaryVal.kt index 9fdd675d5f5..1c1dd71e21e 100644 --- a/compiler/testData/codegen/box/inlineClasses/callableReferences/boundInlineClassPrimaryVal.kt +++ b/compiler/testData/codegen/box/inlineClasses/callableReferences/boundInlineClassPrimaryVal.kt @@ -1,5 +1,4 @@ // !LANGUAGE: +InlineClasses -// IGNORE_BACKEND_FIR: JVM_IR // WITH_RUNTIME inline class Z(val x: Int) diff --git a/compiler/testData/codegen/box/inlineClasses/callableReferences/inlineClassTypeBoundMemberVar.kt b/compiler/testData/codegen/box/inlineClasses/callableReferences/inlineClassTypeBoundMemberVar.kt index 278a5d21cb8..a515a3da6c2 100644 --- a/compiler/testData/codegen/box/inlineClasses/callableReferences/inlineClassTypeBoundMemberVar.kt +++ b/compiler/testData/codegen/box/inlineClasses/callableReferences/inlineClassTypeBoundMemberVar.kt @@ -1,5 +1,4 @@ // !LANGUAGE: +InlineClasses -// IGNORE_BACKEND_FIR: JVM_IR // WITH_RUNTIME inline class Z(val x: Int) diff --git a/compiler/testData/codegen/box/properties/lateinit/isInitializedAndDeinitialize/innerSubclass.kt b/compiler/testData/codegen/box/properties/lateinit/isInitializedAndDeinitialize/innerSubclass.kt index 8dc7a5d8c5c..63c15894b45 100644 --- a/compiler/testData/codegen/box/properties/lateinit/isInitializedAndDeinitialize/innerSubclass.kt +++ b/compiler/testData/codegen/box/properties/lateinit/isInitializedAndDeinitialize/innerSubclass.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // WITH_RUNTIME open class Foo { diff --git a/compiler/testData/ir/irText/declarations/provideDelegate/memberExtension.fir.txt b/compiler/testData/ir/irText/declarations/provideDelegate/memberExtension.fir.txt index d6a56b70722..26d05e16a3c 100644 --- a/compiler/testData/ir/irText/declarations/provideDelegate/memberExtension.fir.txt +++ b/compiler/testData/ir/irText/declarations/provideDelegate/memberExtension.fir.txt @@ -63,6 +63,8 @@ FILE fqName: fileName:/memberExtension.kt $receiver: CONST String type=kotlin.String value="K" host: GET_VAR ': .Host declared in .Host' type=.Host origin=null p: PROPERTY_REFERENCE 'public final plusK: kotlin.String [delegated,val]' field=null getter='public final fun (): kotlin.String declared in .Host' setter=null type=kotlin.reflect.KProperty<*> origin=null + $this: GET_OBJECT 'CLASS OBJECT name:Host modality:FINAL visibility:public superTypes:[kotlin.Any]' type=.Host + $receiver: GET_OBJECT 'CLASS OBJECT name:Host modality:FINAL visibility:public superTypes:[kotlin.Any]' type=.Host FUN DELEGATED_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.Host, $receiver:kotlin.String) returnType:kotlin.String correspondingProperty: PROPERTY name:plusK visibility:public modality:FINAL [delegated,val] $this: VALUE_PARAMETER name: type:.Host @@ -74,6 +76,8 @@ FILE fqName: fileName:/memberExtension.kt receiver: GET_OBJECT 'CLASS OBJECT name:Host modality:FINAL visibility:public superTypes:[kotlin.Any]' type=.Host receiver: ERROR_CALL 'Unresolved reference: this@R|/Host.plusK|' type=kotlin.String p: PROPERTY_REFERENCE 'public final plusK: kotlin.String [delegated,val]' field='FIELD PROPERTY_DELEGATE name:plusK$delegate type:.Host.StringDelegate visibility:private [final]' getter='public final fun (): kotlin.String declared in .Host' setter=null type=kotlin.reflect.KProperty<*> origin=null + $this: GET_OBJECT 'CLASS OBJECT name:Host modality:FINAL visibility:public superTypes:[kotlin.Any]' type=.Host + $receiver: GET_OBJECT 'CLASS OBJECT name:Host modality:FINAL visibility:public superTypes:[kotlin.Any]' type=.Host PROPERTY name:ok visibility:public modality:FINAL [val] FIELD PROPERTY_BACKING_FIELD name:ok type:kotlin.String visibility:private [final] EXPRESSION_BODY diff --git a/compiler/testData/ir/irText/expressions/boundCallableReferences.fir.txt b/compiler/testData/ir/irText/expressions/boundCallableReferences.fir.txt index 71a518ef93a..6be22a54609 100644 --- a/compiler/testData/ir/irText/expressions/boundCallableReferences.fir.txt +++ b/compiler/testData/ir/irText/expressions/boundCallableReferences.fir.txt @@ -49,6 +49,7 @@ FILE fqName: fileName:/boundCallableReferences.kt FIELD PROPERTY_BACKING_FIELD name:test2 type:kotlin.reflect.KProperty0 visibility:private [final,static] EXPRESSION_BODY PROPERTY_REFERENCE 'public final bar: kotlin.Int [val]' field='FIELD PROPERTY_BACKING_FIELD name:bar type:kotlin.Int visibility:private [final]' getter='public final fun (): kotlin.Int declared in .A' setter=null type=kotlin.reflect.KProperty0 origin=null + $this: CONSTRUCTOR_CALL 'public constructor () [primary] declared in .A' type=.A origin=null FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.reflect.KProperty0 correspondingProperty: PROPERTY name:test2 visibility:public modality:FINAL [val] BLOCK_BODY diff --git a/compiler/testData/ir/irText/expressions/callableReferences/importedFromObject.fir.txt b/compiler/testData/ir/irText/expressions/callableReferences/importedFromObject.fir.txt index 0c512ebad97..8b77b267fc6 100644 --- a/compiler/testData/ir/irText/expressions/callableReferences/importedFromObject.fir.txt +++ b/compiler/testData/ir/irText/expressions/callableReferences/importedFromObject.fir.txt @@ -38,6 +38,7 @@ FILE fqName:test fileName:/importedFromObject.kt FIELD PROPERTY_BACKING_FIELD name:test1 type:kotlin.reflect.KProperty0 visibility:private [final,static] EXPRESSION_BODY PROPERTY_REFERENCE 'public final a: kotlin.String [val]' field='FIELD PROPERTY_BACKING_FIELD name:a type:kotlin.String visibility:private [final]' getter='public final fun (): kotlin.String declared in test.Foo' setter=null type=kotlin.reflect.KProperty0 origin=null + $this: GET_OBJECT 'CLASS OBJECT name:Foo modality:FINAL visibility:public superTypes:[kotlin.Any]' type=test.Foo FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.reflect.KProperty0 correspondingProperty: PROPERTY name:test1 visibility:public modality:FINAL [val] BLOCK_BODY diff --git a/compiler/testData/ir/irText/types/genericPropertyReferenceType.fir.txt b/compiler/testData/ir/irText/types/genericPropertyReferenceType.fir.txt index 59f00c0b3e3..b8c53dc877e 100644 --- a/compiler/testData/ir/irText/types/genericPropertyReferenceType.fir.txt +++ b/compiler/testData/ir/irText/types/genericPropertyReferenceType.fir.txt @@ -64,6 +64,9 @@ FILE fqName: fileName:/genericPropertyReferenceType.kt BLOCK_BODY CALL 'public final fun use (p: kotlin.reflect.KMutableProperty): kotlin.Unit declared in ' type=kotlin.Unit origin=null p: PROPERTY_REFERENCE 'public final y: T of . [var]' field=null getter='public final fun (): T of . declared in ' setter='public final fun (v: T of .): kotlin.Unit declared in ' type=kotlin.reflect.KMutableProperty0 origin=null + $receiver: CONSTRUCTOR_CALL 'public constructor (x: T of .C) [primary] declared in .C' type=.C origin=null + : kotlin.String + x: CONST String type=kotlin.String value="abc" FUN name:test2 visibility:public modality:FINAL <> (a:kotlin.Any) returnType:kotlin.Unit VALUE_PARAMETER name:a index:0 type:kotlin.Any BLOCK_BODY @@ -71,3 +74,5 @@ FILE fqName: fileName:/genericPropertyReferenceType.kt 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: PROPERTY_REFERENCE 'public final y: T of . [var]' field=null getter='public final fun (): T of . declared in ' setter='public final fun (v: T of .): kotlin.Unit declared in ' type=kotlin.reflect.KMutableProperty0 origin=null + $receiver: TYPE_OP type=.C origin=IMPLICIT_CAST typeOperand=.C + GET_VAR 'a: kotlin.Any declared in .test2' type=kotlin.Any origin=null