16
16
*/
17
17
package org .apache .calcite .linq4j .tree ;
18
18
19
+ import org .checkerframework .checker .nullness .qual .Nullable ;
20
+
19
21
import java .lang .reflect .Modifier ;
20
22
import java .lang .reflect .Type ;
21
23
import java .util .ArrayList ;
@@ -41,7 +43,7 @@ public class BlockBuilder {
41
43
new HashMap <>();
42
44
43
45
private final boolean optimizing ;
44
- private final BlockBuilder parent ;
46
+ private final @ Nullable BlockBuilder parent ;
45
47
46
48
private static final Shuttle OPTIMIZE_SHUTTLE = new OptimizeShuttle ();
47
49
@@ -66,7 +68,7 @@ public BlockBuilder(boolean optimizing) {
66
68
*
67
69
* @param optimizing Whether to eliminate common sub-expressions
68
70
*/
69
- public BlockBuilder (boolean optimizing , BlockBuilder parent ) {
71
+ public BlockBuilder (boolean optimizing , @ Nullable BlockBuilder parent ) {
70
72
this .optimizing = optimizing ;
71
73
this .parent = parent ;
72
74
}
@@ -85,7 +87,7 @@ public void clear() {
85
87
* (possibly a variable) that represents the result of the newly added
86
88
* block.
87
89
*/
88
- public Expression append (String name , BlockStatement block ) {
90
+ public @ Nullable Expression append (String name , BlockStatement block ) {
89
91
return append (name , block , true );
90
92
}
91
93
@@ -99,7 +101,7 @@ public Expression append(String name, BlockStatement block) {
99
101
* a variable. Do not do this if the expression has
100
102
* side-effects or a time-dependent value.
101
103
*/
102
- public Expression append (String name , BlockStatement block ,
104
+ public @ Nullable Expression append (String name , BlockStatement block ,
103
105
boolean optimize ) {
104
106
if (statements .size () > 0 ) {
105
107
Statement lastStatement = statements .get (statements .size () - 1 );
@@ -184,7 +186,7 @@ public Expression append(String name, Expression expression) {
184
186
/**
185
187
* Appends an expression to a list of statements, if it is not null.
186
188
*/
187
- public Expression appendIfNotNull (String name , Expression expression ) {
189
+ public @ Nullable Expression appendIfNotNull (String name , @ Nullable Expression expression ) {
188
190
if (expression == null ) {
189
191
return null ;
190
192
}
@@ -283,7 +285,7 @@ private Expression normalizeDeclaration(DeclarationStatement decl) {
283
285
* @param expr expression to test
284
286
* @return existing ParameterExpression or null
285
287
*/
286
- public DeclarationStatement getComputedExpression (Expression expr ) {
288
+ public @ Nullable DeclarationStatement getComputedExpression (Expression expr ) {
287
289
if (parent != null ) {
288
290
DeclarationStatement decl = parent .getComputedExpression (expr );
289
291
if (decl != null ) {
0 commit comments