Files
2024-02-12 19:12:36 +00:00

39 lines
1.0 KiB
Java

import java.util.*;
import org.jetbrains.annotations.Range;
public class ForEachPattern {
record IntBox(int i) {}
void bar1(Iterable<IntBox> i) {
int a = 1;
for (<error descr="Record patterns in for-each loops are not supported at language level '21'">IntBox(int d)</error> : i) {
a = 2;
}
System.out.println(a == 1);
}
record Point(int x, @Range(from = 1, to = 10) int y) {}
public static void main(String[] args) {
List<Point> points = new ArrayList<>();
use(points);
}
private static void use(List<Point> points) {
int a = 0, b = 0;
for (<error descr="Record patterns in for-each loops are not supported at language level '21'">Point(int x, int y)</error> : points) {
if (x == 1) {
a = 1;
}
if (x == 2) {
b = 1;
}
if (x == 2 && <warning descr="Condition 'b == 1' is always 'true' when reached">b == 1</warning>) {
b = y;
}
if (<warning descr="Condition 'y == 12' is always 'false'">y == 12</warning>) {}
}
if (a == 1 && b == 1) {
}
}
}