eclipse-jdt / eclipse-jdt/eclipse.jdt.core
Incorrect error: Cannot instantiate local class 'I.IInner' in a static context
- Dominant language
- Java
- Stars
- 237
- Forks
- 195
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 47
Description
This ticket is to cover some loose ends in how ECJ handles requirement (or not) of enclosing instances: (JLS 8.1.3)
(1) Brought forward from https://github.com/eclipse-jdt/eclipse.jdt.core/pull/4020#issuecomment-2894376302
The following should compile, but doesn't:
```
public class C {
void q() {
interface I {
class IInner {}
static void p() {
new IInner();
}
}
}
}
```
(2) Brought forward from `https://github.com/eclipse-jdt/eclipse.jdt.core/issues/3687#issuecomment-2893086827`
While working on https://github.com/eclipse-jdt/eclipse.jdt.core/pull/4020 for https://github.com/eclipse-jdt/eclipse.jdt.core/issues/4015 I noticed that the call site of
org.eclipse.jdt.internal.compiler.problem.ProblemReporter.allocationInStaticContext(ASTNode, LocalTypeBinding) in org.eclipse.jdt.internal.compiler.ast.ReferenceExpression.resolveType(BlockScope) resembles org.eclipse.jdt.internal.compiler.ast.AllocationExpression.resolveType(BlockScope) before https://github.com/eclipse-jdt/eclipse.jdt.core/pull/3699
Should the PR https://github.com/eclipse-jdt/eclipse.jdt.core/pull/3699 also have accounted for ReferenceExpressions ?
Contributor guide
Assessment
This issue has not been assessed yet.