Fix NPE with empty pattern list
This commit is contained in:
parent
00bf6fe2f7
commit
2c1a7f026e
@ -1889,13 +1889,13 @@ void RecordPattern():
|
||||
(Annotation())* ReferenceType() RecordStructurePattern()
|
||||
}
|
||||
|
||||
void RecordStructurePattern() #void:
|
||||
void RecordStructurePattern() #PatternList:
|
||||
{}
|
||||
{
|
||||
"(" [ ComponentPatternList() ] ")"
|
||||
}
|
||||
|
||||
void ComponentPatternList() #PatternList :
|
||||
void ComponentPatternList() #void :
|
||||
{}
|
||||
{
|
||||
ComponentPattern() ( "," ComponentPattern() )*
|
||||
|
@ -97,4 +97,13 @@ public class RecordPatterns {
|
||||
System.out.println("String " + s);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
record Empty(){}
|
||||
void foo(Object o) {
|
||||
boolean x = o instanceof Empty;
|
||||
x = o instanceof Empty();
|
||||
}
|
||||
|
||||
;
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
+- CompilationUnit[@PackageName = ""]
|
||||
+- ClassDeclaration[@Abstract = false, @Annotation = false, @Anonymous = false, @BinaryName = "RecordPatterns", @CanonicalName = "RecordPatterns", @EffectiveVisibility = Visibility.V_PUBLIC, @Enum = false, @Final = false, @Interface = false, @Local = false, @Nested = false, @PackageName = "", @Record = false, @RegularClass = true, @RegularInterface = false, @SimpleName = "RecordPatterns", @Static = false, @TopLevel = true, @UnnamedToplevelClass = false, @Visibility = Visibility.V_PUBLIC]
|
||||
+- ModifierList[@EffectiveModifiers = (JModifier.PUBLIC), @ExplicitModifiers = (JModifier.PUBLIC)]
|
||||
+- ClassBody[@Empty = false, @Size = 18]
|
||||
+- ClassBody[@Empty = false, @Size = 21]
|
||||
+- RecordDeclaration[@Abstract = false, @Annotation = false, @Anonymous = false, @BinaryName = "RecordPatterns$Point", @CanonicalName = "RecordPatterns.Point", @EffectiveVisibility = Visibility.V_PACKAGE, @Enum = false, @Final = true, @Interface = false, @Local = false, @Nested = true, @PackageName = "", @Record = true, @RegularClass = false, @RegularInterface = false, @SimpleName = "Point", @Static = true, @TopLevel = false, @UnnamedToplevelClass = false, @Visibility = Visibility.V_PACKAGE]
|
||||
| +- ModifierList[@EffectiveModifiers = (JModifier.STATIC, JModifier.FINAL), @ExplicitModifiers = ()]
|
||||
| +- RecordComponentList[@Empty = false, @Size = 2, @Varargs = false]
|
||||
@ -512,38 +512,70 @@
|
||||
| +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "String ", @Empty = false, @Image = "\"String \"", @Length = 7, @LiteralText = "\"String \"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false]
|
||||
| +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "s", @Name = "s", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
+- MethodDeclaration[@Abstract = false, @Arity = 1, @EffectiveVisibility = Visibility.V_PACKAGE, @Final = false, @Name = "test4", @Overridden = false, @Static = false, @Varargs = false, @Visibility = Visibility.V_PACKAGE, @Void = true]
|
||||
+- ModifierList[@EffectiveModifiers = (), @ExplicitModifiers = ()]
|
||||
+- VoidType[]
|
||||
+- FormalParameters[@Empty = false, @Size = 1]
|
||||
| +- FormalParameter[@EffectiveVisibility = Visibility.V_LOCAL, @Final = false, @Varargs = false, @Visibility = Visibility.V_LOCAL]
|
||||
| +- ModifierList[@EffectiveModifiers = (), @ExplicitModifiers = ()]
|
||||
| +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "Box"]
|
||||
| | +- TypeArguments[@Diamond = false, @Empty = false, @Size = 1]
|
||||
| +- VoidType[]
|
||||
| +- FormalParameters[@Empty = false, @Size = 1]
|
||||
| | +- FormalParameter[@EffectiveVisibility = Visibility.V_LOCAL, @Final = false, @Varargs = false, @Visibility = Visibility.V_LOCAL]
|
||||
| | +- ModifierList[@EffectiveModifiers = (), @ExplicitModifiers = ()]
|
||||
| | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "Box"]
|
||||
| | +- TypeArguments[@Diamond = false, @Empty = false, @Size = 1]
|
||||
| | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "String"]
|
||||
| +- 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 = "bo", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @Static = false, @TypeInferred = false, @Unnamed = false, @Visibility = Visibility.V_LOCAL]
|
||||
+- Block[@Empty = false, @Size = 1, @containsComment = false]
|
||||
+- IfStatement[@Else = false]
|
||||
+- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.INSTANCEOF, @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "bo", @Name = "bo", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | | +- TypeArguments[@Diamond = false, @Empty = false, @Size = 1]
|
||||
| | | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "Box"]
|
||||
| | | +- TypeArguments[@Diamond = false, @Empty = false, @Size = 1]
|
||||
| | | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "String"]
|
||||
| | +- 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 = "bo", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @Static = false, @TypeInferred = false, @Unnamed = false, @Visibility = Visibility.V_LOCAL]
|
||||
| +- Block[@Empty = false, @Size = 1, @containsComment = false]
|
||||
| +- IfStatement[@Else = false]
|
||||
| +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.INSTANCEOF, @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "bo", @Name = "bo", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | +- PatternExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | +- RecordPattern[]
|
||||
| | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "Box"]
|
||||
| | +- PatternList[@Empty = false, @Size = 1]
|
||||
| | +- RecordPattern[]
|
||||
| | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "Box"]
|
||||
| | +- PatternList[@Empty = false, @Size = 1]
|
||||
| | +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @Visibility = Visibility.V_PACKAGE]
|
||||
| | +- ModifierList[@EffectiveModifiers = (), @ExplicitModifiers = ()]
|
||||
| | +- VariableId[@ArrayType = false, @EffectiveVisibility = Visibility.V_LOCAL, @EnumConstant = false, @ExceptionBlockParameter = false, @Field = false, @Final = false, @ForLoopVariable = false, @ForeachVariable = false, @FormalParameter = false, @LambdaParameter = false, @LocalVariable = false, @Name = "s", @PatternBinding = true, @RecordComponent = false, @ResourceDeclaration = false, @Static = false, @TypeInferred = true, @Unnamed = false, @Visibility = Visibility.V_LOCAL]
|
||||
| +- Block[@Empty = false, @Size = 1, @containsComment = false]
|
||||
| +- ExpressionStatement[]
|
||||
| +- MethodCall[@CompileTimeConstant = false, @Image = "println", @MethodName = "println", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| +- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "out", @Name = "out", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | +- TypeExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "System"]
|
||||
| +- ArgumentList[@Empty = false, @Size = 1]
|
||||
| +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.ADD, @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| +- StringLiteral[@CompileTimeConstant = true, @ConstValue = "String ", @Empty = false, @Image = "\"String \"", @Length = 7, @LiteralText = "\"String \"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false]
|
||||
| +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "s", @Name = "s", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
+- RecordDeclaration[@Abstract = false, @Annotation = false, @Anonymous = false, @BinaryName = "RecordPatterns$Empty", @CanonicalName = "RecordPatterns.Empty", @EffectiveVisibility = Visibility.V_PACKAGE, @Enum = false, @Final = true, @Interface = false, @Local = false, @Nested = true, @PackageName = "", @Record = true, @RegularClass = false, @RegularInterface = false, @SimpleName = "Empty", @Static = true, @TopLevel = false, @UnnamedToplevelClass = false, @Visibility = Visibility.V_PACKAGE]
|
||||
| +- ModifierList[@EffectiveModifiers = (JModifier.STATIC, JModifier.FINAL), @ExplicitModifiers = ()]
|
||||
| +- RecordComponentList[@Empty = true, @Size = 0, @Varargs = false]
|
||||
| +- RecordBody[@Empty = true, @Size = 0]
|
||||
+- MethodDeclaration[@Abstract = false, @Arity = 1, @EffectiveVisibility = Visibility.V_PACKAGE, @Final = false, @Name = "foo", @Overridden = false, @Static = false, @Varargs = false, @Visibility = Visibility.V_PACKAGE, @Void = true]
|
||||
| +- ModifierList[@EffectiveModifiers = (), @ExplicitModifiers = ()]
|
||||
| +- VoidType[]
|
||||
| +- FormalParameters[@Empty = false, @Size = 1]
|
||||
| | +- FormalParameter[@EffectiveVisibility = Visibility.V_LOCAL, @Final = false, @Varargs = false, @Visibility = Visibility.V_LOCAL]
|
||||
| | +- ModifierList[@EffectiveModifiers = (), @ExplicitModifiers = ()]
|
||||
| | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "Object"]
|
||||
| | +- 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 = "o", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @Static = false, @TypeInferred = false, @Unnamed = false, @Visibility = Visibility.V_LOCAL]
|
||||
| +- Block[@Empty = false, @Size = 2, @containsComment = false]
|
||||
| +- LocalVariableDeclaration[@EffectiveVisibility = Visibility.V_LOCAL, @Final = false, @TypeInferred = false, @Visibility = Visibility.V_LOCAL]
|
||||
| | +- ModifierList[@EffectiveModifiers = (), @ExplicitModifiers = ()]
|
||||
| | +- PrimitiveType[@Kind = PrimitiveTypeKind.BOOLEAN]
|
||||
| | +- VariableDeclarator[@Initializer = true, @Name = "x"]
|
||||
| | +- VariableId[@ArrayType = false, @EffectiveVisibility = Visibility.V_LOCAL, @EnumConstant = false, @ExceptionBlockParameter = false, @Field = false, @Final = false, @ForLoopVariable = false, @ForeachVariable = false, @FormalParameter = false, @LambdaParameter = false, @LocalVariable = true, @Name = "x", @PatternBinding = false, @RecordComponent = false, @ResourceDeclaration = false, @Static = false, @TypeInferred = false, @Unnamed = false, @Visibility = Visibility.V_LOCAL]
|
||||
| | +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.INSTANCEOF, @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "o", @Name = "o", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | +- TypeExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| | +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "Empty"]
|
||||
| +- ExpressionStatement[]
|
||||
| +- AssignmentExpression[@CompileTimeConstant = false, @Compound = false, @Operator = AssignmentOp.ASSIGN, @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| +- VariableAccess[@AccessType = AccessType.WRITE, @CompileTimeConstant = false, @Image = "x", @Name = "x", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| +- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.INSTANCEOF, @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| +- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "o", @Name = "o", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| +- PatternExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| +- RecordPattern[]
|
||||
| +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "Box"]
|
||||
| +- PatternList[@Empty = false, @Size = 1]
|
||||
| +- RecordPattern[]
|
||||
| +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "Box"]
|
||||
| +- PatternList[@Empty = false, @Size = 1]
|
||||
| +- TypePattern[@EffectiveVisibility = Visibility.V_PACKAGE, @Visibility = Visibility.V_PACKAGE]
|
||||
| +- ModifierList[@EffectiveModifiers = (), @ExplicitModifiers = ()]
|
||||
| +- VariableId[@ArrayType = false, @EffectiveVisibility = Visibility.V_LOCAL, @EnumConstant = false, @ExceptionBlockParameter = false, @Field = false, @Final = false, @ForLoopVariable = false, @ForeachVariable = false, @FormalParameter = false, @LambdaParameter = false, @LocalVariable = false, @Name = "s", @PatternBinding = true, @RecordComponent = false, @ResourceDeclaration = false, @Static = false, @TypeInferred = true, @Unnamed = false, @Visibility = Visibility.V_LOCAL]
|
||||
+- Block[@Empty = false, @Size = 1, @containsComment = false]
|
||||
+- ExpressionStatement[]
|
||||
+- MethodCall[@CompileTimeConstant = false, @Image = "println", @MethodName = "println", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
+- FieldAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "out", @Name = "out", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| +- TypeExpression[@CompileTimeConstant = false, @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "System"]
|
||||
+- ArgumentList[@Empty = false, @Size = 1]
|
||||
+- InfixExpression[@CompileTimeConstant = false, @Operator = BinaryOp.ADD, @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
+- StringLiteral[@CompileTimeConstant = true, @ConstValue = "String ", @Empty = false, @Image = "\"String \"", @Length = 7, @LiteralText = "\"String \"", @ParenthesisDepth = 0, @Parenthesized = false, @TextBlock = false]
|
||||
+- VariableAccess[@AccessType = AccessType.READ, @CompileTimeConstant = false, @Image = "s", @Name = "s", @ParenthesisDepth = 0, @Parenthesized = false]
|
||||
| +- ClassType[@FullyQualified = false, @PackageQualifier = null, @SimpleName = "Empty"]
|
||||
| +- PatternList[@Empty = true, @Size = 0]
|
||||
+- EmptyDeclaration[]
|
||||
|
Loading…
x
Reference in New Issue
Block a user