KT-59504 [FIR] Check _ on destructuring declarations
Previously the checker was ignoring them, leading to missing diagnostics ^KT-59504 Fixed
This commit is contained in:
committed by
Space Team
parent
59129501cb
commit
b1551c67e0
+1
-1
@@ -5,7 +5,7 @@ fun useDeclaredVariables() {
|
||||
}
|
||||
|
||||
fun checkersShouldRun() {
|
||||
val (@A a, _) = <!COMPONENT_FUNCTION_MISSING, UNRESOLVED_REFERENCE!>unresolved<!>
|
||||
val (@A a, _) = <!COMPONENT_FUNCTION_MISSING, COMPONENT_FUNCTION_MISSING, UNRESOLVED_REFERENCE!>unresolved<!>
|
||||
}
|
||||
|
||||
annotation class A
|
||||
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
class A {
|
||||
operator fun component1() = 1
|
||||
operator fun component2() = ""
|
||||
}
|
||||
|
||||
fun test() {
|
||||
val (_, _) = A()
|
||||
val (_, _, _) = <!COMPONENT_FUNCTION_MISSING!>A()<!>
|
||||
|
||||
val (_: Int, _: String) = A()
|
||||
val (_: String, _) = <!COMPONENT_FUNCTION_RETURN_TYPE_MISMATCH!>A()<!>
|
||||
|
||||
val f: (A) -> Int = { (_, _) -> 1 }
|
||||
val g: (A) -> Int = { <!COMPONENT_FUNCTION_MISSING!>(_, _, _)<!> -> 2 }
|
||||
val h: (A) -> Int = { (<!COMPONENT_FUNCTION_RETURN_TYPE_MISMATCH!>_: String<!>, _) -> 3}
|
||||
}
|
||||
compiler/testData/diagnostics/tests/declarationChecks/destructuringDeclarations/missingComponentN.kt
Vendored
+16
@@ -0,0 +1,16 @@
|
||||
class A {
|
||||
operator fun component1() = 1
|
||||
operator fun component2() = ""
|
||||
}
|
||||
|
||||
fun test() {
|
||||
val (_, _) = A()
|
||||
val (_, _, _) = <!COMPONENT_FUNCTION_MISSING!>A()<!>
|
||||
|
||||
val (_: Int, _: String) = A()
|
||||
val (_: String, _) = <!COMPONENT_FUNCTION_RETURN_TYPE_MISMATCH!>A()<!>
|
||||
|
||||
val f: (A) -> Int = { (_, _) -> 1 }
|
||||
val g: (A) -> Int = { (_, _, <!COMPONENT_FUNCTION_MISSING!>_<!>) -> 2 }
|
||||
val h: (A) -> Int = { (<!COMPONENT_FUNCTION_RETURN_TYPE_MISMATCH!>_: String<!>, _) -> 3}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
package
|
||||
|
||||
public fun test(): kotlin.Unit
|
||||
|
||||
public final class A {
|
||||
public constructor A()
|
||||
public final operator fun component1(): kotlin.Int
|
||||
public final operator fun component2(): kotlin.String
|
||||
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
@@ -25,7 +25,7 @@ fun test() {
|
||||
foo(<!UNRESOLVED_REFERENCE!>_<!>, <!UNRESOLVED_REFERENCE!>_<!>)
|
||||
}
|
||||
|
||||
for ((_ : String, _ : Int) in C()) {
|
||||
for ((_ : String, _ : Int) in <!COMPONENT_FUNCTION_RETURN_TYPE_MISMATCH, COMPONENT_FUNCTION_RETURN_TYPE_MISMATCH!>C()<!>) {
|
||||
foo(<!UNRESOLVED_REFERENCE!>_<!>, <!UNRESOLVED_REFERENCE!>_<!>)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user