[java] Verify that "when" can still be used as type name (#4038, #4039)

This commit is contained in:
Andreas Dangel
2022-07-14 11:38:45 +02:00
parent aae6d02c10
commit 0f2cb5a116
2 changed files with 6 additions and 0 deletions

View File

@@ -30,6 +30,9 @@ public class GuardedAndParenthesizedPatterns {
System.out.println(when);
}
// verify that "when" can still be used as a type name
private static class when {}
static void testWithNull(Object o) {
switch (o) {
case String s when (s.length() == 1) -> System.out.println("single char string");

View File

@@ -210,6 +210,9 @@
| +- PrimaryExpression[]
| +- PrimaryPrefix[@SuperModifier = false, @ThisModifier = false]
| +- Name[@Image = "when"]
+- ClassOrInterfaceBodyDeclaration[@AnonymousInnerClass = false, @EnumChild = false, @Kind = DeclarationKind.CLASS]
| +- ClassOrInterfaceDeclaration[@Abstract = false, @BinaryName = "GuardedAndParenthesizedPatterns$when", @Default = false, @Final = false, @Image = "when", @Interface = false, @Local = false, @Modifiers = 20, @Native = false, @Nested = true, @NonSealed = false, @PackagePrivate = false, @Private = true, @Protected = false, @Public = false, @Sealed = false, @SimpleName = "when", @Static = true, @Strictfp = false, @Synchronized = false, @Transient = false, @TypeKind = TypeKind.CLASS, @Volatile = false]
| +- ClassOrInterfaceBody[@AnonymousInnerClass = false, @EnumChild = false]
+- ClassOrInterfaceBodyDeclaration[@AnonymousInnerClass = false, @EnumChild = false, @Kind = DeclarationKind.METHOD]
| +- MethodDeclaration[@Abstract = false, @Arity = 1, @Default = false, @Final = false, @InterfaceMember = false, @Kind = MethodLikeKind.METHOD, @MethodName = "testWithNull", @Modifiers = 16, @Name = "testWithNull", @Native = false, @PackagePrivate = true, @Private = false, @Protected = false, @Public = false, @Static = true, @Strictfp = false, @Synchronized = false, @SyntacticallyAbstract = false, @SyntacticallyPublic = false, @Transient = false, @Void = true, @Volatile = false]
| +- ResultType[@Void = true, @returnsArray = false]