diff options
author | Manoj Palat | 2019-07-05 03:45:02 +0000 |
---|---|---|
committer | Manoj Palat | 2019-07-05 16:26:09 +0000 |
commit | 307a3c3d44128acfd11ff622b30bcb4cbff02be4 (patch) | |
tree | 844e06cacffa1a40cccf8f364e5080fe4a96e60f | |
parent | ba38cbc42b824a26720727ec32191753fe9e726b (diff) | |
download | eclipse.jdt.core-307a3c3d44128acfd11ff622b30bcb4cbff02be4.tar.gz eclipse.jdt.core-307a3c3d44128acfd11ff622b30bcb4cbff02be4.tar.xz eclipse.jdt.core-307a3c3d44128acfd11ff622b30bcb4cbff02be4.zip |
and yield type - further error messages
Change-Id: Iddbca11a47858f9d7a3150dff20ec8ad53f564ee
-rw-r--r-- | org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/YieldStatement.java | 27 |
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 |