Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephan Herrmann2019-01-26 23:43:05 +0000
committerStephan Herrmann2019-01-26 23:43:05 +0000
commitd19276eae98e935f2934a2eb81f277c9da487629 (patch)
tree2a1973aaa090e9464254324981069e933e7506bf
parent611d1a2bf2ab2bdbd4d1e773bc63025fa361e04b (diff)
downloadeclipse.jdt.core-d19276eae98e935f2934a2eb81f277c9da487629.tar.gz
eclipse.jdt.core-d19276eae98e935f2934a2eb81f277c9da487629.tar.xz
eclipse.jdt.core-d19276eae98e935f2934a2eb81f277c9da487629.zip
Bug 531714 - [12] Compiler support for JEP 325: Switch Expressions
- polish Change-Id: I5f9461bc60284a8b7cc7775880e3c11085a2378f Signed-off-by: Stephan Herrmann <stephan.herrmann@berlin.de>
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SwitchExpression.java11
1 files changed, 5 insertions, 6 deletions
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 a43facb6f9..88e75f2a52 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
@@ -214,13 +214,12 @@ public class SwitchExpression extends SwitchStatement implements IPolyExpression
protected boolean computeConversions(BlockScope blockScope, TypeBinding targetType) {
boolean ok = true;
for (int i = 0, l = this.resultExpressions.size(); i < l; ++i) {
- ok &= computeConversionsResultExpressions(blockScope, targetType, ok, this.originalValueResultExpressionTypes[i],
- this.resultExpressions.get(i));
+ ok &= computeConversionsResultExpressions(blockScope, targetType, this.originalValueResultExpressionTypes[i], this.resultExpressions.get(i));
}
return ok;
}
- private boolean computeConversionsResultExpressions(BlockScope blockScope, TypeBinding targetType, boolean ok,
- TypeBinding resultExpressionType, Expression resultExpression) {
+ private boolean computeConversionsResultExpressions(BlockScope blockScope, TypeBinding targetType, TypeBinding resultExpressionType,
+ Expression resultExpression) {
if (resultExpressionType != null && resultExpressionType.isValidBinding()) {
if (resultExpression.isConstantValueOfTypeAssignableToType(resultExpressionType, targetType)
|| resultExpressionType.isCompatibleWith(targetType)) {
@@ -241,10 +240,10 @@ public class SwitchExpression extends SwitchStatement implements IPolyExpression
}
} else {
blockScope.problemReporter().typeMismatchError(resultExpressionType, targetType, resultExpression, null);
- ok = false;
+ return false;
}
}
- return ok;
+ return true;
}
/* package */ void collectResultExpressions() {
if (this.resultExpressions != null)

Back to the top