GreatSyntacticShift: Syntax for function types, function literals, when and tuples

Bug:
fun loop(var times : Int) {
   while(times > 0) {
        val u : (value : Int) -> Unit = { // This arrow is confusing the lookahead
            System.out?.println(it)
        }
        u(times--)
   }
}
This commit is contained in:
Andrey Breslav
2011-12-20 22:55:25 +04:00
parent c9959a10f9
commit 41fd43b5e5
124 changed files with 1602 additions and 758 deletions
+27 -27
View File
@@ -4,19 +4,19 @@ fun foo() : Int {
val s = ""
val x = 1
when (x) {
is * => 1
is <!INCOMPATIBLE_TYPES!>String<!> => 1
!is Int => 1
is Any? => 1
<!INCOMPATIBLE_TYPES!>s<!> => 1
1 => 1
1 + <!UNRESOLVED_REFERENCE!>a<!> => 1
in 1..<!UNRESOLVED_REFERENCE!>a<!> => 1
!in 1..<!UNRESOLVED_REFERENCE!>a<!> => 1
is * -> 1
is <!INCOMPATIBLE_TYPES!>String<!> -> 1
!is Int -> 1
is Any? -> 1
<!INCOMPATIBLE_TYPES!>s<!> -> 1
1 -> 1
1 + <!UNRESOLVED_REFERENCE!>a<!> -> 1
in 1..<!UNRESOLVED_REFERENCE!>a<!> -> 1
!in 1..<!UNRESOLVED_REFERENCE!>a<!> -> 1
// Commented for KT-621 .<!!UNRESOLVED_REFERENCE!>a<!!> => 1
// Commented for KT-621 .equals(1).<!!UNRESOLVED_REFERENCE!>a<!!> => 1
// Commented for KT-621 <!UNNECESSARY_SAFE_CALL!!>?.<!!>equals(1) => 1
else => 1
else -> 1
}
// Commented for KT-621
@@ -35,33 +35,33 @@ fun test() {
val s = "";
when (x) {
<!INCOMPATIBLE_TYPES!>s<!> => 1
is <!INCOMPATIBLE_TYPES!>""<!> => 1
x => 1
is 1 => 1
is <!TYPE_MISMATCH_IN_TUPLE_PATTERN!>(1, 1)<!> => 1
<!INCOMPATIBLE_TYPES!>s<!> -> 1
is <!INCOMPATIBLE_TYPES!>""<!> -> 1
x -> 1
is 1 -> 1
is <!TYPE_MISMATCH_IN_TUPLE_PATTERN!>#(1, 1)<!> -> 1
}
val z = (1, 1)
val z = #(1, 1)
when (z) {
is (*, *) => 1
is (*, 1) => 1
is (1, 1) => 1
is (1, <!INCOMPATIBLE_TYPES!>"1"<!>) => 1
is <!TYPE_MISMATCH_IN_TUPLE_PATTERN!>(1, "1", *)<!> => 1
is boo @ (1, <!INCOMPATIBLE_TYPES!>"a"<!>, *) => 1
is boo @ <!TYPE_MISMATCH_IN_TUPLE_PATTERN!>(1, *)<!> => 1
is #(*, *) -> 1
is #(*, 1) -> 1
is #(1, 1) -> 1
is #(1, <!INCOMPATIBLE_TYPES!>"1"<!>) -> 1
is <!TYPE_MISMATCH_IN_TUPLE_PATTERN!>#(1, "1", *)<!> -> 1
is boo #(1, <!INCOMPATIBLE_TYPES!>"a"<!>, *) -> 1
is boo <!TYPE_MISMATCH_IN_TUPLE_PATTERN!>#(1, *)<!> -> 1
}
when (z) {
<!ELSE_MISPLACED_IN_WHEN!>else => 1<!>
(1, 1) => 2
<!ELSE_MISPLACED_IN_WHEN!>else -> 1<!>
#(1, 1) -> 2
}
when (z) {
else => 1
else -> 1
}
}
val (Int, Int).boo : (Int, Int, Int) = (1, 1, 1)
val #(Int, Int).boo : #(Int, Int, Int) = #(1, 1, 1)