Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorManoj Palat2019-03-08 06:26:22 +0000
committerManoj Palat2019-03-11 09:58:56 +0000
commit2626149d97fec42ea468f261615b6c149db7460b (patch)
treea3dd3ac5bf9c559e153570ba86bac97fa78a1f77
parent2b0a76948a729e70b2d3d038d5a479226f3e89c9 (diff)
downloadeclipse.jdt.core-2626149d97fec42ea468f261615b6c149db7460b.tar.gz
eclipse.jdt.core-2626149d97fec42ea468f261615b6c149db7460b.tar.xz
eclipse.jdt.core-2626149d97fec42ea468f261615b6c149db7460b.zip
Bug 544605: [12] DebugEvaluationTest test failures/errors with Java 12P20190312-0135
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Expression.java4
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SwitchExpression.java4
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SwitchStatement.java5
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java8
-rw-r--r--org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetParser.java12
5 files changed, 27 insertions, 6 deletions
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Expression.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Expression.java
index 5b8054c57d..f5cb820c72 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Expression.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Expression.java
@@ -1293,6 +1293,10 @@ public void traverse(ASTVisitor visitor, ClassScope scope) {
public boolean statementExpression() {
return false;
}
+// for switch statement
+public boolean isTrulyExpression() {
+ return true;
+}
/**
* Used on the lhs of an assignment for detecting null spec violation.
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SwitchExpression.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SwitchExpression.java
index 0860ac3f0c..9dd21e41f8 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SwitchExpression.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SwitchExpression.java
@@ -641,6 +641,10 @@ public class SwitchExpression extends SwitchStatement implements IPolyExpression
this.expressionContext == INVOCATION_CONTEXT;
}
@Override
+ public boolean isTrulyExpression() {
+ return true;
+ }
+ @Override
public boolean isCompatibleWith(TypeBinding left, Scope skope) {
if (!isPolyExpression())
return super.isCompatibleWith(left, skope);
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SwitchStatement.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SwitchStatement.java
index 8670e38554..1147db6bf9 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SwitchStatement.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SwitchStatement.java
@@ -742,7 +742,10 @@ public class SwitchStatement extends Expression {
protected boolean ignoreMissingDefaultCase(CompilerOptions compilerOptions, boolean isEnumSwitch) {
return compilerOptions.getSeverity(CompilerOptions.MissingDefaultCase) == ProblemSeverities.Ignore;
}
-
+ @Override
+ public boolean isTrulyExpression() {
+ return false;
+ }
private void reportMixingCaseTypes() {
if (this.caseCount == 0) {
this.switchLabeledRules = this.defaultCase != null ? this.defaultCase.isExpr : this.switchLabeledRules;
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java
index 63c98f070d..af3d047a89 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java
@@ -898,7 +898,7 @@ public class Parser implements TerminalTokens, ParserBasicInformation, Conflicte
protected int[] nestedMethod; //the ptr is nestedType
protected int forStartPosition = 0;
- protected int nestedType, dimensions;
+ protected int nestedType, dimensions, switchNestingLevel;
ASTNode [] noAstNodes = new ASTNode[AstStackIncrement];
Expression [] noExpressions = new Expression[ExpressionStackIncrement];
@@ -9280,6 +9280,7 @@ private void createSwitchStatementOrExpression(boolean isStmt) {
//the block is inlined but a scope need to be created
//if some declaration occurs.
this.nestedType--;
+ this.switchNestingLevel--;
int length;
SwitchStatement switchStatement = isStmt ? new SwitchStatement() : new SwitchExpression();
@@ -9879,6 +9880,7 @@ protected void consumeToken(int type) {
break;
case TokenNameswitch :
consumeNestedType();
+ ++this.switchNestingLevel;
this.nestedMethod[this.nestedType] ++;
pushOnIntStack(this.scanner.startPosition);
break;
@@ -11385,6 +11387,7 @@ public void initialize(boolean parsingCompilationUnit) {
this.identifierLengthPtr = -1;
this.intPtr = -1;
this.nestedMethod[this.nestedType = 0] = 0; // need to reset for further reuse
+ this.switchNestingLevel = 0;
this.variablesCounter[this.nestedType] = 0;
this.dimensions = 0 ;
this.realBlockPtr = -1;
@@ -12557,6 +12560,7 @@ protected void prepareForBlockStatements() {
this.nestedMethod[this.nestedType = 0] = 1;
this.variablesCounter[this.nestedType] = 0;
this.realBlockStack[this.realBlockPtr = 1] = 0;
+ this.switchNestingLevel = 0;
}
/**
* Returns this parser's problem reporter initialized with its reference context.
@@ -13139,6 +13143,7 @@ protected void resetStacks() {
this.nestedMethod[this.nestedType = 0] = 0; // need to reset for further reuse
this.variablesCounter[this.nestedType] = 0;
+ this.switchNestingLevel = 0;
this.dimensions = 0 ;
this.realBlockStack[this.realBlockPtr = 0] = 0;
@@ -13365,6 +13370,7 @@ public void copyState(Parser from) {
this.typeAnnotationLengthPtr = parser.typeAnnotationLengthPtr;
this.intPtr = parser.intPtr;
this.nestedType = parser.nestedType;
+ this.switchNestingLevel = parser.switchNestingLevel;
this.realBlockPtr = parser.realBlockPtr;
this.valueLambdaNestDepth = parser.valueLambdaNestDepth;
diff --git a/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetParser.java b/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetParser.java
index e6c4acc71a..0b02569aed 100644
--- a/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetParser.java
+++ b/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetParser.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2013 IBM Corporation and others.
+ * Copyright (c) 2000, 2019 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -8,6 +8,10 @@
*
* SPDX-License-Identifier: EPL-2.0
*
+ * This is an implementation of an early-draft specification developed under the Java
+ * Community Process (JCP) and is made available for testing and evaluation purposes
+ * only. The code is not compatible with any specification of the JCP.
+ *
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
@@ -290,7 +294,8 @@ protected void consumeMethodDeclaration(boolean isNotAbstract, boolean isDefault
// support have to be defined at toplevel only
if (isTopLevelType()) {
int last = methodDecl.statements == null ? -1 : methodDecl.statements.length - 1;
- if (last >= 0 && methodDecl.statements[last] instanceof Expression){
+ if (last >= 0 && methodDecl.statements[last] instanceof Expression &&
+ ((Expression) methodDecl.statements[last]).isTrulyExpression()) {
Expression lastExpression = (Expression) methodDecl.statements[last];
methodDecl.statements[last] = new CodeSnippetReturnStatement(
lastExpression,
@@ -365,7 +370,6 @@ protected void consumeMethodDeclaration(boolean isNotAbstract, boolean isDefault
methodDecl.statements = newStatements;
}
}
-
@Override
protected void consumeMethodInvocationName() {
// MethodInvocation ::= Name '(' ArgumentListopt ')'
@@ -770,7 +774,7 @@ protected void ignoreExpressionAssignment() {
* Returns whether we are parsing a top level type or not.
*/
private boolean isTopLevelType() {
- return this.nestedType == (this.diet ? 0 : 1);
+ return (this.nestedType - this.switchNestingLevel) == (this.diet ? 0 : 1);
}
@Override
protected MessageSend newMessageSend() {

Back to the top