Report more specific diagnostic for variable + invoke calls
Do not report same set of diagnostics for variable call if actual error was happened with a function candidate. Here the candidate is invoke function on DeepRecursiveFunction ^KT-40991 Fixed ^KT-41491 Fixed ^KT-40926 In Progress
This commit is contained in:
+6
@@ -22962,6 +22962,12 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti
|
||||
runTest("compiler/testData/diagnostics/tests/resolve/invoke/kt9805.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("reportFunctionExpectedOnSimpleUnresolved.kt")
|
||||
public void testReportFunctionExpectedOnSimpleUnresolved() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/resolve/invoke/reportFunctionExpectedOnSimpleUnresolved.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("reportFunctionExpectedWhenOneInvokeExist.kt")
|
||||
public void testReportFunctionExpectedWhenOneInvokeExist() throws Exception {
|
||||
|
||||
+4
-2
@@ -205,10 +205,12 @@ class KotlinToResolvedCallTransformer(
|
||||
): ResolvedCall<D> {
|
||||
val psiKotlinCall = completedCallAtom.atom.psiKotlinCall
|
||||
return if (psiKotlinCall is PSIKotlinCallForInvoke) {
|
||||
val diagnosticsForVariableCall = if (completedCallAtom.candidateDescriptor is FunctionDescriptor) emptyList() else diagnostics
|
||||
val diagnosticsForFunctionCall = if (completedCallAtom.candidateDescriptor is FunctionDescriptor) diagnostics else emptyList()
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
NewVariableAsFunctionResolvedCallImpl(
|
||||
createOrGet(psiKotlinCall.variableCall.resolvedCall, trace, resultSubstitutor, diagnostics),
|
||||
createOrGet(completedCallAtom, trace, resultSubstitutor, diagnostics),
|
||||
createOrGet(psiKotlinCall.variableCall.resolvedCall, trace, resultSubstitutor, diagnosticsForVariableCall),
|
||||
createOrGet(completedCallAtom, trace, resultSubstitutor, diagnosticsForFunctionCall),
|
||||
) as ResolvedCall<D>
|
||||
} else {
|
||||
createOrGet(completedCallAtom, trace, resultSubstitutor, diagnostics)
|
||||
|
||||
+1
-1
@@ -275,7 +275,7 @@ fun poll8() {
|
||||
|
||||
fun poll81() {
|
||||
val inv = ::bar2 <!TYPE_INFERENCE_ONLY_INPUT_TYPES_WARNING!>in<!> setOf(::foo2)
|
||||
<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>inv<!>()
|
||||
<!DEBUG_INFO_MISSING_UNRESOLVED, FUNCTION_EXPECTED!>inv<!>()
|
||||
}
|
||||
|
||||
fun poll82() {
|
||||
|
||||
Vendored
+1
-1
@@ -7,7 +7,7 @@ fun Int.invoke(a: Int, b: Int) {}
|
||||
class SomeClass
|
||||
|
||||
fun test(identifier: SomeClass, fn: String.() -> Unit) {
|
||||
<!DEBUG_INFO_MISSING_UNRESOLVED{OI}, FUNCTION_EXPECTED{OI}, UNRESOLVED_REFERENCE_WRONG_RECEIVER{NI}!>identifier<!>()
|
||||
<!DEBUG_INFO_MISSING_UNRESOLVED, FUNCTION_EXPECTED!>identifier<!>()
|
||||
<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>identifier<!>(123)
|
||||
<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>identifier<!>(1, 2)
|
||||
1.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>fn<!>()
|
||||
|
||||
Vendored
+16
@@ -0,0 +1,16 @@
|
||||
object Scope1 {
|
||||
val someVar: Any = Any()
|
||||
|
||||
fun foo() {
|
||||
<!UNRESOLVED_REFERENCE!>someVar<!>(1)
|
||||
}
|
||||
}
|
||||
|
||||
object Scope2 {
|
||||
class Foo
|
||||
|
||||
fun use() {
|
||||
val foo = Foo()
|
||||
<!UNRESOLVED_REFERENCE!>foo<!>()
|
||||
}
|
||||
}
|
||||
Vendored
+16
@@ -0,0 +1,16 @@
|
||||
object Scope1 {
|
||||
val someVar: Any = Any()
|
||||
|
||||
fun foo() {
|
||||
<!FUNCTION_EXPECTED!>someVar<!>(1)
|
||||
}
|
||||
}
|
||||
|
||||
object Scope2 {
|
||||
class Foo
|
||||
|
||||
fun use() {
|
||||
val foo = Foo()
|
||||
<!FUNCTION_EXPECTED!>foo<!>()
|
||||
}
|
||||
}
|
||||
Vendored
+25
@@ -0,0 +1,25 @@
|
||||
package
|
||||
|
||||
public object Scope1 {
|
||||
private constructor Scope1()
|
||||
public final val someVar: kotlin.Any
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public final fun foo(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public object Scope2 {
|
||||
private constructor Scope2()
|
||||
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 fun use(): kotlin.Unit
|
||||
|
||||
public final class Foo {
|
||||
public constructor Foo()
|
||||
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
|
||||
}
|
||||
}
|
||||
Vendored
+1
-1
@@ -6,7 +6,7 @@ fun Int.invoke() {}
|
||||
class SomeClass
|
||||
|
||||
fun test(identifier: SomeClass, fn: String.() -> Unit) {
|
||||
<!DEBUG_INFO_MISSING_UNRESOLVED{OI}, FUNCTION_EXPECTED{OI}, UNRESOLVED_REFERENCE_WRONG_RECEIVER{NI}!>identifier<!>()
|
||||
<!DEBUG_INFO_MISSING_UNRESOLVED, FUNCTION_EXPECTED!>identifier<!>()
|
||||
<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>identifier<!>(123)
|
||||
<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>identifier<!>(1, 2)
|
||||
1.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>fn<!>()
|
||||
|
||||
Generated
+6
@@ -22974,6 +22974,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
|
||||
runTest("compiler/testData/diagnostics/tests/resolve/invoke/kt9805.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("reportFunctionExpectedOnSimpleUnresolved.kt")
|
||||
public void testReportFunctionExpectedOnSimpleUnresolved() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/resolve/invoke/reportFunctionExpectedOnSimpleUnresolved.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("reportFunctionExpectedWhenOneInvokeExist.kt")
|
||||
public void testReportFunctionExpectedWhenOneInvokeExist() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user