From 75c7e49ac20cf8127528574deeed1f3875a35f66 Mon Sep 17 00:00:00 2001 From: Lucas Werkmeister Date: Wed, 19 Nov 2014 19:55:20 +0100 Subject: [PATCH 1/2] Update for ceylon/ceylon-spec#1119 We can now declare inline variables in switch. --- source/ceylon/formatter/FormattingVisitor.ceylon | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/ceylon/formatter/FormattingVisitor.ceylon b/source/ceylon/formatter/FormattingVisitor.ceylon index ebdc713..b0f4f64 100644 --- a/source/ceylon/formatter/FormattingVisitor.ceylon +++ b/source/ceylon/formatter/FormattingVisitor.ceylon @@ -1736,7 +1736,7 @@ shared class FormattingVisitor( indentAfter = 1; lineBreaksAfter = noLineBreak; }; - that.expression.visit(this); + that.switched.visit(this); fWriter.writeToken { ")"; // not in the AST as well context; From 87a3619edc61dcdf182c03a906961e805ad4587e Mon Sep 17 00:00:00 2001 From: Lucas Werkmeister Date: Wed, 19 Nov 2014 19:56:07 +0100 Subject: [PATCH 2/2] Expand switch test to cover ceylon/ceylon-spec#1119 --- test-samples/switch.ceylon | 6 ++++++ test-samples/switch.ceylon.formatted | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/test-samples/switch.ceylon b/test-samples/switch.ceylon index fb25a96..f78eb5b 100644 --- a/test-samples/switch.ceylon +++ b/test-samples/switch.ceylon @@ -30,3 +30,9 @@ void testSwitchWithMultipleCases() { // do other stuff } } + +void testSwitchWithNewVariable() { + switch (arg = process.arguments.first) + case (is String) { print("Hello, ``arg``!"); } + case (null) { print("USAGE: ceylon run `` `module`.name ``/`` `module`.version `` [NAME]"); } +} diff --git a/test-samples/switch.ceylon.formatted b/test-samples/switch.ceylon.formatted index fb25a96..f78eb5b 100644 --- a/test-samples/switch.ceylon.formatted +++ b/test-samples/switch.ceylon.formatted @@ -30,3 +30,9 @@ void testSwitchWithMultipleCases() { // do other stuff } } + +void testSwitchWithNewVariable() { + switch (arg = process.arguments.first) + case (is String) { print("Hello, ``arg``!"); } + case (null) { print("USAGE: ceylon run `` `module`.name ``/`` `module`.version `` [NAME]"); } +}