Code transformation: if statement with assignments <-> assignment with if expression
This commit is contained in:
+11
@@ -0,0 +1,11 @@
|
||||
public class MyClass {
|
||||
public method(a: Int): String {
|
||||
var res: String
|
||||
|
||||
if (a == 1) res = "one";
|
||||
else if (a == 2) res = "two";
|
||||
else res = "too many";
|
||||
|
||||
return res;
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
public class MyClass {
|
||||
public method(a: Int): String {
|
||||
var res: String
|
||||
|
||||
res = if (a == 1) "one";
|
||||
else if (a == 2) "two";
|
||||
else "too many";
|
||||
|
||||
return res;
|
||||
}
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
<html>
|
||||
<body>
|
||||
This intention converts assignment with 'if' expression as right-hand side
|
||||
into 'if' statement where each branch is terminated with assignment to the original variable
|
||||
</body>
|
||||
</html>
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
public class MyClass {
|
||||
public method(a: Int): String {
|
||||
var res: String
|
||||
|
||||
res = if (a == 1) "one";
|
||||
else if (a == 2) "two";
|
||||
else "too many";
|
||||
|
||||
return res;
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
public class MyClass {
|
||||
public method(a: Int): String {
|
||||
var res: String
|
||||
|
||||
if (a == 1) res = "one";
|
||||
else if (a == 2) res = "two";
|
||||
else res = "too many";
|
||||
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
<html>
|
||||
<body>
|
||||
This intention converts 'if' statement where each branch is terminated with assignment to the same variable
|
||||
into single assignment with 'if' expression
|
||||
</body>
|
||||
</html>
|
||||
-8
@@ -1,8 +0,0 @@
|
||||
import jet.runtime.typeinfo.KotlinSignature;
|
||||
|
||||
public class MyClass {
|
||||
<spot>@KotlinSignature("fun method() : jet.String?")</spot>
|
||||
public String method() {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
-5
@@ -1,5 +0,0 @@
|
||||
public class MyClass {
|
||||
public String method() {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user