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 0f5ee80b931..0f6b851857d 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 @@ -23,6 +23,7 @@ import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol 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.expressions.IrErrorCallExpression import org.jetbrains.kotlin.ir.expressions.IrExpression import org.jetbrains.kotlin.ir.expressions.IrStatementOrigin @@ -62,14 +63,8 @@ internal class CallGenerator( typeArgumentsCount = 0, reflectionTarget = symbol ).apply { - val firReceiver = callableReferenceAccess.explicitReceiver - if (firReceiver != null && firReceiver !is FirResolvedQualifier) { - val irReceiver = visitor.convertToIrExpression(firReceiver) - if (symbol.owner.dispatchReceiverParameter != null) { - this.dispatchReceiver = irReceiver - } else if (symbol.owner.extensionReceiverParameter != null) { - this.extensionReceiver = irReceiver - } + if (callableReferenceAccess.explicitReceiver !is FirResolvedQualifier) { + applyReceivers(callableReferenceAccess) } } } @@ -354,12 +349,12 @@ internal class CallGenerator( private fun IrExpression.applyReceivers(qualifiedAccess: FirQualifiedAccess): IrExpression { return when (this) { - is IrCallImpl -> { - val ownerFunction = symbol.owner - if (ownerFunction.dispatchReceiverParameter != null) { + is IrCallWithIndexedArgumentsBase -> { + val ownerFunction = symbol.owner as? IrFunction + if (ownerFunction?.dispatchReceiverParameter != null) { dispatchReceiver = qualifiedAccess.findIrDispatchReceiver() } - if (ownerFunction.extensionReceiverParameter != null) { + if (ownerFunction?.extensionReceiverParameter != null) { extensionReceiver = qualifiedAccess.findIrExtensionReceiver() } this diff --git a/compiler/testData/codegen/box/callableReference/function/traitImplMethodWithClassReceiver.kt b/compiler/testData/codegen/box/callableReference/function/traitImplMethodWithClassReceiver.kt index a996b7b7550..9171f0b094b 100644 --- a/compiler/testData/codegen/box/callableReference/function/traitImplMethodWithClassReceiver.kt +++ b/compiler/testData/codegen/box/callableReference/function/traitImplMethodWithClassReceiver.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR interface T { fun foo() = "OK" } diff --git a/compiler/testData/codegen/box/classes/classObjectsWithParentClasses.kt b/compiler/testData/codegen/box/classes/classObjectsWithParentClasses.kt index c424de02c39..668619e3032 100644 --- a/compiler/testData/codegen/box/classes/classObjectsWithParentClasses.kt +++ b/compiler/testData/codegen/box/classes/classObjectsWithParentClasses.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR open class Test { companion object { fun testStatic(ic: InnerClass): NotInnerClass = NotInnerClass(ic.value) diff --git a/compiler/testData/codegen/box/classes/inner/extensionWithOuter.kt b/compiler/testData/codegen/box/classes/inner/extensionWithOuter.kt index c26ebcdf4ce..b297d114c6a 100644 --- a/compiler/testData/codegen/box/classes/inner/extensionWithOuter.kt +++ b/compiler/testData/codegen/box/classes/inner/extensionWithOuter.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR class Outer(val value: String) { inner class Inner { diff --git a/compiler/testData/codegen/box/classes/inner/properOuter.kt b/compiler/testData/codegen/box/classes/inner/properOuter.kt index 179c13ad9df..127b04d7bd8 100644 --- a/compiler/testData/codegen/box/classes/inner/properOuter.kt +++ b/compiler/testData/codegen/box/classes/inner/properOuter.kt @@ -1,5 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR - open class A(val s: String) { open inner class B(val s: String) { fun testB() = s + this@A.s diff --git a/compiler/testData/codegen/box/classes/inner/properSuperLinking.kt b/compiler/testData/codegen/box/classes/inner/properSuperLinking.kt index c7d071a852b..8a11c5ab787 100644 --- a/compiler/testData/codegen/box/classes/inner/properSuperLinking.kt +++ b/compiler/testData/codegen/box/classes/inner/properSuperLinking.kt @@ -1,5 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR - open class A(val s: String) { val z = s diff --git a/compiler/testData/codegen/box/classes/outerThis.kt b/compiler/testData/codegen/box/classes/outerThis.kt index 74d193676d8..346e44ecbbf 100644 --- a/compiler/testData/codegen/box/classes/outerThis.kt +++ b/compiler/testData/codegen/box/classes/outerThis.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR class Outer() { inner class Inner() { val outer: Outer get() = this@Outer diff --git a/compiler/testData/codegen/box/closures/kt3152.kt b/compiler/testData/codegen/box/closures/kt3152.kt index 13fe71d1a0e..59bf3eaaeeb 100644 --- a/compiler/testData/codegen/box/closures/kt3152.kt +++ b/compiler/testData/codegen/box/closures/kt3152.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR public class Test { val content = 1 inner class A { diff --git a/compiler/testData/codegen/box/closures/kt3523.kt b/compiler/testData/codegen/box/closures/kt3523.kt index f0a1369e284..bbc225f8fd8 100644 --- a/compiler/testData/codegen/box/closures/kt3523.kt +++ b/compiler/testData/codegen/box/closures/kt3523.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR open class Base { fun doSomething() { diff --git a/compiler/testData/codegen/box/closures/kt4106.kt b/compiler/testData/codegen/box/closures/kt4106.kt index 150ccc1994f..f190819f8d5 100644 --- a/compiler/testData/codegen/box/closures/kt4106.kt +++ b/compiler/testData/codegen/box/closures/kt4106.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR class Foo(private val s: String) { inner class Inner { private val x = { diff --git a/compiler/testData/codegen/box/constructorCall/inlineFunInInnerClassConstructorCall.kt b/compiler/testData/codegen/box/constructorCall/inlineFunInInnerClassConstructorCall.kt index f07edd964ba..1edef67d6ad 100644 --- a/compiler/testData/codegen/box/constructorCall/inlineFunInInnerClassConstructorCall.kt +++ b/compiler/testData/codegen/box/constructorCall/inlineFunInInnerClassConstructorCall.kt @@ -1,5 +1,4 @@ // !LANGUAGE: -NormalizeConstructorCalls -// IGNORE_BACKEND_FIR: JVM_IR // TARGET_BACKEND: JVM // WITH_RUNTIME // FILE: test.kt diff --git a/compiler/testData/codegen/box/defaultArguments/constructor/defArgs1InnerClass.kt b/compiler/testData/codegen/box/defaultArguments/constructor/defArgs1InnerClass.kt index cc0ddb0d81d..588b0cf1c60 100644 --- a/compiler/testData/codegen/box/defaultArguments/constructor/defArgs1InnerClass.kt +++ b/compiler/testData/codegen/box/defaultArguments/constructor/defArgs1InnerClass.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR class A { inner class B(val a: String = "a", val b: Int = 55, val c: String = "c") } diff --git a/compiler/testData/codegen/box/defaultArguments/constructor/doubleDefArgs1InnerClass.kt b/compiler/testData/codegen/box/defaultArguments/constructor/doubleDefArgs1InnerClass.kt index b69394905ae..cc9737c3e47 100644 --- a/compiler/testData/codegen/box/defaultArguments/constructor/doubleDefArgs1InnerClass.kt +++ b/compiler/testData/codegen/box/defaultArguments/constructor/doubleDefArgs1InnerClass.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR class A { inner class B(val a: Double = 1.0, val b: Int = 55, val c: String = "c") } diff --git a/compiler/testData/codegen/box/defaultArguments/constructor/innerClass32Args.kt b/compiler/testData/codegen/box/defaultArguments/constructor/innerClass32Args.kt index 08ba7a47f31..ae3fc3ab71e 100644 --- a/compiler/testData/codegen/box/defaultArguments/constructor/innerClass32Args.kt +++ b/compiler/testData/codegen/box/defaultArguments/constructor/innerClass32Args.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR class A { inner class B(val a: Int = 1, val b: Int = 2, diff --git a/compiler/testData/codegen/box/innerNested/extensionFun.kt b/compiler/testData/codegen/box/innerNested/extensionFun.kt index 6830e904e4c..44ed11116dc 100644 --- a/compiler/testData/codegen/box/innerNested/extensionFun.kt +++ b/compiler/testData/codegen/box/innerNested/extensionFun.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR class Outer { class Nested inner class Inner diff --git a/compiler/testData/codegen/box/innerNested/innerGeneric.kt b/compiler/testData/codegen/box/innerNested/innerGeneric.kt index 8847e85cb35..36a6bda1e99 100644 --- a/compiler/testData/codegen/box/innerNested/innerGeneric.kt +++ b/compiler/testData/codegen/box/innerNested/innerGeneric.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR class Outer { inner class Inner(val t: T) { fun box() = t diff --git a/compiler/testData/codegen/box/innerNested/innerLabeledThis.kt b/compiler/testData/codegen/box/innerNested/innerLabeledThis.kt index 6be8bea541a..34a50d00af6 100644 --- a/compiler/testData/codegen/box/innerNested/innerLabeledThis.kt +++ b/compiler/testData/codegen/box/innerNested/innerLabeledThis.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR class Outer { inner class Inner { fun O() = this@Outer.O diff --git a/compiler/testData/codegen/box/innerNested/innerSimple.kt b/compiler/testData/codegen/box/innerNested/innerSimple.kt index 577b541ad19..9159e24d84c 100644 --- a/compiler/testData/codegen/box/innerNested/innerSimple.kt +++ b/compiler/testData/codegen/box/innerNested/innerSimple.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR class Outer { inner class Inner { fun box() = "OK" diff --git a/compiler/testData/codegen/box/innerNested/kt3132.kt b/compiler/testData/codegen/box/innerNested/kt3132.kt index 76f9b2a376c..afcee1c6ca1 100644 --- a/compiler/testData/codegen/box/innerNested/kt3132.kt +++ b/compiler/testData/codegen/box/innerNested/kt3132.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR class Test { interface Foo { } diff --git a/compiler/testData/codegen/box/innerNested/kt3927.kt b/compiler/testData/codegen/box/innerNested/kt3927.kt index 4cf80415976..1e1efce9624 100644 --- a/compiler/testData/codegen/box/innerNested/kt3927.kt +++ b/compiler/testData/codegen/box/innerNested/kt3927.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR //KT-3927 Inner class cannot be instantiated with child instance of outer class abstract class Base { diff --git a/compiler/testData/codegen/box/ir/kt25405.kt b/compiler/testData/codegen/box/ir/kt25405.kt index 1fb602beefc..485922deed7 100644 --- a/compiler/testData/codegen/box/ir/kt25405.kt +++ b/compiler/testData/codegen/box/ir/kt25405.kt @@ -1,5 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR - fun tableView(init: Table.() -> Unit) { Table().init() } diff --git a/compiler/testData/codegen/box/mangling/internal.kt b/compiler/testData/codegen/box/mangling/internal.kt index e162ca1f1e1..070c07902d3 100644 --- a/compiler/testData/codegen/box/mangling/internal.kt +++ b/compiler/testData/codegen/box/mangling/internal.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // IGNORE_BACKEND: JS_IR // MODULE: lib // FILE: lib.kt diff --git a/compiler/testData/codegen/box/privateConstructors/inner.kt b/compiler/testData/codegen/box/privateConstructors/inner.kt index 4c37ac5cb41..16c1734f08f 100644 --- a/compiler/testData/codegen/box/privateConstructors/inner.kt +++ b/compiler/testData/codegen/box/privateConstructors/inner.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // See also KT-6299 public open class Outer private constructor(val s: String) { inner class Inner: Outer("O") { diff --git a/compiler/testData/codegen/box/regressions/kt5395.kt b/compiler/testData/codegen/box/regressions/kt5395.kt index d55de8f7f3f..11bb02ddf09 100644 --- a/compiler/testData/codegen/box/regressions/kt5395.kt +++ b/compiler/testData/codegen/box/regressions/kt5395.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR class D { companion object { protected val F: String = "OK" diff --git a/compiler/testData/codegen/box/super/superConstructor/kt13846.kt b/compiler/testData/codegen/box/super/superConstructor/kt13846.kt index 41dcff9b626..c066d8e6ce5 100644 --- a/compiler/testData/codegen/box/super/superConstructor/kt13846.kt +++ b/compiler/testData/codegen/box/super/superConstructor/kt13846.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR open class SuperClass(val arg: () -> String) object obj { diff --git a/compiler/testData/codegen/box/syntheticAccessors/accessorForGenericConstructor.kt b/compiler/testData/codegen/box/syntheticAccessors/accessorForGenericConstructor.kt index ec6e7bf8cbe..9a97980a5a6 100644 --- a/compiler/testData/codegen/box/syntheticAccessors/accessorForGenericConstructor.kt +++ b/compiler/testData/codegen/box/syntheticAccessors/accessorForGenericConstructor.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR fun box(): String { A.Nested().nestedA() A.Nested().Inner().innerA() diff --git a/compiler/testData/ir/irText/expressions/callableReferences/importedFromObject.fir.txt b/compiler/testData/ir/irText/expressions/callableReferences/importedFromObject.fir.txt index 44ddc690136..0c512ebad97 100644 --- a/compiler/testData/ir/irText/expressions/callableReferences/importedFromObject.fir.txt +++ b/compiler/testData/ir/irText/expressions/callableReferences/importedFromObject.fir.txt @@ -56,6 +56,7 @@ FILE fqName:test fileName:/importedFromObject.kt FIELD PROPERTY_BACKING_FIELD name:test2 type:kotlin.reflect.KFunction0 visibility:private [final,static] EXPRESSION_BODY FUNCTION_REFERENCE 'public final fun foo (): kotlin.String declared in test.Foo' type=kotlin.reflect.KFunction0 origin=null reflectionTarget= + $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.KFunction0 correspondingProperty: PROPERTY name:test2 visibility:public modality:FINAL [val] BLOCK_BODY diff --git a/compiler/testData/ir/irText/expressions/callableReferences/typeArguments.fir.txt b/compiler/testData/ir/irText/expressions/callableReferences/typeArguments.fir.txt index c26125bd188..aa3972aa2d7 100644 --- a/compiler/testData/ir/irText/expressions/callableReferences/typeArguments.fir.txt +++ b/compiler/testData/ir/irText/expressions/callableReferences/typeArguments.fir.txt @@ -53,6 +53,7 @@ FILE fqName: fileName:/typeArguments.kt FIELD PROPERTY_BACKING_FIELD name:test3 type:kotlin.Function1 visibility:private [final,static] EXPRESSION_BODY FUNCTION_REFERENCE 'public final fun objectMember (x: T of .Host.objectMember): kotlin.Unit [inline] declared in .Host' type=kotlin.reflect.KFunction1 origin=null reflectionTarget= + $this: GET_OBJECT 'CLASS OBJECT name:Host modality:FINAL visibility:public superTypes:[kotlin.Any]' type=.Host 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/callableReferences/withAdaptedArguments.fir.txt b/compiler/testData/ir/irText/expressions/callableReferences/withAdaptedArguments.fir.txt index b42e8c0e8ec..ed60bf5199d 100644 --- a/compiler/testData/ir/irText/expressions/callableReferences/withAdaptedArguments.fir.txt +++ b/compiler/testData/ir/irText/expressions/callableReferences/withAdaptedArguments.fir.txt @@ -67,3 +67,4 @@ FILE fqName: fileName:/withAdaptedArguments.kt RETURN type=kotlin.Nothing from='public final fun testImportedObjectMember (): IrErrorType declared in ' ERROR_CALL 'Unresolved reference: #' type=IrErrorType FUNCTION_REFERENCE 'public final fun importedObjectMemberWithVarargs (vararg xs: kotlin.Int): kotlin.String declared in .Host' type=kotlin.reflect.KFunction1 origin=null reflectionTarget= + $this: GET_OBJECT 'CLASS OBJECT name:Host modality:FINAL visibility:public superTypes:[kotlin.Any]' type=.Host diff --git a/compiler/testData/ir/irText/expressions/constructorWithOwnTypeParametersCall.fir.txt b/compiler/testData/ir/irText/expressions/constructorWithOwnTypeParametersCall.fir.txt index 59d4d8e71f3..148b152f143 100644 --- a/compiler/testData/ir/irText/expressions/constructorWithOwnTypeParametersCall.fir.txt +++ b/compiler/testData/ir/irText/expressions/constructorWithOwnTypeParametersCall.fir.txt @@ -4,6 +4,8 @@ FILE fqName: fileName:/constructorWithOwnTypeParametersCall.kt RETURN type=kotlin.Nothing from='public final fun testKotlin (): .K1.K2 declared in ' CONSTRUCTOR_CALL 'public constructor () [primary] declared in .K1.K2' type=.K1.K2 origin=null : kotlin.String + $outer: CONSTRUCTOR_CALL 'public constructor () [primary] declared in .K1' type=.K1 origin=null + : kotlin.Int FUN name:testJava visibility:public modality:FINAL <> () returnType:.J1.J2 BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun testJava (): .J1.J2 declared in ' diff --git a/compiler/testData/ir/irText/stubs/javaConstructorWithTypeParameters.fir.txt b/compiler/testData/ir/irText/stubs/javaConstructorWithTypeParameters.fir.txt index 7bd21e7c5c6..03efd51f6b5 100644 --- a/compiler/testData/ir/irText/stubs/javaConstructorWithTypeParameters.fir.txt +++ b/compiler/testData/ir/irText/stubs/javaConstructorWithTypeParameters.fir.txt @@ -14,6 +14,7 @@ FILE fqName: fileName:/javaConstructorWithTypeParameters.kt RETURN type=kotlin.Nothing from='public final fun test3 (j1: .J1): .J1.J2 declared in ' CONSTRUCTOR_CALL 'public constructor () declared in .J1.J2' type=.J1.J2 origin=null : kotlin.Int? + $outer: GET_VAR 'j1: .J1 declared in .test3' type=.J1 origin=null FUN name:test4 visibility:public modality:FINAL <> (j1:.J1) returnType:.J1.J2 VALUE_PARAMETER name:j1 index:0 type:.J1 BLOCK_BODY diff --git a/compiler/testData/ir/irText/stubs/javaInnerClass.fir.txt b/compiler/testData/ir/irText/stubs/javaInnerClass.fir.txt index 08b0aa6a63c..4c7ba6d3011 100644 --- a/compiler/testData/ir/irText/stubs/javaInnerClass.fir.txt +++ b/compiler/testData/ir/irText/stubs/javaInnerClass.fir.txt @@ -9,6 +9,7 @@ FILE fqName: fileName:/javaInnerClass.kt FIELD PROPERTY_BACKING_FIELD name:test type:.J.JInner visibility:private [final] EXPRESSION_BODY CONSTRUCTOR_CALL 'public constructor () [primary] declared in .J.JInner' type=.J.JInner origin=null + $outer: GET_VAR ': .Test1 declared in .Test1' type=.Test1 origin=null FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.Test1) returnType:.J.JInner correspondingProperty: PROPERTY name:test visibility:public modality:FINAL [val] $this: VALUE_PARAMETER name: type:.Test1