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
+12 -1
View File
@@ -8,13 +8,24 @@ class <!UNDERSCORE_IS_RESERVED!>_<!><<!UNDERSCORE_IS_RESERVED!>________<!>>
val <!UNDERSCORE_IS_RESERVED!>______<!> = _<Int>()
fun <!UNDERSCORE_IS_RESERVED!>__<!>(<!UNDERSCORE_IS_RESERVED!>___<!>: Int, y: _<Int>?): Int {
val (_, <!UNUSED_VARIABLE!>z<!>) = Pair(___ - 1, 42)
val (x, <!UNDERSCORE_IS_RESERVED!>__________<!>) = Pair(___ - 1, 42)
val <!UNDERSCORE_IS_RESERVED!>____<!> = x
// in backquotes: allowed
val `_` = __________
val q = fun(_: Int, <!UNDERSCORE_IS_RESERVED, UNUSED_PARAMETER!>__<!>: Int) {}
q(1, 2)
val <!UNDERSCORE_IS_RESERVED!>_<!> = 56
<!UNDERSCORE_IS_RESERVED!>__<!>@ return if (y != null) __(____, y) else __(`_`, ______)
}
// one underscore parameters for named function are still prohibited
fun oneUnderscore(<!UNUSED_PARAMETER, UNDERSCORE_IS_RESERVED!>_<!>: Int) {}
fun doIt(f: (Any?) -> Any?) = f(null)
val something = doIt { <!UNDERSCORE_IS_RESERVED!>__<!> -> __ }
val something = doIt { <!UNDERSCORE_IS_RESERVED!>__<!> -> __ }
val something2 = doIt { _ -> 1 }