Community
Participate
Working Groups
20041208 With the latest changes for type boxing (in N20041207) our tests for the assign compatibility fail: boolean b= true; Object o; o= b; // valid code, no compiler error but typeBindingOfB.isAssignCompatible(typeBindingOfO) is false
Autoboxing support is being added gradually.
Changed TypeBinding#isAssignmentCompatible(...) to check also if the argument is boxing compatible with the receiver. Added regression test CompatibilityRuleTests#test023().
Verified for 3.1 M4 using build I200412142000.
To verify it I've used ASTView 1.0.2 + following code: package b80455; public class Test { void foo() { Integer itg = new Integer(0); int ibt = 0; if (itg == ibt) System.out.println("equals"); } } + breakpoint in ASTViewLabelProvider.getText(Object obj) condition: ((ASTNode)obj).getNodeType() == ASTNode.IF_STATEMENT + code snippet in Debugger Display view: org.eclipse.jdt.core.dom.IfStatement ifStatement = (org.eclipse.jdt.core.dom.IfStatement) obj; org.eclipse.jdt.core.dom.InfixExpression expression = (org.eclipse.jdt.core.dom.InfixExpression) ifStatement.getExpression(); org.eclipse.jdt.core.dom.ITypeBinding leftBinding = expression.getLeftOperand().resolveTypeBinding(); org.eclipse.jdt.core.dom.ITypeBinding rightBinding = expression.getRightOperand().resolveTypeBinding(); rightBinding.isAssignmentCompatible(leftBinding);
Test can easilier be done using new feature of ASTView to compare bindings: - Select a binding and choose 'add to comparison tree' in the context menu - Then select the other binding you want to compare with the first one, - In the comparison tray you can see the result of the test Thanks Martin for the tip :-)