aboutsummaryrefslogtreecommitdiffstats
path: root/tests/features193/Switch3.java
blob: 90e5281259241d5d7901cf7a07d1d2e218edd29a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
public class Switch3 {
	public static void main(String[] argv) {
		System.out.println(one(Color.R));
		System.out.println(one(Color.G));
		System.out.println(one(Color.B));
		System.out.println(one(Color.Y));
	}

	public static int one(Color color) {
		int result = switch (color) {
			case R -> foo(0);
			case G -> {
				int number4 = foo(1) - 2;
				yield number4 +2;
			}
			case B -> foo(2);
			default -> foo(3);
		};
		return result;
	}

	public static final int foo(int i) {
		return i+1;
	}
}

enum Color {
	R, G, B, Y;
}

aspect X {
	int around(): call(* foo(..)) {
		return proceed()*3;
	}
}