-
Notifications
You must be signed in to change notification settings - Fork 382
Closed
Labels
Milestone
Description
Using a switch-statement with an if- or for-statement without using {}, the GWT compilation will throw an exception. Surrounding the switch with {} will fix that exception.
if ((vpos != null))
switch (vpos) {
case TOP :
return "text-before-edge";
case CENTER :
return "central";
case BASELINE :
return "baseline";
case BOTTOM :
return "text-after-edge";
}
will crash with this exception:
[INFO] Caused by: java.lang.ClassCastException: class com.google.gwt.dev.jjs.ast.JSwitchStatement cannot be cast to class com.google.gwt.dev.jjs.ast.JExpression (com.google.gwt.dev.jjs.ast.JSwitchStatement and com.google.gwt.dev.jjs.ast.JExpression are in unnamed module of loader 'app')
[INFO] at com.google.gwt.dev.jjs.impl.GwtAstBuilder$AstVisitor.pop(GwtAstBuilder.java:2816)
[INFO] at com.google.gwt.dev.jjs.impl.GwtAstBuilder$AstVisitor.endVisit(GwtAstBuilder.java:1087)
[INFO] ... 25 more
[INFO] [ERROR] at SvgNodePeer.java(201): if ((vpos != null))
[INFO] switch (vpos) {
[INFO] case TOP :
[INFO] return "text-before-edge";
[INFO] case CENTER :
[INFO] return "central";
[INFO] case BASELINE :
[INFO] return "baseline";
[INFO] case BOTTOM :
[INFO] return "text-after-edge";
[INFO] }
[INFO] org.eclipse.jdt.internal.compiler.ast.IfStatement
while this will work:
if ((vpos != null)) {
switch (vpos) {
case TOP :
return "text-before-edge";
case CENTER :
return "central";
case BASELINE :
return "baseline";
case BOTTOM :
return "text-after-edge";
}
}
Same issue with this code:
for (InMemoryAuthorizationRule rule : rules)
switch (rule.computeRuleResult(operationRequest)) {
case DENIED: result = AuthorizationRuleResult.DENIED; break; // Breaking as it's a final decision
case GRANTED: result = AuthorizationRuleResult.GRANTED; // Not breaking, as we need to check there is not another denying rule (which is priority)
case OUT_OF_RULE_CONTEXT: // just ignoring it and looping to the next
}
GWT version: 2.12.0
Browser (with version): all browser
Operating System: all OS
Reactions are currently unavailable