[FIR-TEST] Add new testdata generated after changes in previous commit
This commit is contained in:
Vendored
+48
@@ -0,0 +1,48 @@
|
||||
// !WITH_NEW_INFERENCE
|
||||
// !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("") {
|
||||
(<!UNRESOLVED_REFERENCE!>a<!>, <!UNRESOLVED_REFERENCE!>b<!>): A, c ->
|
||||
a <!INAPPLICABLE_CANDIDATE!>checkType<!> { <!UNRESOLVED_REFERENCE!>_<!><Int>() }
|
||||
b <!INAPPLICABLE_CANDIDATE!>checkType<!> { <!UNRESOLVED_REFERENCE!>_<!><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) ->
|
||||
<!UNRESOLVED_REFERENCE!>a<!> <!INAPPLICABLE_CANDIDATE!>checkType<!> { <!UNRESOLVED_REFERENCE!>_<!><Int>() }
|
||||
<!UNRESOLVED_REFERENCE!>b<!> <!INAPPLICABLE_CANDIDATE!>checkType<!> { <!UNRESOLVED_REFERENCE!>_<!><String>() }
|
||||
c checkType { _<Double>() }
|
||||
d checkType { _<Short>() }
|
||||
}
|
||||
|
||||
foo(bInstance) {
|
||||
(a, b), (c, d) ->
|
||||
<!UNRESOLVED_REFERENCE!>a<!> <!INAPPLICABLE_CANDIDATE!>checkType<!> { <!UNRESOLVED_REFERENCE!>_<!><Int>() }
|
||||
<!UNRESOLVED_REFERENCE!>b<!> <!INAPPLICABLE_CANDIDATE!>checkType<!> { <!UNRESOLVED_REFERENCE!>_<!><String>() }
|
||||
c checkType { _<Double>() }
|
||||
d checkType { _<Short>() }
|
||||
}
|
||||
|
||||
foo<A, B>(bInstance) {
|
||||
(a, b), (c, d) ->
|
||||
<!UNRESOLVED_REFERENCE!>a<!> <!INAPPLICABLE_CANDIDATE!>checkType<!> { <!UNRESOLVED_REFERENCE!>_<!><Int>() }
|
||||
<!UNRESOLVED_REFERENCE!>b<!> <!INAPPLICABLE_CANDIDATE!>checkType<!> { <!UNRESOLVED_REFERENCE!>_<!><String>() }
|
||||
c checkType { _<Double>() }
|
||||
d checkType { _<Short>() }
|
||||
}
|
||||
}
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
// !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 same scope as the first statement of the lambda
|
||||
foobaz { (a, b) ->
|
||||
a checkType { _<Double>() }
|
||||
b checkType { _<Char>() }
|
||||
}
|
||||
|
||||
// From KEEP: Component-functions are resolved in the same scope as the first statement of the lambda
|
||||
// So `component1`/`component2` for lambda parameters were resolved to member extensions
|
||||
foobar { (a, b) ->
|
||||
a checkType { _<Double>() }
|
||||
b checkType { _<Char>() }
|
||||
}
|
||||
|
||||
// the following code fails with exception, see KT-13873
|
||||
// foobarbaz {
|
||||
// component1: B.() -> Int,
|
||||
// component2: B.() -> String,
|
||||
// (a, b): B ->
|
||||
//
|
||||
// }
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
// !WITH_NEW_INFERENCE
|
||||
// !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 { (a: String, b) ->
|
||||
a checkType { <!INAPPLICABLE_CANDIDATE!>_<!><Int>() }
|
||||
b checkType { _<String>() }
|
||||
}
|
||||
|
||||
aList.foo { (a, b): B ->
|
||||
b checkType { <!INAPPLICABLE_CANDIDATE!>_<!><Int>() }
|
||||
a checkType { <!INAPPLICABLE_CANDIDATE!>_<!><String>() }
|
||||
}
|
||||
}
|
||||
Vendored
+15
@@ -0,0 +1,15 @@
|
||||
// !CHECK_TYPE
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
data class A(val x: Int, val y: String)
|
||||
|
||||
fun foo(block: (A) -> Unit) { }
|
||||
|
||||
@Target(AnnotationTarget.VALUE_PARAMETER)
|
||||
annotation class Ann
|
||||
|
||||
fun bar() {
|
||||
foo { (private inline a, @Ann b) ->
|
||||
a checkType { _<Int>() }
|
||||
b checkType { _<String>() }
|
||||
}
|
||||
}
|
||||
Vendored
+32
@@ -0,0 +1,32 @@
|
||||
// !WITH_NEW_INFERENCE
|
||||
// !CHECK_TYPE
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE
|
||||
data class A(val x: Int, val y: String)
|
||||
|
||||
fun bar() {
|
||||
val x = { (<!UNRESOLVED_REFERENCE!>a<!>, <!UNRESOLVED_REFERENCE!>b<!>): A ->
|
||||
a <!INAPPLICABLE_CANDIDATE!>checkType<!> { <!UNRESOLVED_REFERENCE!>_<!><Int>() }
|
||||
b <!INAPPLICABLE_CANDIDATE!>checkType<!> { <!UNRESOLVED_REFERENCE!>_<!><String>() }
|
||||
}
|
||||
|
||||
x checkType { <!UNRESOLVED_REFERENCE!>_<!><(A) -> Unit>() }
|
||||
|
||||
val y = { (<!UNRESOLVED_REFERENCE!>a: Int<!>, <!UNRESOLVED_REFERENCE!>b<!>): A ->
|
||||
a checkType { <!UNRESOLVED_REFERENCE!>_<!><Int>() }
|
||||
b <!INAPPLICABLE_CANDIDATE!>checkType<!> { <!UNRESOLVED_REFERENCE!>_<!><String>() }
|
||||
}
|
||||
|
||||
y checkType { <!UNRESOLVED_REFERENCE!>_<!><(A) -> Unit>() }
|
||||
|
||||
val y2 = { (<!UNRESOLVED_REFERENCE!>a: Number<!>, <!UNRESOLVED_REFERENCE!>b<!>): A ->
|
||||
a checkType { <!UNRESOLVED_REFERENCE!>_<!><Int>() }
|
||||
b <!INAPPLICABLE_CANDIDATE!>checkType<!> { <!UNRESOLVED_REFERENCE!>_<!><String>() }
|
||||
}
|
||||
|
||||
y2 checkType { <!UNRESOLVED_REFERENCE!>_<!><(A) -> Unit>() }
|
||||
|
||||
val z = { (<!UNRESOLVED_REFERENCE!>a: Int<!>, <!UNRESOLVED_REFERENCE!>b: String<!>) ->
|
||||
a checkType { <!UNRESOLVED_REFERENCE!>_<!><Int>() }
|
||||
b checkType { <!UNRESOLVED_REFERENCE!>_<!><String>() }
|
||||
}
|
||||
}
|
||||
Vendored
+30
@@ -0,0 +1,30 @@
|
||||
// !WITH_NEW_INFERENCE
|
||||
// !CHECK_TYPE
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_ANONYMOUS_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 { (a, a), b ->
|
||||
a checkType { <!INAPPLICABLE_CANDIDATE!>_<!><Int>() }
|
||||
b checkType { <!INAPPLICABLE_CANDIDATE!>_<!><String>() }
|
||||
}
|
||||
|
||||
foo { (a, b), a ->
|
||||
a checkType { _<Int>() }
|
||||
b checkType { _<String>() }
|
||||
}
|
||||
|
||||
foo { a, (a, b) ->
|
||||
a checkType { <!INAPPLICABLE_CANDIDATE!>_<!><Int>() }
|
||||
b checkType { <!INAPPLICABLE_CANDIDATE!>_<!><String>() }
|
||||
}
|
||||
|
||||
foo { (a, b), (c, b) ->
|
||||
<!UNRESOLVED_REFERENCE!>a<!> <!INAPPLICABLE_CANDIDATE!>checkType<!> { <!UNRESOLVED_REFERENCE!>_<!><Int>() }
|
||||
b checkType { <!INAPPLICABLE_CANDIDATE!>_<!><String>() }
|
||||
c checkType { <!INAPPLICABLE_CANDIDATE!>_<!><B>() }
|
||||
}
|
||||
}
|
||||
Vendored
+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>() }
|
||||
}
|
||||
}
|
||||
}
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
// !WITH_NEW_INFERENCE
|
||||
// !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) ->
|
||||
<!UNRESOLVED_REFERENCE!>a<!> <!INAPPLICABLE_CANDIDATE!>checkType<!> { <!UNRESOLVED_REFERENCE!>_<!><Int>() }
|
||||
<!UNRESOLVED_REFERENCE!>b<!> <!INAPPLICABLE_CANDIDATE!>checkType<!> { <!UNRESOLVED_REFERENCE!>_<!><String>() }
|
||||
c checkType { _<Double>() }
|
||||
d checkType { _<Short>() }
|
||||
}
|
||||
|
||||
foo { (a: String, b) ->
|
||||
a checkType { <!INAPPLICABLE_CANDIDATE!>_<!><Int>() }
|
||||
b checkType { _<String>() }
|
||||
}
|
||||
|
||||
foo { (a, b): B ->
|
||||
a checkType { <!INAPPLICABLE_CANDIDATE!>_<!><Double>() }
|
||||
b checkType { <!INAPPLICABLE_CANDIDATE!>_<!><Short>() }
|
||||
}
|
||||
}
|
||||
Vendored
+63
@@ -0,0 +1,63 @@
|
||||
// !WITH_NEW_INFERENCE
|
||||
// !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 bar() {
|
||||
foo { (_, b) ->
|
||||
_.hashCode()
|
||||
b checkType { _<String>() }
|
||||
}
|
||||
|
||||
foo { (a, _) ->
|
||||
a checkType { _<Int>() }
|
||||
_.hashCode()
|
||||
}
|
||||
|
||||
foo { (_, _) ->
|
||||
_.hashCode()
|
||||
}
|
||||
|
||||
foo { (_: Int, b: String) ->
|
||||
_.hashCode()
|
||||
b checkType { _<String>() }
|
||||
}
|
||||
|
||||
foo { (a: Int, _: String) ->
|
||||
a checkType { _<Int>() }
|
||||
_.hashCode()
|
||||
}
|
||||
|
||||
foo { (_: Int, _: String) ->
|
||||
_.hashCode()
|
||||
}
|
||||
|
||||
foo { (_, _): A ->
|
||||
_.hashCode()
|
||||
}
|
||||
|
||||
foo { (`_`, _) ->
|
||||
_ checkType { <!INAPPLICABLE_CANDIDATE!>_<!><Int>() }
|
||||
}
|
||||
|
||||
foo { (_, `_`) ->
|
||||
_ checkType { _<String>() }
|
||||
}
|
||||
|
||||
foo { (`_`, `_`) ->
|
||||
_ checkType { _<String>() }
|
||||
}
|
||||
|
||||
foo { (_: String, b) ->
|
||||
_.hashCode()
|
||||
b checkType { _<String>() }
|
||||
}
|
||||
|
||||
foo { (_, b): B ->
|
||||
_.hashCode()
|
||||
b checkType { <!INAPPLICABLE_CANDIDATE!>_<!><Short>() }
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// !LANGUAGE: -DestructuringLambdaParameters
|
||||
// !CHECK_TYPE
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
data class A(val x: Int, val y: String)
|
||||
|
||||
fun foo(block: (A) -> Unit) { }
|
||||
|
||||
fun bar() {
|
||||
foo { (a, b) ->
|
||||
a checkType { _<Int>() }
|
||||
b checkType { _<String>() }
|
||||
}
|
||||
}
|
||||
Vendored
+43
@@ -0,0 +1,43 @@
|
||||
// !CHECK_TYPE
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_ANONYMOUS_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>() }
|
||||
}
|
||||
|
||||
foo { (a, b) ->
|
||||
b checkType { _<String>() }
|
||||
}
|
||||
|
||||
foo { (a: Int, b: String) ->
|
||||
a checkType { _<Int>() }
|
||||
}
|
||||
|
||||
foo { (a: Int, b: String) ->
|
||||
b checkType { _<String>() }
|
||||
}
|
||||
|
||||
foobar { (a, b), c ->
|
||||
a checkType { _<Int>() }
|
||||
}
|
||||
|
||||
foobar { a, (b, c) ->
|
||||
c checkType { _<Short>() }
|
||||
}
|
||||
|
||||
foobar { (a, b), (c, d) ->
|
||||
<!UNRESOLVED_REFERENCE!>a<!> <!INAPPLICABLE_CANDIDATE!>checkType<!> { <!UNRESOLVED_REFERENCE!>_<!><Int>() }
|
||||
d checkType { _<Short>() }
|
||||
}
|
||||
|
||||
foobar { (a, b), (c, d) ->
|
||||
<!UNRESOLVED_REFERENCE!>b<!> <!INAPPLICABLE_CANDIDATE!>checkType<!> { <!UNRESOLVED_REFERENCE!>_<!><String>() }
|
||||
c checkType { _<Double>() }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user