Implement resolution of desctructuring declarations in lambdas
#KT-5828 In Progress
This commit is contained in:
@@ -4,13 +4,13 @@ val receiverWithParameter = { Int.<!ILLEGAL_SELECTOR!>(<!UNRESOLVED_REFERENCE!>a
|
||||
val receiverAndReturnType = { Int.(<!SYNTAX!><!>)<!SYNTAX!>: Int -> 5<!> }
|
||||
val receiverAndReturnTypeWithParameter = { Int.(<!UNRESOLVED_REFERENCE!>a<!><!SYNTAX!><!SYNTAX!><!>: Int): Int -> 5<!> }
|
||||
|
||||
val returnType = { (<!SYNTAX!><!>)<!SYNTAX!>: Int -> 5<!> }
|
||||
val returnTypeWithParameter = { (<!UNRESOLVED_REFERENCE!>b<!><!SYNTAX!><!SYNTAX!><!>: Int): Int -> 5<!> }
|
||||
val returnType = { (<!SYNTAX!><!>): Int -> 5 }
|
||||
val returnTypeWithParameter = { (<!COMPONENT_FUNCTION_MISSING!>b: Int<!>): Int -> 5 }
|
||||
|
||||
val receiverWithFunctionType = { ((Int)<!SYNTAX!><!> <!SYNTAX!>-> Int).() -><!> }
|
||||
|
||||
val parenthesizedParameters = { (<!UNRESOLVED_REFERENCE!>a<!><!SYNTAX!><!SYNTAX!><!>: Int) -><!> }
|
||||
val parenthesizedParameters2 = { (<!UNRESOLVED_REFERENCE!>b<!>) <!SYNTAX!>-><!> }
|
||||
val parenthesizedParameters = { <!CANNOT_INFER_PARAMETER_TYPE!>(a: Int)<!> -> }
|
||||
val parenthesizedParameters2 = { <!CANNOT_INFER_PARAMETER_TYPE!>(b)<!> -> }
|
||||
|
||||
val none = { -> }
|
||||
|
||||
@@ -21,4 +21,4 @@ val newSyntax = { a: Int -> }
|
||||
val newSyntax1 = { <!CANNOT_INFER_PARAMETER_TYPE!>a<!>, <!CANNOT_INFER_PARAMETER_TYPE!>b<!> -> }
|
||||
val newSyntax2 = { a: Int, b: Int -> }
|
||||
val newSyntax3 = { <!CANNOT_INFER_PARAMETER_TYPE!>a<!>, b: Int -> }
|
||||
val newSyntax4 = { a: Int, <!CANNOT_INFER_PARAMETER_TYPE!>b<!> -> }
|
||||
val newSyntax4 = { a: Int, <!CANNOT_INFER_PARAMETER_TYPE!>b<!> -> }
|
||||
|
||||
@@ -7,12 +7,12 @@ public val newSyntax3: (???, kotlin.Int) -> kotlin.Unit
|
||||
public val newSyntax4: (kotlin.Int, ???) -> kotlin.Unit
|
||||
public val none: () -> kotlin.Unit
|
||||
public val parameterWithFunctionType: (((kotlin.Int) -> kotlin.Int) -> [ERROR : No type element]) -> kotlin.Unit
|
||||
public val parenthesizedParameters: () -> ???
|
||||
public val parenthesizedParameters2: () -> ???
|
||||
public val parenthesizedParameters: (???) -> kotlin.Unit
|
||||
public val parenthesizedParameters2: (???) -> kotlin.Unit
|
||||
public val receiver: () -> ???
|
||||
public val receiverAndReturnType: () -> ???
|
||||
public val receiverAndReturnTypeWithParameter: () -> ???
|
||||
public val receiverWithFunctionType: () -> kotlin.Int.Companion
|
||||
public val receiverWithParameter: () -> ???
|
||||
public val returnType: () -> ???
|
||||
public val returnTypeWithParameter: () -> ???
|
||||
public val returnType: (kotlin.Int) -> kotlin.Int
|
||||
public val returnTypeWithParameter: (kotlin.Int) -> kotlin.Int
|
||||
|
||||
Vendored
+47
@@ -0,0 +1,47 @@
|
||||
// !CHECK_TYPE
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
data class A(val x: Int, val y: String)
|
||||
data class B(val u: Double, val w: Short)
|
||||
|
||||
// first parameter of the functional type of 'x' can only be inferred from a lambda parameter explicit type specification
|
||||
fun <X, Y> foo(y: Y, x: (X, Y) -> Unit) {}
|
||||
|
||||
fun bar(aInstance: A, bInstance: B) {
|
||||
foo("") {
|
||||
(a, b): A, c ->
|
||||
a checkType { _<Int>() }
|
||||
b checkType { _<String>() }
|
||||
c checkType { _<String>() }
|
||||
}
|
||||
|
||||
foo(aInstance) {
|
||||
a: String, (b, c) ->
|
||||
a checkType { _<String>() }
|
||||
b checkType { _<Int>() }
|
||||
c checkType { _<String>() }
|
||||
}
|
||||
|
||||
foo(bInstance) {
|
||||
(a, b): A, (c, d) ->
|
||||
a checkType { _<Int>() }
|
||||
b checkType { _<String>() }
|
||||
c checkType { _<Double>() }
|
||||
d checkType { _<Short>() }
|
||||
}
|
||||
|
||||
<!TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>foo<!>(bInstance) {
|
||||
<!CANNOT_INFER_PARAMETER_TYPE!>(a, b)<!>, (c, d) ->
|
||||
<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>a<!> <!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>checkType<!> { <!UNRESOLVED_REFERENCE!>_<!><Int>() }
|
||||
<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>b<!> <!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>checkType<!> { <!UNRESOLVED_REFERENCE!>_<!><String>() }
|
||||
c checkType { _<Double>() }
|
||||
d checkType { _<Short>() }
|
||||
}
|
||||
|
||||
foo<A, B>(bInstance) {
|
||||
(a, b), (c, d) ->
|
||||
a checkType { _<Int>() }
|
||||
b checkType { _<String>() }
|
||||
c checkType { _<Double>() }
|
||||
d checkType { _<Short>() }
|
||||
}
|
||||
}
|
||||
Vendored
+28
@@ -0,0 +1,28 @@
|
||||
package
|
||||
|
||||
public fun bar(/*0*/ aInstance: A, /*1*/ bInstance: B): kotlin.Unit
|
||||
public fun </*0*/ X, /*1*/ Y> foo(/*0*/ y: Y, /*1*/ x: (X, Y) -> 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
|
||||
}
|
||||
Vendored
+51
@@ -0,0 +1,51 @@
|
||||
// !CHECK_TYPE
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
class A
|
||||
|
||||
operator fun A.component1() = 1
|
||||
operator fun A.component2() = ""
|
||||
|
||||
class B
|
||||
|
||||
class D {
|
||||
operator fun A.component1() = 1.0
|
||||
operator fun A.component2() = ' '
|
||||
|
||||
operator fun B.component1() = 1.0
|
||||
operator fun B.component2() = ' '
|
||||
}
|
||||
|
||||
fun foo(block: (A) -> Unit) { }
|
||||
fun foobaz(block: D.(B) -> Unit) { }
|
||||
fun foobar(block: D.(A) -> Unit) { }
|
||||
|
||||
fun bar() {
|
||||
foo { (a, b) ->
|
||||
a checkType { _<Int>() }
|
||||
b checkType { _<String>() }
|
||||
}
|
||||
|
||||
foo { (a: Int, b: String) ->
|
||||
a checkType { _<Int>() }
|
||||
b checkType { _<String>() }
|
||||
}
|
||||
|
||||
// From KEEP: Component-functions are resolved in the scope that contains the lambda
|
||||
foobaz { (<!COMPONENT_FUNCTION_MISSING!>a<!>, <!COMPONENT_FUNCTION_MISSING!>b<!>) ->
|
||||
}
|
||||
|
||||
// From KEEP: Component-functions are resolved in the scope that contains the lambda
|
||||
// So `component1`/`component2` for lambda parameters were resolved to the top-level extensions
|
||||
foobar { (a, b) ->
|
||||
a checkType { _<Int>() }
|
||||
b checkType { _<String>() }
|
||||
}
|
||||
|
||||
// the following code fails with exception, see KT-13873
|
||||
// foobarbaz {
|
||||
// component1: B.() -> Int,
|
||||
// component2: B.() -> String,
|
||||
// (a, b): B ->
|
||||
//
|
||||
// }
|
||||
}
|
||||
Vendored
+33
@@ -0,0 +1,33 @@
|
||||
package
|
||||
|
||||
public fun bar(): kotlin.Unit
|
||||
public fun foo(/*0*/ block: (A) -> kotlin.Unit): kotlin.Unit
|
||||
public fun foobar(/*0*/ block: D.(A) -> kotlin.Unit): kotlin.Unit
|
||||
public fun foobaz(/*0*/ block: D.(B) -> kotlin.Unit): kotlin.Unit
|
||||
public operator fun A.component1(): kotlin.Int
|
||||
public operator fun A.component2(): kotlin.String
|
||||
|
||||
public final class A {
|
||||
public constructor 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 final class B {
|
||||
public constructor B()
|
||||
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 D {
|
||||
public constructor D()
|
||||
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 operator fun A.component1(): kotlin.Double
|
||||
public final operator fun B.component1(): kotlin.Double
|
||||
public final operator fun A.component2(): kotlin.Char
|
||||
public final operator fun B.component2(): kotlin.Char
|
||||
}
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
// !CHECK_TYPE
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
data class A(val x: Int, val y: String)
|
||||
data class B(val u: Double, val w: Short)
|
||||
|
||||
fun <T> Iterable<T>.foo(x: (T) -> Unit) {}
|
||||
|
||||
fun bar(aList: List<A>) {
|
||||
aList.foo { (a, b) ->
|
||||
a checkType { _<Int>() }
|
||||
b checkType { _<String>() }
|
||||
}
|
||||
|
||||
aList.foo { (a: Int, b: String) ->
|
||||
a checkType { _<Int>() }
|
||||
b checkType { _<String>() }
|
||||
}
|
||||
|
||||
aList.foo { (a, b): A ->
|
||||
a checkType { _<Int>() }
|
||||
b checkType { _<String>() }
|
||||
}
|
||||
|
||||
aList.foo { (<!COMPONENT_FUNCTION_RETURN_TYPE_MISMATCH!>a: String<!>, b) ->
|
||||
a checkType { _<Int>() }
|
||||
b checkType { _<String>() }
|
||||
}
|
||||
|
||||
aList.<!TYPE_INFERENCE_CONFLICTING_SUBSTITUTIONS!>foo<!> { (a, b): B ->
|
||||
b checkType { <!TYPE_MISMATCH!>_<!><Int>() }
|
||||
a checkType { <!TYPE_MISMATCH!>_<!><String>() }
|
||||
}
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
package
|
||||
|
||||
public fun bar(/*0*/ aList: kotlin.collections.List<A>): kotlin.Unit
|
||||
public fun </*0*/ T> kotlin.collections.Iterable<T>.foo(/*0*/ x: (T) -> 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
|
||||
}
|
||||
Vendored
+31
@@ -0,0 +1,31 @@
|
||||
// !CHECK_TYPE
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE
|
||||
data class A(val x: Int, val y: String)
|
||||
|
||||
fun bar() {
|
||||
val x = { (a, b): A ->
|
||||
a checkType { _<Int>() }
|
||||
b checkType { _<String>() }
|
||||
}
|
||||
|
||||
x checkType { _<(A) -> Unit>() }
|
||||
|
||||
val y = { (a: Int, b): A ->
|
||||
a checkType { _<Int>() }
|
||||
b checkType { _<String>() }
|
||||
}
|
||||
|
||||
y checkType { _<(A) -> Unit>() }
|
||||
|
||||
val y2 = { (a: Number, b): A ->
|
||||
a checkType { _<Int>() }
|
||||
b checkType { _<String>() }
|
||||
}
|
||||
|
||||
y2 checkType { _<(A) -> Unit>() }
|
||||
|
||||
val z = { <!CANNOT_INFER_PARAMETER_TYPE!>(a: Int, b: String)<!> ->
|
||||
<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>a<!> <!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>checkType<!> { <!UNRESOLVED_REFERENCE!>_<!><Int>() }
|
||||
<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>b<!> <!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>checkType<!> { <!UNRESOLVED_REFERENCE!>_<!><String>() }
|
||||
}
|
||||
}
|
||||
Vendored
+15
@@ -0,0 +1,15 @@
|
||||
package
|
||||
|
||||
public fun bar(): 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
|
||||
}
|
||||
Vendored
+29
@@ -0,0 +1,29 @@
|
||||
// !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, B) -> Unit) { }
|
||||
|
||||
fun bar() {
|
||||
foo { (<!REDECLARATION!>a<!>, <!REDECLARATION!>a<!>), b ->
|
||||
a checkType { <!TYPE_MISMATCH!>_<!><Int>() }
|
||||
b checkType { <!TYPE_MISMATCH!>_<!><String>() }
|
||||
}
|
||||
|
||||
foo { (<!REDECLARATION!>a<!>, b), <!REDECLARATION!>a<!> ->
|
||||
a checkType { <!TYPE_MISMATCH!>_<!><Int>() }
|
||||
b checkType { _<String>() }
|
||||
}
|
||||
|
||||
foo { <!REDECLARATION!>a<!>, (<!REDECLARATION!>a<!>, b) ->
|
||||
a checkType { <!TYPE_MISMATCH!>_<!><Int>() }
|
||||
b checkType { <!TYPE_MISMATCH!>_<!><String>() }
|
||||
}
|
||||
|
||||
foo { (a, <!REDECLARATION!>b<!>), (c, <!REDECLARATION!>b<!>) ->
|
||||
a checkType { _<Int>() }
|
||||
b checkType { <!TYPE_MISMATCH!>_<!><String>() }
|
||||
c checkType { <!TYPE_MISMATCH!>_<!><B>() }
|
||||
}
|
||||
}
|
||||
Vendored
+28
@@ -0,0 +1,28 @@
|
||||
package
|
||||
|
||||
public fun bar(): kotlin.Unit
|
||||
public fun foo(/*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
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
// !CHECK_TYPE
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE
|
||||
data class A(val x: Int, val y: String)
|
||||
|
||||
fun foo(block: (A) -> Unit) { }
|
||||
|
||||
fun bar(a: Double) {
|
||||
val b = 1.toShort()
|
||||
// Do not report NAME_SHADOWING on lambda destructured parameter, the same way as for common parameters
|
||||
foo { (a, b) ->
|
||||
a checkType { _<Int>() }
|
||||
b checkType { _<String>() }
|
||||
}
|
||||
|
||||
foo { (c, d) ->
|
||||
c checkType { _<Int>() }
|
||||
d checkType { _<String>() }
|
||||
|
||||
foo { (a, c) ->
|
||||
a checkType { _<Int>() }
|
||||
c checkType { _<String>() }
|
||||
d checkType { _<String>() }
|
||||
}
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
package
|
||||
|
||||
public fun bar(/*0*/ a: kotlin.Double): kotlin.Unit
|
||||
public fun foo(/*0*/ block: (A) -> 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
|
||||
}
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
// !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, b) ->
|
||||
a checkType { _<Int>() }
|
||||
b checkType { _<String>() }
|
||||
}
|
||||
|
||||
foo { (a: Int, b: String) ->
|
||||
a checkType { _<Int>() }
|
||||
b checkType { _<String>() }
|
||||
}
|
||||
|
||||
foo { (a, b): A ->
|
||||
a checkType { _<Int>() }
|
||||
b checkType { _<String>() }
|
||||
}
|
||||
|
||||
foobar { (a, b), c ->
|
||||
a checkType { _<Int>() }
|
||||
b checkType { _<String>() }
|
||||
c checkType { _<B>() }
|
||||
}
|
||||
|
||||
foobar { a, (b, c) ->
|
||||
a checkType { _<A>() }
|
||||
b checkType { _<Double>() }
|
||||
c checkType { _<Short>() }
|
||||
}
|
||||
|
||||
foobar { (a, b), (c, d) ->
|
||||
a checkType { _<Int>() }
|
||||
b checkType { _<String>() }
|
||||
c checkType { _<Double>() }
|
||||
d checkType { _<Short>() }
|
||||
}
|
||||
|
||||
foo { (<!COMPONENT_FUNCTION_RETURN_TYPE_MISMATCH!>a: String<!>, b) ->
|
||||
a checkType { _<Int>() }
|
||||
b checkType { _<String>() }
|
||||
}
|
||||
|
||||
foo { <!EXPECTED_PARAMETER_TYPE_MISMATCH!>(a, b): B<!> ->
|
||||
a checkType { _<Double>() }
|
||||
b checkType { _<Short>() }
|
||||
}
|
||||
}
|
||||
+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