JavaCompilerCore/resources/bytecode/javFiles/GenericRecordSwitchCase.jav
Ruben 3ac3af2327
All checks were successful
Build and Test with Maven / Build-and-test-with-Maven (push) Successful in 6m55s
test: add Test for Switch-Case with generic Records.
2024-09-02 19:15:53 +02:00

28 lines
564 B
Java

import java.lang.Object;
import java.lang.String;
sealed interface List permits LinkedElem {}
public record LinkedElem<T>(T a,List l) implements List{} //Implementiert List und wird auch permittet
public record Elem<T>(T c) implements List{} //Implementiert List, wird aber nicht permittet
public class SwitchCaseHeritageDetection {
public main(o) {
return switch(o) {
case LinkedElem(a, Elem(e)) -> a ;
case LinkedElem(a, LinkedElem(e, Elem(f))) -> e;
default -> null;
};
}
}