diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/GenericCandidateResolver.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/GenericCandidateResolver.kt index 02da30d1434..e0487b22b7e 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/GenericCandidateResolver.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/GenericCandidateResolver.kt @@ -404,10 +404,9 @@ class GenericCandidateResolver( .replaceExpectedType(expectedTypeWithoutReturnType) .replaceDataFlowInfo(dataFlowInfoForArgument) .replaceContextDependency(INDEPENDENT) - val argumentExpression = valueArgument.getArgumentExpression()!! - val type = argumentTypeResolver.getCallableReferenceTypeInfo( - argumentExpression, callableReference, newContext, RESOLVE_FUNCTION_ARGUMENTS).type - return type + return argumentTypeResolver.getCallableReferenceTypeInfo( + callableReference, callableReference, newContext, RESOLVE_FUNCTION_ARGUMENTS + ).type } } diff --git a/compiler/testData/codegen/box/callableReference/property/kt12044.kt b/compiler/testData/codegen/box/callableReference/property/kt12044.kt new file mode 100644 index 00000000000..ea43b14b545 --- /dev/null +++ b/compiler/testData/codegen/box/callableReference/property/kt12044.kt @@ -0,0 +1,12 @@ +// KT-12044 Assertion "Rewrite at slice LEXICAL_SCOPE" for 'if' with property references + +fun box(): String { + data class Pair(val first: F, val second: S) + val (x, y) = + Pair(1, + if (1 == 1) + Pair::first + else + Pair::second) + return y.get(Pair("OK", "Fail")) +} diff --git a/compiler/testData/codegen/light-analysis/callableReference/property/kt12044.txt b/compiler/testData/codegen/light-analysis/callableReference/property/kt12044.txt new file mode 100644 index 00000000000..370ab6338d3 --- /dev/null +++ b/compiler/testData/codegen/light-analysis/callableReference/property/kt12044.txt @@ -0,0 +1,3 @@ +public final class Kt12044Kt { + public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String +} diff --git a/compiler/testData/diagnostics/tests/callableReference/resolve/kt12338.kt b/compiler/testData/diagnostics/tests/callableReference/resolve/kt12338.kt new file mode 100644 index 00000000000..dba235fe1cf --- /dev/null +++ b/compiler/testData/diagnostics/tests/callableReference/resolve/kt12338.kt @@ -0,0 +1,9 @@ +// KT-12338 Compiler error ERROR: Rewrite at slice LEXICAL_SCOPE key: REFERENCE_EXPRESSION with when and function references + +fun a() { } + +fun test() { + when { + true -> ::a + } +} diff --git a/compiler/testData/diagnostics/tests/callableReference/resolve/kt12338.txt b/compiler/testData/diagnostics/tests/callableReference/resolve/kt12338.txt new file mode 100644 index 00000000000..2449fd1ec33 --- /dev/null +++ b/compiler/testData/diagnostics/tests/callableReference/resolve/kt12338.txt @@ -0,0 +1,4 @@ +package + +public fun a(): kotlin.Unit +public fun test(): kotlin.Unit diff --git a/compiler/tests-ir-jvm/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java b/compiler/tests-ir-jvm/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java index ec18b7a637e..dd4f1c58615 100644 --- a/compiler/tests-ir-jvm/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests-ir-jvm/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java @@ -2062,6 +2062,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes doTest(fileName); } + @TestMetadata("kt12044.kt") + public void testKt12044() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/callableReference/property/kt12044.kt"); + doTest(fileName); + } + @TestMetadata("kt12982_protectedPropertyReference.kt") public void testKt12982_protectedPropertyReference() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/callableReference/property/kt12982_protectedPropertyReference.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java index 7825aec6406..3ddefe7a1d9 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java @@ -2382,6 +2382,12 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest { doTest(fileName); } + @TestMetadata("kt12338.kt") + public void testKt12338() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/callableReference/resolve/kt12338.kt"); + doTest(fileName); + } + @TestMetadata("kt12751.kt") public void testKt12751() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/callableReference/resolve/kt12751.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java index ceeca8c3f2b..49eadb998e4 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java @@ -2062,6 +2062,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { doTest(fileName); } + @TestMetadata("kt12044.kt") + public void testKt12044() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/callableReference/property/kt12044.kt"); + doTest(fileName); + } + @TestMetadata("kt12982_protectedPropertyReference.kt") public void testKt12982_protectedPropertyReference() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/callableReference/property/kt12982_protectedPropertyReference.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeCodegenTestGenerated.java index 52fa03a9ced..6d2f7e85b92 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeCodegenTestGenerated.java @@ -2062,6 +2062,12 @@ public class LightAnalysisModeCodegenTestGenerated extends AbstractLightAnalysis doTest(fileName); } + @TestMetadata("kt12044.kt") + public void testKt12044() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/callableReference/property/kt12044.kt"); + doTest(fileName); + } + @TestMetadata("kt12982_protectedPropertyReference.kt") public void testKt12982_protectedPropertyReference() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/callableReference/property/kt12982_protectedPropertyReference.kt"); diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java index 26711664faa..864fd825899 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java @@ -2525,6 +2525,12 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { doTest(fileName); } + @TestMetadata("kt12044.kt") + public void testKt12044() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/callableReference/property/kt12044.kt"); + doTest(fileName); + } + @TestMetadata("kt12982_protectedPropertyReference.kt") public void testKt12982_protectedPropertyReference() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/callableReference/property/kt12982_protectedPropertyReference.kt");