Bug 82504 [compiler][1.5] ClassCastException when parsing a CastExpression between an array type and a type variable
I20050104-1600 + jdt.core v_530a class F<T> { Object[] objectArr; void foo() { T x= (T) objectArr; } } Error 2005-01-10 21:22:57.662 An internal error occurred during: "Java AST creation". java.lang.ClassCastException at org.eclipse.jdt.internal.compiler.ast.Expression.checkCastTypesCompatibility(Expression.java:300) at org.eclipse.jdt.internal.compiler.ast.CastExpression.resolveType(CastExpression.java:376) at org.eclipse.jdt.internal.compiler.ast.LocalDeclaration.resolve(LocalDeclaration.java:201) at org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.resolveStatements(AbstractMethodDeclaration.java:411) at org.eclipse.jdt.internal.compiler.ast.MethodDeclaration.resolveStatements(MethodDeclaration.java:160) at org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.resolve(AbstractMethodDeclaration.java:389) at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.resolve(TypeDeclaration.java:1014) at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.resolve(TypeDeclaration.java:1063) at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.resolve(CompilationUnitDeclaration.java:280) at org.eclipse.jdt.core.dom.CompilationUnitResolver.resolve(CompilationUnitResolver.java:651) at org.eclipse.jdt.core.dom.CompilationUnitResolver.resolve(CompilationUnitResolver.java:443) at org.eclipse.jdt.core.dom.ASTParser.internalCreateAST(ASTParser.java:708) at org.eclipse.jdt.core.dom.ASTParser.createAST(ASTParser.java:574) at org.eclipse.jdt.internal.ui.javaeditor.ASTProvider.createAST(ASTProvider.java:563) at org.eclipse.jdt.internal.ui.javaeditor.ASTProvider.getAST(ASTProvider.java:494) at org.eclipse.jdt.internal.ui.viewsupport.SelectionListenerWithASTManager$PartListenerGroup.calculateASTandInform(SelectionListenerWithASTManager.java:165) at org.eclipse.jdt.internal.ui.viewsupport.SelectionListenerWithASTManager$3.run(SelectionListenerWithASTManager.java:142) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:66)
org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/TypeRulesTest.java
public void testIsAssignmentCompatible() throws Exception {
		VariableDeclarationFragment[] targets= createVariables();
		
		StringBuffer errors= new StringBuffer();
		for (int k= 0; k < targets.length; k++) {
			for (int n= 0; n < targets.length; n++) {
				VariableDeclarationFragment f1= targets[k];
				VariableDeclarationFragment f2= targets[n];
				String line= f2.getName().getIdentifier() + "= " + f1.getName().getIdentifier();
				
				StringBuffer buf= new StringBuffer();
				buf.append("package test1;\n");
				buf.append("public class F<T, U extends Number> extends E<T, U> {\n");
				buf.append("    void foo() {\n");
				buf.append("        ").append(line).append(";\n");
				buf.append("    }\n");
				buf.append("}\n");
				char[] content= buf.toString().toCharArray();
				
				ASTParser parser= ASTParser.newParser(AST.JLS3);
				parser.setSource(content);
				parser.setProject(fJProject1);
				parser.setUnitName("F.java");
				
				CompilationUnit astRoot= (CompilationUnit) parser.createAST(null);
				IProblem[] problems= astRoot.getProblems();
				
				ITypeBinding b1= f1.resolveBinding().getType();
				assertNotNull(b1);
				ITypeBinding b2= f2.resolveBinding().getType();