| Summary: | [1.7] codeSelect doesn't resolve diamond type arguments in variable assignment | ||
|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Markus Keller <markus.kell.r> |
| Component: | Core | Assignee: | JDT-Core-Inbox <jdt-core-inbox> |
| Status: | CLOSED WONTFIX | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | amj87.iitr, daniel_megert |
| Version: | 3.7.1 | ||
| Target Milestone: | --- | ||
| Hardware: | PC | ||
| OS: | Windows 7 | ||
| Whiteboard: | stalebug | ||
|
Description
Markus Keller
Also happens for local variables, not only for fields:
void foo() {
HashMap<String, String> map = new HashMap<>(); // OK
map = new HashMap<>(); // codeSelect returns HashMap<Object, Object>
}
Problem is visible in ParameterizedGenericMethodBinding#computeCompatibleMethod(MethodBinding, TypeBinding[], Scope, InvocationSite), where the invocationSite doesn't have an typeExpected in the second case.
In the first case, the expected type is set from LocalDeclaration#resolve(BlockScope), but in the second case, the expected type stays null.
The cause is an incomplete AST in the codeSelect case. The statements of the MethodDeclaration are:
[0]= LocalDeclaration: HashMap<String, String> map;
[1]= SelectionOnQualifiedAllocationExpression: <SelectOnAllocationExpression:new HashMap<>()>
If I create a DOM AST, the second statement of the MethodDeclaration is:
[1]= Assignment: map = new HashMap<>()
In that case, "Assignment.resolveType(BlockScope) line: 198" sets the expected type.
=> I don't know where and why the SelectionParser drops the Assignment node, but that's the reason why the expected type is not available.
This is visible in the UI: The Javadoc hover on the rhs of the assignment shows wrong inferred types for the constructor invocation. This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug. If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant. -- The automated Eclipse Genie. |