Skip to content

Commit

Permalink
"Regression" in 3.39.0
Browse files Browse the repository at this point in the history
+ find missing types in more kinds of types to avoid abort due to
  ProblemReporter.needImplementation()

Fixes #3064
  • Loading branch information
stephan-herrmann committed Oct 26, 2024
1 parent becc3cd commit 1006cc6
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4874,7 +4874,7 @@ else if (type instanceof ArrayBinding) {
}
}

if (type.isParameterizedType()) {
if (!(type instanceof MissingTypeBinding)) {
List<TypeBinding> missingTypes = type.collectMissingTypes(null);
if (missingTypes != null) {
ReferenceContext savedContext = this.referenceContext;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,7 @@
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.dom.AST;
import org.eclipse.jdt.core.dom.ASTParser;
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jdt.core.dom.MethodDeclaration;
import org.eclipse.jdt.core.dom.MethodInvocation;
import org.eclipse.jdt.core.dom.TypeDeclaration;
import org.eclipse.jdt.core.dom.VariableDeclarationFragment;
import org.eclipse.jdt.core.dom.VariableDeclarationStatement;
import org.eclipse.jdt.core.dom.*;
import org.eclipse.jdt.internal.core.dom.rewrite.ASTRewriteFlattener;
import org.eclipse.jdt.internal.core.dom.rewrite.RewriteEventStore;

Expand Down Expand Up @@ -1162,4 +1155,48 @@ <T> Map<String, Integer> foo(Class<T> clazz) {
deleteProject("P");
}
}

public void testGH3064() throws CoreException {
try {
createJavaProject("P", new String[] { "" }, new String[] { "CONVERTER_JCL_LIB" }, "", "1.8", true);
createFolder("P/src/test");
createFile("/P/src/test/Action.java", """
package test;
public class Action<Request extends BroadcastRequest<Request>, ShardRequest> {
private final Request request;
protected ShardRequest newShardRequest(Request request) {return null;} // can also be omitted
protected void performOperation(final int shardIndex) {
ShardRequest shardRequest = newShardRequest(request);
shardRequest.setParentTask(foobar);
}
}
""");
ICompilationUnit cuAction = getCompilationUnit("P/src/test/Action.java");
ASTParser parser = createASTParser();
parser.setResolveBindings(true);
parser.setBindingsRecovery(true);
parser.setSource(cuAction);
CompilationUnit cu = (CompilationUnit) parser.createAST(null);
TypeDeclaration type = (TypeDeclaration) cu.types().get(0);
Object decl2 = type.bodyDeclarations().get(2);
assertEquals(MethodDeclaration.class, decl2.getClass());
Object stat0 = ((MethodDeclaration) decl2).getBody().statements().get(0);
Object stat1 = ((MethodDeclaration) decl2).getBody().statements().get(1);
assertEquals(ExpressionStatement.class, stat1.getClass());
Expression expr = ((ExpressionStatement) stat1).getExpression();
assertEquals(MethodInvocation.class, expr.getClass());
Expression receiver = ((MethodInvocation) expr).getExpression();
IBinding binding1 = ((SimpleName) receiver).resolveBinding();
assertNotNull(binding1);
assertEquals(VariableDeclarationStatement.class, stat0.getClass());
VariableDeclarationFragment frag = (VariableDeclarationFragment) ((VariableDeclarationStatement) stat0)
.fragments().get(0);
IBinding binding0 = frag.getName().resolveBinding();
assertEquals(binding0, binding1);
} finally {
deleteProject("P");
}
}
}

0 comments on commit 1006cc6

Please sign in to comment.