mirror of
https://github.com/tiennm99/lombok.git
synced 2026-05-27 18:23:24 +00:00
66469e04fe
* 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.
22 lines
490 B
Java
22 lines
490 B
Java
import lombok.var;
|
|
|
|
public class VarComplex {
|
|
private String field = "";
|
|
private static final int CONSTANT = 20;
|
|
|
|
public void testComplex() {
|
|
var shouldBeCharArray = field.toCharArray();
|
|
var shouldBeInt = CONSTANT;
|
|
var lock = new Object();
|
|
synchronized (lock) {
|
|
var field = 20; //Shadowing
|
|
var inner = 10;
|
|
switch (field) {
|
|
case 5:
|
|
var shouldBeCharArray2 = shouldBeCharArray;
|
|
var innerInner = inner;
|
|
}
|
|
}
|
|
var shouldBeString = field; //Unshadowing
|
|
}
|
|
} |