[NI] Fix diagnostic reporting for missing type parameter info
#KT-31975 fixed
This commit is contained in:
+5
@@ -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");
|
||||
|
||||
+6
-3
@@ -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<PSIKotlinCall>()?.psiCall ?: call
|
||||
val expression = call.calleeExpression ?: return
|
||||
val typeVariableName = when (val typeVariable = error.typeVariable) {
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@ public class Foo {
|
||||
// FILE: test.kt
|
||||
|
||||
fun test(e: <!UNRESOLVED_REFERENCE!>ErrorType<!>) {
|
||||
Foo.foo {
|
||||
Foo.<!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>foo<!> {
|
||||
Sam.Result.create(<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>e<!>)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
// !LANGUAGE: +NewInference
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
interface MemoizedFunctionToNotNull<K, V>
|
||||
|
||||
fun <K, V : Any> createMemoizedFunction(compute: (K) -> V): MemoizedFunctionToNotNull<K, V> = TODO()
|
||||
|
||||
interface A
|
||||
|
||||
interface TypeConstructor
|
||||
|
||||
class Refiner {
|
||||
val memoizedFunctionLambda = <!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>createMemoizedFunction<!> { <!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>it<!>.<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>foo<!>() } // error type infered, no diagnostic, BAD, backend fails
|
||||
val memoizedFunctionReference = createMemoizedFunction(TypeConstructor::<!EXTENSION_IN_CLASS_REFERENCE_NOT_ALLOWED!>foo<!>) // EXTENSION_IN_CLASS_REFERENCE_IS_NOT_ALLOWED, fine
|
||||
val memoizedFunctionTypes = createMemoizedFunction<TypeConstructor, Boolean> { it.foo() } // works fine
|
||||
|
||||
private fun TypeConstructor.foo(): Boolean = true
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package
|
||||
|
||||
public fun </*0*/ K, /*1*/ V : kotlin.Any> createMemoizedFunction(/*0*/ compute: (K) -> V): MemoizedFunctionToNotNull<K, V>
|
||||
|
||||
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</*0*/ K, /*1*/ V> {
|
||||
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<TypeConstructor, kotlin.Boolean>
|
||||
public final val memoizedFunctionTypes: MemoizedFunctionToNotNull<TypeConstructor, kotlin.Boolean>
|
||||
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
|
||||
}
|
||||
@@ -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");
|
||||
|
||||
Generated
+5
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user