diff --git a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirOldFrontendDiagnosticsTestGenerated.java b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirOldFrontendDiagnosticsTestGenerated.java index 5d14a817eaa..d03fb8bf726 100644 --- a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirOldFrontendDiagnosticsTestGenerated.java +++ b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirOldFrontendDiagnosticsTestGenerated.java @@ -1869,6 +1869,11 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirOldFronte runTest("compiler/testData/diagnostics/tests/callableReference/kt34314_lambda.kt"); } + @TestMetadata("kt35959.kt") + public void testKt35959() throws Exception { + runTest("compiler/testData/diagnostics/tests/callableReference/kt35959.kt"); + } + @TestMetadata("kt7430_wrongClassOnLHS.kt") public void testKt7430_wrongClassOnLHS() throws Exception { runTest("compiler/testData/diagnostics/tests/callableReference/kt7430_wrongClassOnLHS.kt"); diff --git a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/components/KotlinConstraintSystemCompleter.kt b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/components/KotlinConstraintSystemCompleter.kt index 5e7dd8f3b77..a3b8368c7f2 100644 --- a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/components/KotlinConstraintSystemCompleter.kt +++ b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/components/KotlinConstraintSystemCompleter.kt @@ -241,7 +241,10 @@ class KotlinConstraintSystemCompleter( fun ResolvedAtom.process(to: LinkedHashSet) { val typeVariables = when (this) { is ResolvedCallAtom -> freshVariablesSubstitutor.freshVariables - is CallableReferenceWithTypeVariableAsExpectedTypeAtom -> listOfNotNull(typeVariableForReturnType) + is CallableReferenceWithTypeVariableAsExpectedTypeAtom -> mutableListOf().apply { + addIfNotNull(typeVariableForReturnType) + addAll(candidate?.freshSubstitutor?.freshVariables.orEmpty()) + } is ResolvedCallableReferenceAtom -> candidate?.freshSubstitutor?.freshVariables.orEmpty() is ResolvedLambdaAtom -> listOfNotNull(typeVariableForLambdaReturnType) else -> emptyList() diff --git a/compiler/testData/diagnostics/tests/callableReference/kt35959.fir.kt b/compiler/testData/diagnostics/tests/callableReference/kt35959.fir.kt new file mode 100644 index 00000000000..81c3ef8e1eb --- /dev/null +++ b/compiler/testData/diagnostics/tests/callableReference/kt35959.fir.kt @@ -0,0 +1,12 @@ +// !LANGUAGE: +NewInference +// !DIAGNOSTICS: -UNUSED_PARAMETER +// ISSUE: KT-35959 + +interface Expect + +inline val Expect.and: Expect get() = this +infix fun Expect.and(assertionCreator: Expect.() -> Unit): Expect = this + +fun id(x: K): K = x + +fun test(): Expect.(Expect.() -> Unit) -> Expect = id(Expect::and) diff --git a/compiler/testData/diagnostics/tests/callableReference/kt35959.kt b/compiler/testData/diagnostics/tests/callableReference/kt35959.kt new file mode 100644 index 00000000000..81c3ef8e1eb --- /dev/null +++ b/compiler/testData/diagnostics/tests/callableReference/kt35959.kt @@ -0,0 +1,12 @@ +// !LANGUAGE: +NewInference +// !DIAGNOSTICS: -UNUSED_PARAMETER +// ISSUE: KT-35959 + +interface Expect + +inline val Expect.and: Expect get() = this +infix fun Expect.and(assertionCreator: Expect.() -> Unit): Expect = this + +fun id(x: K): K = x + +fun test(): Expect.(Expect.() -> Unit) -> Expect = id(Expect::and) diff --git a/compiler/testData/diagnostics/tests/callableReference/kt35959.txt b/compiler/testData/diagnostics/tests/callableReference/kt35959.txt new file mode 100644 index 00000000000..10ed82dc500 --- /dev/null +++ b/compiler/testData/diagnostics/tests/callableReference/kt35959.txt @@ -0,0 +1,12 @@ +package + +public val Expect.and: Expect +public fun id(/*0*/ x: K): K +public fun test(): Expect.(Expect.() -> kotlin.Unit) -> Expect +public infix fun Expect.and(/*0*/ assertionCreator: Expect.() -> kotlin.Unit): Expect + +public interface Expect { + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java index 1939d432f3b..cd5fb93e21b 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java @@ -1876,6 +1876,11 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest { runTest("compiler/testData/diagnostics/tests/callableReference/kt34314_lambda.kt"); } + @TestMetadata("kt35959.kt") + public void testKt35959() throws Exception { + runTest("compiler/testData/diagnostics/tests/callableReference/kt35959.kt"); + } + @TestMetadata("kt7430_wrongClassOnLHS.kt") public void testKt7430_wrongClassOnLHS() throws Exception { runTest("compiler/testData/diagnostics/tests/callableReference/kt7430_wrongClassOnLHS.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java index f30ce340fbd..4dff5eca7c5 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java @@ -1871,6 +1871,11 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing runTest("compiler/testData/diagnostics/tests/callableReference/kt34314_lambda.kt"); } + @TestMetadata("kt35959.kt") + public void testKt35959() throws Exception { + runTest("compiler/testData/diagnostics/tests/callableReference/kt35959.kt"); + } + @TestMetadata("kt7430_wrongClassOnLHS.kt") public void testKt7430_wrongClassOnLHS() throws Exception { runTest("compiler/testData/diagnostics/tests/callableReference/kt7430_wrongClassOnLHS.kt");