Report UNUSED_DESTRUCTURED_PARAMETER_ENTRY
on destructured lambda parameters #KT-14347 Fixed
This commit is contained in:
Vendored
+1
-1
@@ -31,7 +31,7 @@ fun bar() {
|
||||
}
|
||||
|
||||
// From KEEP: Component-functions are resolved in the scope that contains the lambda
|
||||
foobaz { (<!COMPONENT_FUNCTION_MISSING!>a<!>, <!COMPONENT_FUNCTION_MISSING!>b<!>) ->
|
||||
foobaz { (<!COMPONENT_FUNCTION_MISSING, UNUSED_DESTRUCTURED_PARAMETER_ENTRY!>a<!>, <!COMPONENT_FUNCTION_MISSING, UNUSED_DESTRUCTURED_PARAMETER_ENTRY!>b<!>) ->
|
||||
}
|
||||
|
||||
// From KEEP: Component-functions are resolved in the scope that contains the lambda
|
||||
|
||||
Vendored
+3
-3
@@ -6,12 +6,12 @@ data class B(val u: Double, val w: Short)
|
||||
fun foo(block: (A, B) -> Unit) { }
|
||||
|
||||
fun bar() {
|
||||
foo { (<!REDECLARATION!>a<!>, <!REDECLARATION!>a<!>), b ->
|
||||
foo { (<!REDECLARATION, UNUSED_DESTRUCTURED_PARAMETER_ENTRY!>a<!>, <!REDECLARATION!>a<!>), b ->
|
||||
a checkType { <!TYPE_MISMATCH!>_<!><Int>() }
|
||||
b checkType { <!TYPE_MISMATCH!>_<!><String>() }
|
||||
}
|
||||
|
||||
foo { (<!REDECLARATION!>a<!>, b), <!REDECLARATION!>a<!> ->
|
||||
foo { (<!REDECLARATION, UNUSED_DESTRUCTURED_PARAMETER_ENTRY!>a<!>, b), <!REDECLARATION!>a<!> ->
|
||||
a checkType { <!TYPE_MISMATCH!>_<!><Int>() }
|
||||
b checkType { _<String>() }
|
||||
}
|
||||
@@ -21,7 +21,7 @@ fun bar() {
|
||||
b checkType { <!TYPE_MISMATCH!>_<!><String>() }
|
||||
}
|
||||
|
||||
foo { (a, <!REDECLARATION!>b<!>), (c, <!REDECLARATION!>b<!>) ->
|
||||
foo { (a, <!REDECLARATION, UNUSED_DESTRUCTURED_PARAMETER_ENTRY!>b<!>), (c, <!REDECLARATION!>b<!>) ->
|
||||
a checkType { _<Int>() }
|
||||
b checkType { <!TYPE_MISMATCH!>_<!><String>() }
|
||||
c checkType { <!TYPE_MISMATCH!>_<!><B>() }
|
||||
|
||||
+1
-1
@@ -46,7 +46,7 @@ fun bar() {
|
||||
_ checkType { _<String>() }
|
||||
}
|
||||
|
||||
foo { (<!REDECLARATION!>`_`<!>, <!REDECLARATION!>`_`<!>) ->
|
||||
foo { (<!REDECLARATION, UNUSED_DESTRUCTURED_PARAMETER_ENTRY!>`_`<!>, <!REDECLARATION!>`_`<!>) ->
|
||||
_ checkType { _<String>() }
|
||||
}
|
||||
|
||||
|
||||
Vendored
+43
@@ -0,0 +1,43 @@
|
||||
// !CHECK_TYPE
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
data class A(val x: Int, val y: String)
|
||||
data class B(val u: Double, val w: Short)
|
||||
|
||||
fun foo(block: (A) -> Unit) { }
|
||||
fun foobar(block: (A, B) -> Unit) { }
|
||||
|
||||
fun bar() {
|
||||
foo { (a, <!UNUSED_DESTRUCTURED_PARAMETER_ENTRY!>b<!>) ->
|
||||
a checkType { _<Int>() }
|
||||
}
|
||||
|
||||
foo { (<!UNUSED_DESTRUCTURED_PARAMETER_ENTRY!>a<!>, b) ->
|
||||
b checkType { _<String>() }
|
||||
}
|
||||
|
||||
foo { (a: Int, <!UNUSED_DESTRUCTURED_PARAMETER_ENTRY!>b<!>: String) ->
|
||||
a checkType { _<Int>() }
|
||||
}
|
||||
|
||||
foo { (<!UNUSED_DESTRUCTURED_PARAMETER_ENTRY!>a<!>: Int, b: String) ->
|
||||
b checkType { _<String>() }
|
||||
}
|
||||
|
||||
foobar { (a, <!UNUSED_DESTRUCTURED_PARAMETER_ENTRY!>b<!>), c ->
|
||||
a checkType { _<Int>() }
|
||||
}
|
||||
|
||||
foobar { a, (<!UNUSED_DESTRUCTURED_PARAMETER_ENTRY!>b<!>, c) ->
|
||||
c checkType { _<Short>() }
|
||||
}
|
||||
|
||||
foobar { (a, <!UNUSED_DESTRUCTURED_PARAMETER_ENTRY!>b<!>), (<!UNUSED_DESTRUCTURED_PARAMETER_ENTRY!>c<!>, d) ->
|
||||
a checkType { _<Int>() }
|
||||
d checkType { _<Short>() }
|
||||
}
|
||||
|
||||
foobar { (<!UNUSED_DESTRUCTURED_PARAMETER_ENTRY!>a<!>, b), (c, <!UNUSED_DESTRUCTURED_PARAMETER_ENTRY!>d<!>) ->
|
||||
b checkType { _<String>() }
|
||||
c checkType { _<Double>() }
|
||||
}
|
||||
}
|
||||
Vendored
+29
@@ -0,0 +1,29 @@
|
||||
package
|
||||
|
||||
public fun bar(): kotlin.Unit
|
||||
public fun foo(/*0*/ block: (A) -> kotlin.Unit): kotlin.Unit
|
||||
public fun foobar(/*0*/ block: (A, B) -> kotlin.Unit): kotlin.Unit
|
||||
|
||||
public final data class A {
|
||||
public constructor A(/*0*/ x: kotlin.Int, /*1*/ y: kotlin.String)
|
||||
public final val x: kotlin.Int
|
||||
public final val y: kotlin.String
|
||||
public final operator /*synthesized*/ fun component1(): kotlin.Int
|
||||
public final operator /*synthesized*/ fun component2(): kotlin.String
|
||||
public final /*synthesized*/ fun copy(/*0*/ x: kotlin.Int = ..., /*1*/ y: kotlin.String = ...): A
|
||||
public open override /*1*/ /*synthesized*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*synthesized*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*synthesized*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public final data class B {
|
||||
public constructor B(/*0*/ u: kotlin.Double, /*1*/ w: kotlin.Short)
|
||||
public final val u: kotlin.Double
|
||||
public final val w: kotlin.Short
|
||||
public final operator /*synthesized*/ fun component1(): kotlin.Double
|
||||
public final operator /*synthesized*/ fun component2(): kotlin.Short
|
||||
public final /*synthesized*/ fun copy(/*0*/ u: kotlin.Double = ..., /*1*/ w: kotlin.Short = ...): B
|
||||
public open override /*1*/ /*synthesized*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*synthesized*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*synthesized*/ fun toString(): kotlin.String
|
||||
}
|
||||
Reference in New Issue
Block a user