eclipse-jdt / eclipse-jdt/eclipse.jdt.core
Change brought in by https://github.com/eclipse-jdt/eclipse.jdt.core/pull/1036 problematic
- Dominant language
- Java
- Stars
- 237
- Forks
- 195
- Avg merge
- 1d 10h
- Merged PRs (30d)
- 49
Description
The code change to ASTNode.java made for https://github.com/eclipse-jdt/eclipse.jdt.core/pull/1036 is problematic for the following reasons:
1. It fails to consider QAExpressions with anonymous type declarations. In the presence of anonymous class, `allocExp.resolvedType.isParameterizedTypeWithActualArguments()` would always yield `false` since `allocExp.resolvedType` will now be `$Local$` which itself is not a parameterized type - only its super may be parameterized with actual arguments
2. The code directly calls `scope.problemReporter().redundantSpecificationOfTypeArguments` without actually checking if diamond inference produces identical results to explicitly specified type arguments. It should in fact call `org.eclipse.jdt.internal.compiler.ast.AllocationExpression.reportTypeArgumentRedundancyProblem(ParameterizedTypeBinding, BlockScope)` so that the checks implemented in `org.eclipse.jdt.internal.compiler.ast.QualifiedAllocationExpression.diamondOperatorCanbeDeployed(BlockScope)` can verify whether it is safe to drop the type arguments and opt for diamond without silently changing the meaning of the program
3. Nowhere in this vicinity is there a check for denotability of type arguments - this can result in recommendations for <> which could then subsequently fails with `IProblem.NonDenotableTypeArgumentForAnonymousDiamond`
My amend to this code via https://github.com/srikanth-sankaran/eclipse.jdt.core/commit/d6d6fde5f70db06ca0505051d77e45866e1405b4.patch/ made on behalf of https://github.com/eclipse-jdt/eclipse.jdt.core/pull/1542 done for https://github.com/eclipse-jdt/eclipse.jdt.core/issues/1506 has the potential to trigger these problems plus also
```
https://bugs.eclipse.org/bugs/show_bug.cgi?id=579314 and
https://bugs.eclipse.org/bugs/show_bug.cgi?id=576002
```
as these involve invocation contexts.
Contributor guide
Assessment
This issue has not been assessed yet.