This is an automated email from the ASF dual-hosted git repository.
emilles pushed a commit to branch GROOVY_3_0_X
in repository https://gitbox.apache.org/repos/asf/groovy.git
The following commit(s) were added to refs/heads/GROOVY_3_0_X by this push:
new 41b7760427 restructure empty check
41b7760427 is described below
commit 41b7760427fe46b5dd6c09f6045515af9e24c319
Author: Eric Milles <[email protected]>
AuthorDate: Thu Jul 3 11:34:55 2025 -0500
restructure empty check
3_0_X backport
---
.../transform/stc/StaticTypeCheckingVisitor.java | 25 ++++++++++------------
1 file changed, 11 insertions(+), 14 deletions(-)
diff --git
a/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
b/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
index 831adc48e5..f974e8f42d 100644
---
a/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
+++
b/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
@@ -5162,21 +5162,18 @@ public class StaticTypeCheckingVisitor extends
ClassCodeVisitorSupport {
}
if (variable instanceof Parameter) {
Parameter parameter = (Parameter) variable;
- ClassNode type = null;
- // check if param part of control structure - but not if
inside instanceof
- List<ClassNode> temporaryTypesForExpression =
getTemporaryTypesForExpression(vexp);
- if (temporaryTypesForExpression == null ||
temporaryTypesForExpression.isEmpty()) {
- type =
typeCheckingContext.controlStructureVariables.get(parameter);
- }
- // now check for closure override
- if (type == null && temporaryTypesForExpression == null) {
- type = getTypeFromClosureArguments(parameter);
- }
- if (type != null) {
- storeType(vexp, type);
- return type;
+ if (getTemporaryTypesForExpression(vexp).isEmpty()) { // not
instanceof
+ // check if the parameter is part of a control structure
(for, catch, closure)
+ ClassNode type =
typeCheckingContext.controlStructureVariables.get(parameter);
+ if (type == null) { // else check closure metadata
+ type = getTypeFromClosureArguments(parameter);
+ }
+ if (type != null) {
+ storeType(vexp, type);
+ return type;
+ }
}
- return getType((Parameter) variable);
+ return getType(parameter);
}
return vexp.getOriginType();
}