From c939fb7b0570beba9ab0acf884e51a25cc4152dc Mon Sep 17 00:00:00 2001 From: Dmitry Petrov Date: Fri, 24 Jan 2020 21:33:29 +0300 Subject: [PATCH] PSI2IR: Fix argument adaptation for unbound references NB front-end "lies". --- .../kotlin/fir/Fir2IrTextTestGenerated.java | 5 + .../calls/tower/ResolvedAtomCompleter.kt | 24 +++-- .../ReflectionReferencesGenerator.kt | 15 ++- ...emberReferenceWithAdaptedArguments.fir.txt | 70 ++++++++++++ ...oundMemberReferenceWithAdaptedArguments.kt | 25 +++++ ...undMemberReferenceWithAdaptedArguments.txt | 100 ++++++++++++++++++ .../kotlin/ir/IrTextTestCaseGenerated.java | 5 + 7 files changed, 230 insertions(+), 14 deletions(-) create mode 100644 compiler/testData/ir/irText/expressions/callableReferences/unboundMemberReferenceWithAdaptedArguments.fir.txt create mode 100644 compiler/testData/ir/irText/expressions/callableReferences/unboundMemberReferenceWithAdaptedArguments.kt create mode 100644 compiler/testData/ir/irText/expressions/callableReferences/unboundMemberReferenceWithAdaptedArguments.txt diff --git a/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/fir/Fir2IrTextTestGenerated.java b/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/fir/Fir2IrTextTestGenerated.java index 2742fe4eed5..0f2fd3f62d2 100644 --- a/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/fir/Fir2IrTextTestGenerated.java +++ b/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/fir/Fir2IrTextTestGenerated.java @@ -1379,6 +1379,11 @@ public class Fir2IrTextTestGenerated extends AbstractFir2IrTextTest { runTest("compiler/testData/ir/irText/expressions/callableReferences/typeArguments.kt"); } + @TestMetadata("unboundMemberReferenceWithAdaptedArguments.kt") + public void testUnboundMemberReferenceWithAdaptedArguments() throws Exception { + runTest("compiler/testData/ir/irText/expressions/callableReferences/unboundMemberReferenceWithAdaptedArguments.kt"); + } + @TestMetadata("withAdaptedArguments.kt") public void testWithAdaptedArguments() throws Exception { runTest("compiler/testData/ir/irText/expressions/callableReferences/withAdaptedArguments.kt"); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/ResolvedAtomCompleter.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/ResolvedAtomCompleter.kt index 821e8ce5d8d..acc66b00c2a 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/ResolvedAtomCompleter.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/ResolvedAtomCompleter.kt @@ -38,6 +38,7 @@ import org.jetbrains.kotlin.resolve.calls.tasks.TracingStrategyImpl import org.jetbrains.kotlin.resolve.calls.util.CallMaker import org.jetbrains.kotlin.resolve.checkers.MissingDependencySupertypeChecker import org.jetbrains.kotlin.resolve.deprecation.DeprecationResolver +import org.jetbrains.kotlin.resolve.scopes.receivers.TransientReceiver import org.jetbrains.kotlin.types.* import org.jetbrains.kotlin.types.expressions.DoubleColonExpressionResolver import org.jetbrains.kotlin.types.expressions.ExpressionTypingServices @@ -370,6 +371,16 @@ class ResolvedAtomCompleter( if (callableReferenceAdaptation == null) return val callElement = resolvedCall.call.callElement + val isUnboundReference = resolvedCall.dispatchReceiver is TransientReceiver + + fun makeFakeValueArgument(callArgument: KotlinCallArgument): ValueArgument { + val fakeCallArgument = callArgument as? FakeKotlinCallArgumentForCallableReference + ?: throw AssertionError("FakeKotlinCallArgumentForCallableReference expected: $callArgument") + return FakePositionalValueArgumentForCallableReferenceImpl( + callElement, + if (isUnboundReference) fakeCallArgument.index + 1 else fakeCallArgument.index + ) + } for ((valueParameter, resolvedCallArgument) in callableReferenceAdaptation.mappedArguments) { resolvedCall.recordValueArgument( @@ -378,7 +389,7 @@ class ResolvedAtomCompleter( ResolvedCallArgument.DefaultArgument -> DefaultValueArgument.DEFAULT is ResolvedCallArgument.SimpleArgument -> { - val valueArgument = makeFakeValueArgument(resolvedCallArgument.callArgument, callElement) + val valueArgument = makeFakeValueArgument(resolvedCallArgument.callArgument) if (valueParameter.isVararg) VarargValueArgument( listOf( @@ -391,7 +402,7 @@ class ResolvedAtomCompleter( is ResolvedCallArgument.VarargArgument -> VarargValueArgument( resolvedCallArgument.arguments.map { - makeFakeValueArgument(it, callElement) + makeFakeValueArgument(it) } ) } @@ -399,15 +410,6 @@ class ResolvedAtomCompleter( } } - private fun makeFakeValueArgument( - callArgument: KotlinCallArgument, - callElement: KtElement - ): ValueArgument { - val fakeCallArgument = callArgument as? FakeKotlinCallArgumentForCallableReference - ?: throw AssertionError("FakeKotlinCallArgumentForCallableReference expected: $callArgument") - return FakePositionalValueArgumentForCallableReferenceImpl(callElement, fakeCallArgument.index) - } - private fun completeCollectionLiteralCalls(collectionLiteralArgument: ResolvedCollectionLiteralAtom) { val psiCallArgument = collectionLiteralArgument.atom.psiCallArgument as CollectionLiteralKotlinCallArgumentImpl val context = psiCallArgument.outerCallContext diff --git a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/ReflectionReferencesGenerator.kt b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/ReflectionReferencesGenerator.kt index 443484d834f..420be9931fe 100644 --- a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/ReflectionReferencesGenerator.kt +++ b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/ReflectionReferencesGenerator.kt @@ -38,6 +38,7 @@ import org.jetbrains.kotlin.psi.psiUtil.startOffsetSkippingComments import org.jetbrains.kotlin.psi2ir.intermediate.CallBuilder import org.jetbrains.kotlin.resolve.BindingContext import org.jetbrains.kotlin.resolve.calls.model.* +import org.jetbrains.kotlin.resolve.scopes.receivers.TransientReceiver import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.expressions.DoubleColonLHS import org.jetbrains.kotlin.utils.addIfNotNull @@ -274,6 +275,13 @@ class ReflectionReferencesGenerator(statementGenerator: StatementGenerator) : St throw AssertionError("Callable reference with adapted arguments expected: ${resolvedCall.call.callElement.text}") } + if (resolvedCall.dispatchReceiver is TransientReceiver) { + // Unbound callable reference 'A::foo', receiver is passed as a first parameter + val irAdaptedReceiverParameter = irAdapterFun.valueParameters[0] + irAdapteeCall.dispatchReceiver = + IrGetValueImpl(startOffset, endOffset, irAdaptedReceiverParameter.type, irAdaptedReceiverParameter.symbol) + } + for ((valueParameter, valueArgument) in adaptedArguments) { val substitutedValueParameter = resolvedCall.resultingDescriptor.valueParameters[valueParameter.index] irAdapteeCall.putValueArgument( @@ -289,8 +297,8 @@ class ReflectionReferencesGenerator(statementGenerator: StatementGenerator) : St resolvedValueArgument: ResolvedValueArgument, irAdapterFun: IrSimpleFunction, valueParameter: ValueParameterDescriptor - ): IrExpression? = - when (resolvedValueArgument) { + ): IrExpression? { + return when (resolvedValueArgument) { is DefaultValueArgument -> null is VarargValueArgument -> @@ -309,8 +317,9 @@ class ReflectionReferencesGenerator(statementGenerator: StatementGenerator) : St else -> throw AssertionError("Unexpected ResolvedValueArgument: $resolvedValueArgument") } + } - private fun adaptValueArgument( + fun adaptValueArgument( startOffset: Int, endOffset: Int, valueArgument: ValueArgument, diff --git a/compiler/testData/ir/irText/expressions/callableReferences/unboundMemberReferenceWithAdaptedArguments.fir.txt b/compiler/testData/ir/irText/expressions/callableReferences/unboundMemberReferenceWithAdaptedArguments.fir.txt new file mode 100644 index 00000000000..795e96307a6 --- /dev/null +++ b/compiler/testData/ir/irText/expressions/callableReferences/unboundMemberReferenceWithAdaptedArguments.fir.txt @@ -0,0 +1,70 @@ +FILE fqName: fileName:/unboundMemberReferenceWithAdaptedArguments.kt + FUN name:use1 visibility:public modality:FINAL <> (fn:kotlin.Function2<.A, kotlin.Int, kotlin.Unit>) returnType:kotlin.Unit + VALUE_PARAMETER name:fn index:0 type:kotlin.Function2<.A, kotlin.Int, kotlin.Unit> + BLOCK_BODY + FUN name:use2 visibility:public modality:FINAL <> (fn:kotlin.Function1) returnType:kotlin.Unit + VALUE_PARAMETER name:fn index:0 type:kotlin.Function1 + BLOCK_BODY + CLASS CLASS name:A modality:OPEN visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.A + CONSTRUCTOR visibility:public <> () returnType:.A [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:A modality:OPEN visibility:public superTypes:[kotlin.Any]' + FUN name:foo visibility:public modality:OPEN <> ($this:.A, xs:kotlin.IntArray) returnType:kotlin.Int + $this: VALUE_PARAMETER name: type:.A + VALUE_PARAMETER name:xs index:0 type:kotlin.IntArray + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun foo (xs: kotlin.IntArray): kotlin.Int declared in .A' + CONST Int type=kotlin.Int value=1 + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS OBJECT name:Obj modality:FINAL visibility:public superTypes:[.A] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Obj + CONSTRUCTOR visibility:private <> () returnType:.Obj [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in .A' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS OBJECT name:Obj modality:FINAL visibility:public superTypes:[.A]' + FUN name:foo visibility:public modality:FINAL <> ($this:.Obj, xs:kotlin.IntArray) returnType:kotlin.Int + $this: VALUE_PARAMETER name: type:.Obj + VALUE_PARAMETER name:xs index:0 type:kotlin.IntArray + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun foo (xs: kotlin.IntArray): kotlin.Int declared in .Obj' + CONST Int type=kotlin.Int value=1 + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN name:testUnbound visibility:public modality:FINAL <> () returnType:kotlin.Unit + BLOCK_BODY + ERROR_CALL 'Unresolved reference: #' type=IrErrorType + FUNCTION_REFERENCE 'public open fun foo (xs: kotlin.IntArray): kotlin.Int declared in .A' type=kotlin.reflect.KFunction2<.A, kotlin.IntArray, kotlin.Int> origin=null reflectionTarget= + FUN name:testBound visibility:public modality:FINAL <> (a:.A) returnType:kotlin.Unit + VALUE_PARAMETER name:a index:0 type:.A + BLOCK_BODY + ERROR_CALL 'Unresolved reference: #' type=IrErrorType + FUNCTION_REFERENCE 'public open fun foo (xs: kotlin.IntArray): kotlin.Int declared in .A' type=kotlin.reflect.KFunction1 origin=null reflectionTarget= + FUN name:testObject visibility:public modality:FINAL <> () returnType:kotlin.Unit + BLOCK_BODY + ERROR_CALL 'Unresolved reference: #' type=IrErrorType + FUNCTION_REFERENCE 'public final fun foo (xs: kotlin.IntArray): kotlin.Int declared in .Obj' type=kotlin.reflect.KFunction1 origin=null reflectionTarget= diff --git a/compiler/testData/ir/irText/expressions/callableReferences/unboundMemberReferenceWithAdaptedArguments.kt b/compiler/testData/ir/irText/expressions/callableReferences/unboundMemberReferenceWithAdaptedArguments.kt new file mode 100644 index 00000000000..0b730955ac9 --- /dev/null +++ b/compiler/testData/ir/irText/expressions/callableReferences/unboundMemberReferenceWithAdaptedArguments.kt @@ -0,0 +1,25 @@ +// !LANGUAGE: +NewInference, +FunctionReferenceWithDefaultValueAsOtherType + +fun use1(fn: (A, Int) -> Unit) {} + +fun use2(fn: (Int) -> Unit) {} + +open class A { + open fun foo(vararg xs: Int) = 1 +} + +object Obj : A() { + override fun foo(vararg xs: Int) = 1 +} + +fun testUnbound() { + use1(A::foo) +} + +fun testBound(a: A) { + use2(a::foo) +} + +fun testObject() { + use2(Obj::foo) +} diff --git a/compiler/testData/ir/irText/expressions/callableReferences/unboundMemberReferenceWithAdaptedArguments.txt b/compiler/testData/ir/irText/expressions/callableReferences/unboundMemberReferenceWithAdaptedArguments.txt new file mode 100644 index 00000000000..869ef7b8cc5 --- /dev/null +++ b/compiler/testData/ir/irText/expressions/callableReferences/unboundMemberReferenceWithAdaptedArguments.txt @@ -0,0 +1,100 @@ +FILE fqName: fileName:/unboundMemberReferenceWithAdaptedArguments.kt + FUN name:use1 visibility:public modality:FINAL <> (fn:kotlin.Function2<.A, kotlin.Int, kotlin.Unit>) returnType:kotlin.Unit + VALUE_PARAMETER name:fn index:0 type:kotlin.Function2<.A, kotlin.Int, kotlin.Unit> + BLOCK_BODY + FUN name:use2 visibility:public modality:FINAL <> (fn:kotlin.Function1) returnType:kotlin.Unit + VALUE_PARAMETER name:fn index:0 type:kotlin.Function1 + BLOCK_BODY + CLASS CLASS name:A modality:OPEN visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.A + CONSTRUCTOR visibility:public <> () returnType:.A [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:A modality:OPEN visibility:public superTypes:[kotlin.Any]' + FUN name:foo visibility:public modality:OPEN <> ($this:.A, xs:kotlin.IntArray) returnType:kotlin.Int + $this: VALUE_PARAMETER name: type:.A + VALUE_PARAMETER name:xs index:0 type:kotlin.IntArray varargElementType:kotlin.Int [vararg] + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun foo (vararg xs: kotlin.Int): kotlin.Int declared in .A' + CONST Int type=kotlin.Int value=1 + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS OBJECT name:Obj modality:FINAL visibility:public superTypes:[.A] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Obj + CONSTRUCTOR visibility:private <> () returnType:.Obj [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in .A' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS OBJECT name:Obj modality:FINAL visibility:public superTypes:[.A]' + FUN name:foo visibility:public modality:OPEN <> ($this:.Obj, xs:kotlin.IntArray) returnType:kotlin.Int + overridden: + public open fun foo (vararg xs: kotlin.Int): kotlin.Int declared in .A + $this: VALUE_PARAMETER name: type:.Obj + VALUE_PARAMETER name:xs index:0 type:kotlin.IntArray varargElementType:kotlin.Int [vararg] + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun foo (vararg xs: kotlin.Int): kotlin.Int declared in .Obj' + CONST Int type=kotlin.Int value=1 + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .A + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int [fake_override] declared in .A + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String [fake_override] declared in .A + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN name:testUnbound visibility:public modality:FINAL <> () returnType:kotlin.Unit + BLOCK_BODY + CALL 'public final fun use1 (fn: kotlin.Function2<.A, kotlin.Int, kotlin.Unit>): kotlin.Unit declared in ' type=kotlin.Unit origin=null + fn: BLOCK type=kotlin.reflect.KFunction2<.A, kotlin.Int, kotlin.Unit> origin=null + FUN ADAPTER_FOR_CALLABLE_REFERENCE name:foo visibility:local modality:FINAL <> (p0:.A, p1:kotlin.Int) returnType:kotlin.Unit + VALUE_PARAMETER ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE name:p0 index:0 type:.A + VALUE_PARAMETER ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE name:p1 index:1 type:kotlin.Int + BLOCK_BODY + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + CALL 'public open fun foo (vararg xs: kotlin.Int): kotlin.Int declared in .A' type=kotlin.Int origin=null + $this: GET_VAR 'p0: .A declared in .testUnbound.foo' type=.A origin=null + xs: VARARG type=kotlin.IntArray varargElementType=kotlin.Int + GET_VAR 'p1: kotlin.Int declared in .testUnbound.foo' type=kotlin.Int origin=null + FUNCTION_REFERENCE 'local final fun foo (p0: .A, p1: kotlin.Int): kotlin.Unit declared in .testUnbound' type=kotlin.reflect.KFunction2<.A, kotlin.Int, kotlin.Unit> origin=null reflectionTarget=null + FUN name:testBound visibility:public modality:FINAL <> (a:.A) returnType:kotlin.Unit + VALUE_PARAMETER name:a index:0 type:.A + BLOCK_BODY + CALL 'public final fun use2 (fn: kotlin.Function1): kotlin.Unit declared in ' type=kotlin.Unit origin=null + fn: BLOCK type=kotlin.reflect.KFunction1 origin=null + FUN ADAPTER_FOR_CALLABLE_REFERENCE name:foo visibility:local modality:FINAL <> (p0:kotlin.Int) returnType:kotlin.Unit + VALUE_PARAMETER ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE name:p0 index:0 type:kotlin.Int + BLOCK_BODY + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + CALL 'public open fun foo (vararg xs: kotlin.Int): kotlin.Int declared in .A' type=kotlin.Int origin=null + $this: GET_VAR 'a: .A declared in .testBound' type=.A origin=null + xs: VARARG type=kotlin.IntArray varargElementType=kotlin.Int + GET_VAR 'p0: kotlin.Int declared in .testBound.foo' type=kotlin.Int origin=null + FUNCTION_REFERENCE 'local final fun foo (p0: kotlin.Int): kotlin.Unit declared in .testBound' type=kotlin.reflect.KFunction1 origin=null reflectionTarget=null + FUN name:testObject visibility:public modality:FINAL <> () returnType:kotlin.Unit + BLOCK_BODY + CALL 'public final fun use2 (fn: kotlin.Function1): kotlin.Unit declared in ' type=kotlin.Unit origin=null + fn: BLOCK type=kotlin.reflect.KFunction1 origin=null + FUN ADAPTER_FOR_CALLABLE_REFERENCE name:foo visibility:local modality:FINAL <> (p0:kotlin.Int) returnType:kotlin.Unit + VALUE_PARAMETER ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE name:p0 index:0 type:kotlin.Int + BLOCK_BODY + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + CALL 'public open fun foo (vararg xs: kotlin.Int): kotlin.Int declared in .Obj' type=kotlin.Int origin=null + $this: GET_OBJECT 'CLASS OBJECT name:Obj modality:FINAL visibility:public superTypes:[.A]' type=.Obj + xs: VARARG type=kotlin.IntArray varargElementType=kotlin.Int + GET_VAR 'p0: kotlin.Int declared in .testObject.foo' type=kotlin.Int origin=null + FUNCTION_REFERENCE 'local final fun foo (p0: kotlin.Int): kotlin.Unit declared in .testObject' type=kotlin.reflect.KFunction1 origin=null reflectionTarget=null diff --git a/compiler/tests/org/jetbrains/kotlin/ir/IrTextTestCaseGenerated.java b/compiler/tests/org/jetbrains/kotlin/ir/IrTextTestCaseGenerated.java index 3a84e781780..3780d2eab38 100644 --- a/compiler/tests/org/jetbrains/kotlin/ir/IrTextTestCaseGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/ir/IrTextTestCaseGenerated.java @@ -1378,6 +1378,11 @@ public class IrTextTestCaseGenerated extends AbstractIrTextTestCase { runTest("compiler/testData/ir/irText/expressions/callableReferences/typeArguments.kt"); } + @TestMetadata("unboundMemberReferenceWithAdaptedArguments.kt") + public void testUnboundMemberReferenceWithAdaptedArguments() throws Exception { + runTest("compiler/testData/ir/irText/expressions/callableReferences/unboundMemberReferenceWithAdaptedArguments.kt"); + } + @TestMetadata("withAdaptedArguments.kt") public void testWithAdaptedArguments() throws Exception { runTest("compiler/testData/ir/irText/expressions/callableReferences/withAdaptedArguments.kt");