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:
Denis Zharkov
2016-10-13 11:55:37 +03:00
parent 82364ad3e5
commit dbca310d8c
19 changed files with 319 additions and 21 deletions
@@ -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) {})
}