diff --git a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsSmokeTestGenerated.java b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsSmokeTestGenerated.java index 25f46a73033..21e6c01df9c 100644 --- a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsSmokeTestGenerated.java +++ b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsSmokeTestGenerated.java @@ -17395,6 +17395,11 @@ public class FirDiagnosticsSmokeTestGenerated extends AbstractFirDiagnosticsSmok runTest("compiler/testData/diagnostics/tests/regressions/kt316.kt"); } + @TestMetadata("kt31975.kt") + public void testKt31975() throws Exception { + runTest("compiler/testData/diagnostics/tests/regressions/kt31975.kt"); + } + @TestMetadata("kt32205.kt") public void testKt32205() throws Exception { runTest("compiler/testData/diagnostics/tests/regressions/kt32205.kt"); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/DiagnosticReporterByTrackingStrategy.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/DiagnosticReporterByTrackingStrategy.kt index 4219d3623c7..bbbb0b02fd6 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/DiagnosticReporterByTrackingStrategy.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/DiagnosticReporterByTrackingStrategy.kt @@ -357,10 +357,13 @@ class DiagnosticReporterByTrackingStrategy( } NotEnoughInformationForTypeParameter::class.java -> { - if (allDiagnostics.any {it is ConstrainingTypeIsError || it is NewConstraintError || it is WrongCountOfTypeArguments}) - return - val error = diagnostic as NotEnoughInformationForTypeParameter + if (allDiagnostics.any { + (it is ConstrainingTypeIsError && it.typeVariable == error.typeVariable) + || it is NewConstraintError || it is WrongCountOfTypeArguments + } + ) return + val call = error.resolvedAtom.atom?.safeAs()?.psiCall ?: call val expression = call.calleeExpression ?: return val typeVariableName = when (val typeVariable = error.typeVariable) { diff --git a/compiler/testData/diagnostics/tests/inference/constraints/errorUpperBoundConstraint.kt b/compiler/testData/diagnostics/tests/inference/constraints/errorUpperBoundConstraint.kt index 26de6fec138..187422bdd1c 100644 --- a/compiler/testData/diagnostics/tests/inference/constraints/errorUpperBoundConstraint.kt +++ b/compiler/testData/diagnostics/tests/inference/constraints/errorUpperBoundConstraint.kt @@ -20,7 +20,7 @@ public class Foo { // FILE: test.kt fun test(e: ErrorType) { - Foo.foo { + Foo.foo { Sam.Result.create(e) } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/regressions/kt31975.kt b/compiler/testData/diagnostics/tests/regressions/kt31975.kt new file mode 100644 index 00000000000..1b59ff233d1 --- /dev/null +++ b/compiler/testData/diagnostics/tests/regressions/kt31975.kt @@ -0,0 +1,18 @@ +// !LANGUAGE: +NewInference +// !DIAGNOSTICS: -UNUSED_PARAMETER + +interface MemoizedFunctionToNotNull + +fun createMemoizedFunction(compute: (K) -> V): MemoizedFunctionToNotNull = TODO() + +interface A + +interface TypeConstructor + +class Refiner { + val memoizedFunctionLambda = createMemoizedFunction { it.foo() } // error type infered, no diagnostic, BAD, backend fails + val memoizedFunctionReference = createMemoizedFunction(TypeConstructor::foo) // EXTENSION_IN_CLASS_REFERENCE_IS_NOT_ALLOWED, fine + val memoizedFunctionTypes = createMemoizedFunction { it.foo() } // works fine + + private fun TypeConstructor.foo(): Boolean = true +} diff --git a/compiler/testData/diagnostics/tests/regressions/kt31975.txt b/compiler/testData/diagnostics/tests/regressions/kt31975.txt new file mode 100644 index 00000000000..fb0c297b3ba --- /dev/null +++ b/compiler/testData/diagnostics/tests/regressions/kt31975.txt @@ -0,0 +1,32 @@ +package + +public fun createMemoizedFunction(/*0*/ compute: (K) -> V): MemoizedFunctionToNotNull + +public interface A { + 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 +} + +public interface MemoizedFunctionToNotNull { + 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 +} + +public final class Refiner { + public constructor Refiner() + public final val memoizedFunctionLambda: [ERROR : Type for createMemoizedFunction { it.foo() }] + public final val memoizedFunctionReference: MemoizedFunctionToNotNull + public final val memoizedFunctionTypes: MemoizedFunctionToNotNull + 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 + private final fun TypeConstructor.foo(): kotlin.Boolean +} + +public interface TypeConstructor { + 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 5b2d8637185..c53f3b995ca 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java @@ -17407,6 +17407,11 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest { runTest("compiler/testData/diagnostics/tests/regressions/kt316.kt"); } + @TestMetadata("kt31975.kt") + public void testKt31975() throws Exception { + runTest("compiler/testData/diagnostics/tests/regressions/kt31975.kt"); + } + @TestMetadata("kt32205.kt") public void testKt32205() throws Exception { runTest("compiler/testData/diagnostics/tests/regressions/kt32205.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java index 0020f48e281..05798236e39 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java @@ -17397,6 +17397,11 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing runTest("compiler/testData/diagnostics/tests/regressions/kt316.kt"); } + @TestMetadata("kt31975.kt") + public void testKt31975() throws Exception { + runTest("compiler/testData/diagnostics/tests/regressions/kt31975.kt"); + } + @TestMetadata("kt32205.kt") public void testKt32205() throws Exception { runTest("compiler/testData/diagnostics/tests/regressions/kt32205.kt");