public static final class VariableScopeVisitor.InstanceofFlowBindings
extends Object
Flow-sensitive result for JEP 394 instanceof pattern
bindings (GROOVY-12242) — the Groovy equivalent of the JLS §6.3.1
“introduced by” sets.
One type, two views of the same analysis:
Covered shapes: e instanceof T t, e !instanceof T t
(native form and !(e instanceof T t)), !expr,
a && b, a || b. All other shapes yield EMPTY
(conservative: no definite bindings).
| Modifiers | Name | Description |
|---|---|---|
static VariableScopeVisitor.InstanceofFlowBindings |
EMPTY |
Singleton for "no pattern variables on either path". |
static Object |
KEY |
Metadata key for ASTNode.putNodeMetaData/getNodeMetaData. |
| Type Params | Return Type | Name and description |
|---|---|---|
|
public Set<String> |
allNames()All pattern-variable names in either path (stable encounter order). |
|
public static Set<String> |
allPatternNames(Expression expression)Names of all pattern variables in expression, regardless
of definite-assignment path. |
|
public static boolean |
containsPattern(Expression expression)Returns true if expression contains any JEP 394
type-pattern node at any depth. |
|
public static VariableScopeVisitor.InstanceofFlowBindings |
get(ASTNode node)Returns the analysis result previously attached to node, or
EMPTY if none (no path-live pattern variables). |
|
public boolean |
isEmpty()Whether any pattern variable is bound on either path. |
|
public static VariableScopeVisitor.InstanceofFlowBindings |
of(Expression expression)Analyses expression for definite instanceof pattern
bindings. |
|
public static void |
put(ASTNode node, VariableScopeVisitor.InstanceofFlowBindings bindings)Attaches this analysis result to node for later phases.
|
|
public List<VariableExpression> |
whenFalse()Pattern variables definitely assigned when the condition is false.
|
|
public Set<String> |
whenFalseNames()Names of pattern variables bound when the condition is false.
|
|
public List<VariableExpression> |
whenTrue()Pattern variables definitely assigned when the condition is true.
|
|
public Set<String> |
whenTrueNames()Names of pattern variables bound when the condition is true.
|
Singleton for "no pattern variables on either path".
Metadata key for ASTNode.putNodeMetaData/getNodeMetaData.
Names of all pattern variables in expression, regardless
of definite-assignment path. Full tree walk; for tests/diagnostics.
Classgen tracks allocated slots via CompileStack instead.
Returns true if expression contains any JEP 394
type-pattern node at any depth. Full subtree walk (unlike of).
Used by tests and diagnostics; classgen has its own structural check
for expression-statement isolation.
Returns the analysis result previously attached to node, or
EMPTY if none (no path-live pattern variables).
Whether any pattern variable is bound on either path.
Analyses expression for definite instanceof pattern
bindings. Call only from VariableScopeVisitor (or tests);
classgen must use get(ASTNode).
expression - a boolean condition (may be a
BooleanExpression wrapper); null
yields EMPTYnull Attaches this analysis result to node for later phases.
No-op when bindings is null or EMPTY.
Pattern variables definitely assigned when the condition is false.
Used by VariableScopeVisitor to declare into scopes.
Names of pattern variables bound when the condition is false.
Used by classgen for CompileStack path-hide; same set as whenFalse().
Pattern variables definitely assigned when the condition is true.
Used by VariableScopeVisitor to declare into scopes.
Names of pattern variables bound when the condition is true.
Used by classgen for CompileStack path-hide; same set as whenTrue().