[NI] Set correct applicability for unknown lambda parameter diagnostic

Unknown lambda parameter should not change resolve.
So the new diagnostic should not have error status; othrewise candidates with lower priority but more specific expected type may be chosen.

KT-34335 Fixed
See also KT-36264
This commit is contained in:
Pavel Kirpichenkov
2020-01-28 14:56:09 +03:00
parent eec039f5a2
commit 832064305f
7 changed files with 50 additions and 1 deletions
@@ -10161,6 +10161,11 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirOldFronte
runTest("compiler/testData/diagnostics/tests/inference/reportAboutUnresolvedReferenceAsUnresolved.kt");
}
@TestMetadata("resolveWithUnknownLambdaParameterType.kt")
public void testResolveWithUnknownLambdaParameterType() throws Exception {
runTest("compiler/testData/diagnostics/tests/inference/resolveWithUnknownLambdaParameterType.kt");
}
@TestMetadata("starApproximation.kt")
public void testStarApproximation() throws Exception {
runTest("compiler/testData/diagnostics/tests/inference/starApproximation.kt");
@@ -213,7 +213,7 @@ class ResolvedToSamWithVarargDiagnostic(val argument: KotlinCallArgument) : Kotl
class NotEnoughInformationForLambdaParameter(
val lambdaArgument: LambdaKotlinCallArgument,
val parameterIndex: Int
) : KotlinCallDiagnostic(INAPPLICABLE) {
) : KotlinCallDiagnostic(RESOLVED) {
override fun report(reporter: DiagnosticReporter) {
reporter.onCallArgument(lambdaArgument, this)
}
@@ -0,0 +1,11 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_ANONYMOUS_PARAMETER
fun baz(f: (Int) -> String) {}
object Foo {
fun baz(vararg anys: Any?) {}
fun testResolvedToMember() {
baz({ x -> "" }) // should be an error
}
}
@@ -0,0 +1,11 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_ANONYMOUS_PARAMETER
fun baz(f: (Int) -> String) {}
object Foo {
fun baz(vararg anys: Any?) {}
fun testResolvedToMember() {
baz({ <!CANNOT_INFER_PARAMETER_TYPE!>x<!> -> "" }) // should be an error
}
}
@@ -0,0 +1,12 @@
package
public fun baz(/*0*/ f: (kotlin.Int) -> kotlin.String): kotlin.Unit
public object Foo {
private constructor Foo()
public final fun baz(/*0*/ vararg anys: kotlin.Any? /*kotlin.Array<out kotlin.Any?>*/): kotlin.Unit
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 final fun testResolvedToMember(): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
@@ -10168,6 +10168,11 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
runTest("compiler/testData/diagnostics/tests/inference/reportAboutUnresolvedReferenceAsUnresolved.kt");
}
@TestMetadata("resolveWithUnknownLambdaParameterType.kt")
public void testResolveWithUnknownLambdaParameterType() throws Exception {
runTest("compiler/testData/diagnostics/tests/inference/resolveWithUnknownLambdaParameterType.kt");
}
@TestMetadata("starApproximation.kt")
public void testStarApproximation() throws Exception {
runTest("compiler/testData/diagnostics/tests/inference/starApproximation.kt");
@@ -10163,6 +10163,11 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing
runTest("compiler/testData/diagnostics/tests/inference/reportAboutUnresolvedReferenceAsUnresolved.kt");
}
@TestMetadata("resolveWithUnknownLambdaParameterType.kt")
public void testResolveWithUnknownLambdaParameterType() throws Exception {
runTest("compiler/testData/diagnostics/tests/inference/resolveWithUnknownLambdaParameterType.kt");
}
@TestMetadata("starApproximation.kt")
public void testStarApproximation() throws Exception {
runTest("compiler/testData/diagnostics/tests/inference/starApproximation.kt");