mirror of
https://github.com/tiennm99/lombok.git
synced 2026-08-01 06:21:53 +00:00
* var is promoted to the main package. * It is no longer an opt-in thing. * bug: var (unlike val) is allowed in old-style for loops, but if you multi-init: for (var i = 0, j="Foo";;), you now get an error that you can't do that. * tests both for the multi-for situation and the new main package variant.
26 lines
657 B
Java
26 lines
657 B
Java
import lombok.var;
|
|
public class VarComplex {
|
|
private String field = "";
|
|
private static final int CONSTANT = 20;
|
|
<clinit>() {
|
|
}
|
|
public VarComplex() {
|
|
super();
|
|
}
|
|
public void testComplex() {
|
|
@var char[] shouldBeCharArray = field.toCharArray();
|
|
@var int shouldBeInt = CONSTANT;
|
|
@var java.lang.Object lock = new Object();
|
|
synchronized (lock)
|
|
{
|
|
@var int field = 20;
|
|
@var int inner = 10;
|
|
switch (field) {
|
|
case 5 :
|
|
@var char[] shouldBeCharArray2 = shouldBeCharArray;
|
|
@var int innerInner = inner;
|
|
}
|
|
}
|
|
@var java.lang.String shouldBeString = field;
|
|
}
|
|
} |