ceylon/ceylon-ide-eclipse — pull request #315 by sjurba (2012-07-11 08:12:43+00:00)
Title: Improved #285 with inferred type for value modifier and running expressions only once

Improved issue #285 with type inference for value modifier and running expressions only once:

String? hi() {
Integer i = 1;
Boolean test = true;
String x = "x";
String y = "y";
String? obj = null;
String default = "";
Process process = Process();
//String first = "f";

if (i == 0) {
return test then x else y;
} else if (i == 1) {
return test then x;
} else if (i == 2) {
return obj else default;
} else if (i == 3) {
return process.first() else default;
}

Object o = test then x else y;
Object? o1 = test then default;
Object o2 = obj else default;
Object o3 = process.first() else default;

value o4= test then x else y;
value o5 = test then default;
value o6 = obj else default;
value o7 = process.first() else default;

variable Object v := test then x else y;
variable Object? v1 := test then default;
variable Object v2 := obj else default;
variable Object v3 := process.first() else default;

variable value v4 := test then x else y;
variable value v5 := test then default;
variable value v6 := obj else default;
variable value v7 := process.first() else default;

v := test then x else y;
v1 := test then default;
v2 := obj else default;
v3 := process.first() else default;
v4 := obj else default;

return null;
}

class Process() {
shared String? first() {
return "first";
}
}

Notice that if you un-comment the "first" attribute, the converted code from the process.first() expressions won't work since I re-use the name of the method name..
We should possibly improve this by triggering a rename in file action thing like they have in the Eclipse for Java.