Skip to content

Commit babe074

Browse files
committed
Test new switch syntax with super in constructor
1 parent 3c3d393 commit babe074

3 files changed

Lines changed: 47 additions & 0 deletions

File tree

pmd-java/src/test/java/net/sourceforge/pmd/lang/java/ast/ParserCornersTest.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,11 @@ void testGitHubBug207() {
253253
doTest("GitHubBug207", java8);
254254
}
255255

256+
@Test
257+
void testGitHubBug() {
258+
doTest("GitHubBug", java15);
259+
}
260+
256261
@Test
257262
void testLambda2783() {
258263
java8.parseResource("LambdaBug2783.java");
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import java.util.concurrent.Callable;
2+
3+
class A {
4+
A(Callable<Boolean> x) {}
5+
}
6+
7+
class B extends A {
8+
private static final int X = 1;
9+
B() {
10+
super(
11+
() -> {
12+
return switch (1) {
13+
case X -> true;
14+
default -> false;
15+
};
16+
}
17+
);
18+
}
19+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
+- CompilationUnit[@Compact = false, @PackageName = ""]
2+
+- ClassDeclaration[@Abstract = false, @Annotation = false, @Anonymous = false, @BinaryName = "GitHubBug207", @CanonicalName = "GitHubBug207", @EffectiveVisibility = Visibility.V_PUBLIC, @Enum = false, @Final = false, @Interface = false, @Local = false, @Nested = false, @PackageName = "", @Record = false, @RegularClass = true, @RegularInterface = false, @SimpleName = "GitHubBug207", @Static = false, @TopLevel = true, @UnnamedToplevelClass = false, @Visibility = Visibility.V_PUBLIC]
3+
+- ModifierList[@EffectiveModifiers = (JModifier.PUBLIC), @ExplicitModifiers = (JModifier.PUBLIC)]
4+
+- ClassBody[@Empty = false, @Size = 1]
5+
+- MethodDeclaration[@Abstract = false, @Arity = 1, @EffectiveVisibility = Visibility.V_PRIVATE, @Final = false, @Name = "resourceHttpMessageWriter", @Overridden = false, @Static = true, @Varargs = false, @Visibility = Visibility.V_PRIVATE, @Void = false]
6+
+- ModifierList[@EffectiveModifiers = (JModifier.PRIVATE, JModifier.STATIC), @ExplicitModifiers = (JModifier.PRIVATE, JModifier.STATIC)]
7+
+- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "HttpMessageWriter"]
8+
| +- TypeArguments[@Diamond = false, @Empty = false, @Size = 1]
9+
| +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "Resource"]
10+
+- FormalParameters[@Empty = false, @Size = 1]
11+
| +- FormalParameter[@EffectiveVisibility = Visibility.V_LOCAL, @Final = false, @Varargs = false, @Visibility = Visibility.V_LOCAL]
12+
| +- ModifierList[@EffectiveModifiers = (), @ExplicitModifiers = ()]
13+
| +- ClassType[@FullyQualified = true, @PackageQualifier = "BodyInserter", @SimpleName = "Context"]
14+
| +- VariableId[@ArrayType = false, @EffectiveVisibility = Visibility.V_LOCAL, @EnumConstant = false, @ExceptionBlockParameter = false, @Field = false, @Final = false, @ForLoopVariable = false, @ForeachVariable = false, @FormalParameter = true, @LambdaParameter = false, @LocalVariable = false, @Name = "context", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @Static = false, @TypeInferred = false, @Unnamed = false, @Visibility = Visibility.V_LOCAL]
15+
+- Block[@Empty = false, @Size = 1, @containsComment = false]
16+
+- ReturnStatement[]
17+
+- MethodCall[@CompileTimeConstant = false, @Image = "map", @MethodName = "map", @ParenthesisDepth = 0, @Parenthesized = false]
18+
+- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "context", @Name = "context", @ParenthesisDepth = 0, @Parenthesized = false]
19+
+- ArgumentList[@Empty = false, @Size = 1]
20+
+- MethodReference[@CompileTimeConstant = false, @ConstructorReference = false, @MethodName = "cast", @ParenthesisDepth = 0, @Parenthesized = false]
21+
+- AmbiguousName[@CompileTimeConstant = false, @Image = "BodyInserters", @Name = "BodyInserters", @ParenthesisDepth = 0, @Parenthesized = false]
22+
+- TypeArguments[@Diamond = false, @Empty = false, @Size = 1]
23+
+- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "Resource"]

0 commit comments

Comments
 (0)