update jdt.core to I20210603-0040 for 4.20 RC2
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/LambdaRegressionTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/LambdaRegressionTest.java
index a336738..1e1b834 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/LambdaRegressionTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/LambdaRegressionTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2015, 2019 IBM Corporation and others.
+ * Copyright (c) 2015, 2021 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -24,7 +24,7 @@
public class LambdaRegressionTest extends AbstractRegressionTest {
static {
-// TESTS_NAMES = new String[] { "test001"};
+// TESTS_NAMES = new String[] { "test572873a", "test572873b"};
// TESTS_NUMBERS = new int[] { 50 };
// TESTS_RANGE = new int[] { 11, -1 };
}
@@ -1163,6 +1163,60 @@
runner.customOptions.put(JavaCore.COMPILER_ANNOTATION_NULL_ANALYSIS, JavaCore.ENABLED); // bug happens due to type annotation handling
runner.runConformTest();
}
+public void test572873a() {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "import java.util.Iterator;\n" +
+ "\n" +
+ "public class X {\n" +
+ " static <T> Iterable<T> iterable() {\n" +
+ " return () -> new Iterator<T>() {\n" +
+ " @Override\n" +
+ " public boolean hasNext() {\n" +
+ " return false;\n" +
+ " }\n" +
+ "\n" +
+ " @Override\n" +
+ " public T next() {\n" +
+ " return null;\n" +
+ " }\n" +
+ " };\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " System.out.println(\"test T\");\n" +
+ " }\n" +
+ "}",
+ },
+ "test T"
+ );
+}
+public void test572873b() {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "import java.util.function.Consumer;\n" +
+ "\n" +
+ "public class X {\n" +
+ " public static <T> void build(T element) {\n" +
+ " new Thread(() -> {\n" +
+ " new Consumer<T>() {\n" +
+ "\n" +
+ " @Override\n" +
+ " public void accept(T t) {" +
+ "\n" +
+ " }\n" +
+ " };\n" +
+ " });\n" +
+ " }" +
+ " public static void main(String[] args) {\n" +
+ " System.out.println(\"test T\");\n" +
+ " }\n" +
+ "}",
+ },
+ "test T"
+ );
+}
public static Class testClass() {
return LambdaRegressionTest.class;
}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/PatternMatching16Test.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/PatternMatching16Test.java
index a933b29..bcb28a1 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/PatternMatching16Test.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/PatternMatching16Test.java
@@ -3707,7 +3707,7 @@
"true",
options);
}
- public void testBug572431() {
+ public void testBug572431_1() {
Map<String, String> options = getCompilerOptions(false);
runConformTest(
new String[] {
@@ -3728,4 +3728,88 @@
options);
}
+ public void testBug572431_2() {
+ Map<String, String> options = getCompilerOptions(false);
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n"
+ + " static public void something () {\n"
+ + " boolean bool = true;\n"
+ + " Object object = null;\n"
+ + " if (object instanceof String string) {\n"
+ + " } else if (bool) {\n"
+ + " if (object instanceof Integer integer) {\n"
+ + " }\n"
+ + " }\n"
+ + " }\n"
+ + " static public void main (String[] args) throws Exception {\n"
+ + " }\n"
+ + "}",
+ },
+ "",
+ options);
+
+ }
+ public void testBug572431_3() {
+ Map<String, String> options = getCompilerOptions(false);
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n"
+ + " static public void something () {\n"
+ + " boolean bool = true;\n"
+ + " Object object = null;\n"
+ + " if (bool && object instanceof Integer i) {\n"
+ + " }\n"
+ + " }\n"
+ + " static public void main (String[] args) throws Exception {\n"
+ + " }\n"
+ + "}",
+ },
+ "",
+ options);
+
+ }
+ public void testBug572431_4() {
+ Map<String, String> options = getCompilerOptions(false);
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n"
+ + " static public void something () {\n"
+ + " boolean bool = true;\n"
+ + " Object object = null;\n"
+ + " if (!(object instanceof Integer i)) {\n"
+ + " }\n"
+ + " }\n"
+ + " static public void main (String[] args) throws Exception {\n"
+ + " }\n"
+ + "}",
+ },
+ "",
+ options);
+
+ }
+ public void testBug572431_5() {
+ Map<String, String> options = getCompilerOptions(false);
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n"
+ + " static public void something () {\n"
+ + " boolean bool = true;\n"
+ + " Object object = null;\n"
+ + " if (false) {\n"
+ + " } else if (!(object instanceof Integer i)) {\n"
+ + " }\n"
+ + " }\n"
+ + " static public void main (String[] args) throws Exception {\n"
+ + " }\n"
+ + "}",
+ },
+ "",
+ options);
+
+ }
}
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterBugsTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterBugsTests.java
index 094bba4..b4ab2dd 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterBugsTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterBugsTests.java
@@ -13283,6 +13283,6 @@
formatSource(source,
"public Record {\n" +
"}",
- CodeFormatter.K_RECORD_BODY_DECLARATIONS);
+ CodeFormatter.K_CLASS_BODY_DECLARATIONS);
}
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/IfStatement.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/IfStatement.java
index 9eff87b..921df40 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/IfStatement.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/IfStatement.java
@@ -249,7 +249,16 @@
this.elseStatement.generateCode(currentScope, codeStream);
} else {
// generate condition side-effects
- this.condition.generateCode(currentScope, codeStream, false);
+ if (this.condition.containsPatternVariable()) {
+ this.condition.generateOptimizedBoolean(
+ currentScope,
+ codeStream,
+ endifLabel,
+ null,
+ cst == Constant.NotAConstant);
+ } else {
+ this.condition.generateCode(currentScope, codeStream, false);
+ }
codeStream.recordPositionsFrom(pc, this.sourceStart);
}
// May loose some local variable initializations : affecting the local variable attributes
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/InstanceOfExpression.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/InstanceOfExpression.java
index c6ce375..8072d94 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/InstanceOfExpression.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/InstanceOfExpression.java
@@ -223,7 +223,6 @@
BranchLabel nextSibling = falseLabel != null ? falseLabel : new BranchLabel(codeStream);
codeStream.instance_of(this.type, this.type.resolvedType);
if (this.elementVariable != null) {
- valueRequired = true;
codeStream.ifeq(nextSibling);
codeStream.load(this.secretInstanceOfPatternExpressionValue);
codeStream.checkcast(this.type, this.type.resolvedType, codeStream.position);
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java
index a539bf6..f2edeee 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java
@@ -3789,7 +3789,7 @@
return typeVariable;
}
insideStaticContext |= sourceType.isStatic();
- insideClassContext = true;
+ insideClassContext = !sourceType.isAnonymousType();
insideTypeAnnotation = false;
if (CharOperation.equals(sourceType.sourceName, name)) {
if (foundType != null && TypeBinding.notEquals(foundType, sourceType) && foundType.problemId() != ProblemReasons.NotVisible)
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTParser.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTParser.java
index e27ac0f..675d7ab 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTParser.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTParser.java
@@ -135,13 +135,6 @@
// SH}
/**
- * Kind constant used to request that the source be parsed
- * as a compilation unit.
- * @since 3.26
- */
- public static final int K_RECORD_BODY_DECLARATIONS = 0x16;
-
- /**
* Creates a new object for creating a Java abstract syntax tree
* (AST) following the specified set of API rules.
*
@@ -1487,39 +1480,6 @@
ast.setOriginalModificationCount(ast.modificationCount());
return compilationUnit;
}
- case K_RECORD_BODY_DECLARATIONS:
- final org.eclipse.jdt.internal.compiler.ast.ASTNode[] recordNodes =
- codeSnippetParsingUtil.parseClassBodyDeclarations(
- this.rawSource,
- this.sourceOffset,
- this.sourceLength,
- this.compilerOptions,
- true,
- (this.bits & CompilationUnitResolver.STATEMENT_RECOVERY) != 0);
- recordedParsingInformation = codeSnippetParsingUtil.recordedParsingInformation;
- comments = recordedParsingInformation.commentPositions;
- if (comments != null) {
- converter.buildCommentsTable(compilationUnit, comments);
- }
- compilationUnit.setLineEndTable(recordedParsingInformation.lineEnds);
- if (recordNodes != null) {
- // source has no syntax error or the statement recovery is enabled
- RecordDeclaration recordDeclaration = converter.convertToRecord(recordNodes);
- recordDeclaration.setSourceRange(this.sourceOffset, this.sourceOffset + this.sourceLength);
- rootNodeToCompilationUnit(recordDeclaration.getAST(), compilationUnit, recordDeclaration, codeSnippetParsingUtil.recordedParsingInformation, null);
- ast.setDefaultNodeFlag(0);
- ast.setOriginalModificationCount(ast.modificationCount());
- return recordDeclaration;
- } else {
- // source has syntax error and the statement recovery is disabled
- CategorizedProblem[] problems = recordedParsingInformation.problems;
- if (problems != null) {
- compilationUnit.setProblems(problems);
- }
- ast.setDefaultNodeFlag(0);
- ast.setOriginalModificationCount(ast.modificationCount());
- return compilationUnit;
- }
}
throw new IllegalStateException();
}
diff --git a/org.eclipse.jdt.core/formatter/org/eclipse/jdt/core/formatter/CodeFormatter.java b/org.eclipse.jdt.core/formatter/org/eclipse/jdt/core/formatter/CodeFormatter.java
index 6bac726..c37a3fb 100644
--- a/org.eclipse.jdt.core/formatter/org/eclipse/jdt/core/formatter/CodeFormatter.java
+++ b/org.eclipse.jdt.core/formatter/org/eclipse/jdt/core/formatter/CodeFormatter.java
@@ -113,17 +113,6 @@
//jsv}
/**
- * Kind used to format a set of class body declarations
- *<p>
- * if the corresponding comment option is set to
- * <code>true</code> then it is also possible to format the comments on the fly
- * by adding the {@link #F_INCLUDE_COMMENTS} flag to this kind of format.
- * </p>
- * @since 3.26
- */
- public static final int K_RECORD_BODY_DECLARATIONS = 0x16;
-
- /**
* Kind used to format a single-line comment
* @since 3.1
*/