Fix #1371992: Error with switch when last case block omits break or return
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / compiler / parser / Parser.java
index 7314c8d..ded438e 100644 (file)
@@ -1725,6 +1725,10 @@ public class Parser implements ITerminalSymbols, CompilerModifiers, ParserBasicI
                                expr(); // constant();
                                if (token == TokenNameCOLON || token == TokenNameSEMICOLON) {
                                        getNextToken();
+                                       if (token == TokenNameRBRACE) {
+                                               // empty case; assumes that the '}' token belongs to the wrapping switch statement
+                                               break;
+                                       }
                                        if (token == TokenNamecase || token == TokenNamedefault) {
                                                // empty case statement ?
                                                continue;
@@ -1752,7 +1756,7 @@ public class Parser implements ITerminalSymbols, CompilerModifiers, ParserBasicI
                                if (token == TokenNameCOLON || token == TokenNameSEMICOLON) {
                                        getNextToken();
                                        if (token == TokenNameRBRACE) {
-                                               // empty default case
+                                               // empty default case; ; assumes that the '}' token belongs to the wrapping switch statement
                                                break;
                                        }
                                        if (token != TokenNamecase) {
@@ -3124,15 +3128,7 @@ public class Parser implements ITerminalSymbols, CompilerModifiers, ParserBasicI
                                }
                                getNextToken();
                        } else if (token == TokenNameLBRACKET) {
-                               if (ref != null && ref instanceof FieldReference) {
-                                       FieldReference fref = (FieldReference) ref;
-                                       if (!containsVariableSet(fref.token)) {
-                                               problemReporter.uninitializedLocalVariable(new String(fref.token), fref.sourceStart(), fref.sourceEnd(),
-                                                               referenceContext, compilationUnit.compilationResult);
-                                               addVariableSet(fref.token);
-                                       }
-                               }
-                               ref = null;
+                               // To remove "ref = null;" here, is probably better than the patch commented in #1368081 - axelcl
                                getNextToken();
                                if (token != TokenNameRBRACKET) {
                                        expr();