Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorManoj Palat2014-08-01 08:12:40 +0000
committerManoj Palat2014-08-01 08:12:40 +0000
commit56632b66e4460fbaf36da5ee9142d7bce0f56a9e (patch)
tree9a3ad96eb5b8a4cf743cc745054b696db6072193
parentc7d5dd9d5cb1b97ae6a8cae6547b02ca06b345eb (diff)
downloadeclipse.jdt.core-56632b66e4460fbaf36da5ee9142d7bce0f56a9e.tar.gz
eclipse.jdt.core-56632b66e4460fbaf36da5ee9142d7bce0f56a9e.tar.xz
eclipse.jdt.core-56632b66e4460fbaf36da5ee9142d7bce0f56a9e.zip
Fix for Bug 432175 [1.8] IAE in ImportRewrite#addImport(..) for
IntersectionCastTypeBinding
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter18Test.java32
-rw-r--r--org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/TypeBinding.java5
2 files changed, 37 insertions, 0 deletions
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter18Test.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter18Test.java
index 1cb9793da8..2530e9aef6 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter18Test.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter18Test.java
@@ -4827,4 +4827,36 @@ public void testBug433879d() throws JavaModelException {
fail(e.getMessage());
}
}
+public void testBug432175() throws JavaModelException {
+ this.workingCopy = getWorkingCopy("/Converter18/src/testBug432175/X.java",
+ true/* resolve */);
+ String contents = "package testBug432175;\n" +
+ "interface Collection <T> {}\n" +
+ "class Collections {\n" +
+ " public static final <T> T emptyList() { return null; }\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public static <T extends Number & Comparable<?>> void method2(Collection<T> coll) {}\n" +
+ "\n" +
+ " public static void main(String[] args) {\n" +
+ " method2(Collections.emptyList());\n" +
+ " }\n" +
+ "}\n" ;
+
+ CompilationUnit cu = (CompilationUnit) buildAST(contents, this.workingCopy);
+ TypeDeclaration typeDeclaration = (TypeDeclaration) getASTNode(cu, 2);
+ MethodDeclaration [] methods = typeDeclaration.getMethods();
+
+ {
+ MethodDeclaration method = methods[1];
+ ExpressionStatement expressionStatement = (ExpressionStatement) method.getBody().statements().get(0);
+ MethodInvocation methodInvocation = (MethodInvocation) expressionStatement.getExpression();
+ methodInvocation = (MethodInvocation) methodInvocation.arguments().get(0);
+ ITypeBinding typeBinding = methodInvocation.resolveTypeBinding();
+ typeBinding = typeBinding.getTypeArguments()[0];
+ String res = typeBinding.getTypeDeclaration().getName();
+ this.ast.newSimpleType(this.ast.newName(res));
+ }
+}
+
}
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/TypeBinding.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/TypeBinding.java
index da7ed8e21e..ca7e4fc3c2 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/TypeBinding.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/TypeBinding.java
@@ -24,6 +24,7 @@ import org.eclipse.jdt.internal.compiler.lookup.BaseTypeBinding;
import org.eclipse.jdt.internal.compiler.lookup.Binding;
import org.eclipse.jdt.internal.compiler.lookup.CaptureBinding;
import org.eclipse.jdt.internal.compiler.lookup.FieldBinding;
+import org.eclipse.jdt.internal.compiler.lookup.IntersectionCastTypeBinding;
import org.eclipse.jdt.internal.compiler.lookup.LocalTypeBinding;
import org.eclipse.jdt.internal.compiler.lookup.MethodBinding;
import org.eclipse.jdt.internal.compiler.lookup.PackageBinding;
@@ -684,6 +685,10 @@ class TypeBinding implements ITypeBinding {
buffer.append(brackets);
return String.valueOf(buffer);
+ case Binding.INTERSECTION_CAST_TYPE :
+ // just use the first bound for now (same kludge as in IntersectionCastTypeBinding#constantPoolName())
+ return new String(((IntersectionCastTypeBinding) this.binding).getIntersectingTypes()[0].sourceName());
+
default :
if (isPrimitive() || isNullType()) {
BaseTypeBinding baseTypeBinding = (BaseTypeBinding) this.binding;

Back to the top