Support single-underscore variable names partially
Currently only parameters of lambdas/function expressions and destructuring entries are allowed #KT-3824 In Progress #KT-2783 In Progress
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
// !CHECK_TYPE
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
fun foo(block: (Int, String) -> Unit) { }
|
||||
fun foobar(block: (Double) -> Unit) { }
|
||||
|
||||
fun bar() {
|
||||
foo { _, b ->
|
||||
<!UNRESOLVED_REFERENCE!>_<!>.<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>hashCode<!>()
|
||||
b checkType { _<String>() }
|
||||
}
|
||||
|
||||
foo { a, _ ->
|
||||
a checkType { _<Int>() }
|
||||
<!UNRESOLVED_REFERENCE!>_<!>.<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>hashCode<!>()
|
||||
}
|
||||
|
||||
foo { _, _ ->
|
||||
<!UNRESOLVED_REFERENCE!>_<!>.<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>hashCode<!>()
|
||||
}
|
||||
|
||||
foo { _: Int, b: String ->
|
||||
<!UNRESOLVED_REFERENCE!>_<!>.<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>hashCode<!>()
|
||||
b checkType { _<String>() }
|
||||
}
|
||||
|
||||
foo { a: Int, _: String ->
|
||||
a checkType { _<Int>() }
|
||||
<!UNRESOLVED_REFERENCE!>_<!>.<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>hashCode<!>()
|
||||
}
|
||||
|
||||
foo { _: Int, _: String ->
|
||||
<!UNRESOLVED_REFERENCE!>_<!>.<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>hashCode<!>()
|
||||
}
|
||||
|
||||
foo { `_`, _ ->
|
||||
_ checkType { _<Int>() }
|
||||
}
|
||||
|
||||
foo { _, `_` ->
|
||||
_ checkType { _<String>() }
|
||||
}
|
||||
|
||||
foo { <!REDECLARATION, REDECLARATION!>`_`<!>, <!REDECLARATION, REDECLARATION!>`_`<!> ->
|
||||
_ checkType { _<String>() }
|
||||
}
|
||||
|
||||
foo(fun(x: Int, _: String) {})
|
||||
}
|
||||
Reference in New Issue
Block a user