Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorManoj Palat2019-07-05 03:45:02 +0000
committerManoj Palat2019-07-05 16:26:09 +0000
commit307a3c3d44128acfd11ff622b30bcb4cbff02be4 (patch)
tree844e06cacffa1a40cccf8f364e5080fe4a96e60f
parentba38cbc42b824a26720727ec32191753fe9e726b (diff)
downloadeclipse.jdt.core-307a3c3d44128acfd11ff622b30bcb4cbff02be4.tar.gz
eclipse.jdt.core-307a3c3d44128acfd11ff622b30bcb4cbff02be4.tar.xz
eclipse.jdt.core-307a3c3d44128acfd11ff622b30bcb4cbff02be4.zip
Bug 547891 - [13] flag error for unqualified yield method invocations
and yield type - further error messages Change-Id: Iddbca11a47858f9d7a3150dff20ec8ad53f564ee
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/YieldStatement.java27
1 files changed, 20 insertions, 7 deletions
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/YieldStatement.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/YieldStatement.java
index ce9a5fe1e8..c1a0ad3eb0 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/YieldStatement.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/YieldStatement.java
@@ -121,10 +121,22 @@ protected void adjustStackSize(BlockScope currentScope, CodeStream codeStream) {
public void resolve(BlockScope scope) {
// METHOD IN WORKS - INCOMPLETE
super.resolve(scope);
-// if (this.expression == null)
-// currentScope.problemReporter().switchExpressionYieldMissingExpression(this);
-//
- if (this.switchExpression == null) {
+ if (this.expression == null) {
+ //currentScope.problemReporter().switchExpressionYieldMissingExpression(this);
+ return;
+
+ }
+ if (this.switchExpression != null || this.isImplicit) {
+ if (this.switchExpression == null && this.isImplicit && !this.expression.statementExpression()) {
+ if (scope.compilerOptions().sourceLevel >= ClassFileConstants.JDK12 && scope.compilerOptions().enablePreviewFeatures) {
+ /* JLS 13 14.11.2
+ Switch labeled rules in switch statements differ from those in switch expressions (15.28).
+ In switch statements they must be switch labeled statement expressions, ... */
+ scope.problemReporter().invalidExpressionAsStatement(this.expression);
+ return;
+ }
+ }
+ } else {
if (scope.compilerOptions().sourceLevel >= ClassFileConstants.JDK13) {
if (scope.compilerOptions().enablePreviewFeatures) {
scope.problemReporter().switchExpressionsYieldOutsideSwitchExpression(this);
@@ -133,9 +145,10 @@ public void resolve(BlockScope scope) {
}
}
}
- if (this.expression != null) {
- this.expression.resolveType(scope);
- }
+ this.expression.resolveType(scope);
+// if (this.expression != null) {
+// this.expression.resolveType(scope);
+// }
}
@Override

Back to the top