eclipse-jdt / eclipse-jdt/eclipse.jdt.core

[Model][Records] Overeager call to `AbstractMethodDeclaration.isCanonicalConstructor()` in org.eclipse.jdt.internal.compiler.SourceElementNotifier.notifySourceElementRequestor(AbstractMethodDeclaration, TypeDeclaration, ImportReference)

Open
#4,222 1 comment 0 reactions 1 assignee Claimed by @srikanth-sankaran View on GitHub
Dominant language
Java
Stars
237
Forks
195
Avg merge
1d 12h
Merged PRs (30d)
47

Description

In the call stack below, there is a call to `AbstractMethodDeclaration.isCanonicalConstructor()` - purely from a merely parsed compilation unit (that is not resolved), it is not possible to definitively say whether a given constructor is a canonical constructor.

```
SourceElementNotifier.notifySourceElementRequestor(AbstractMethodDeclaration, TypeDeclaration, ImportReference) line: 324
SourceElementNotifier.notifySourceElementRequestor(CompilationUnitDeclaration, TypeDeclaration, boolean, TypeDeclaration, ImportReference) line: 818
SourceElementNotifier.notifySourceElementRequestor(CompilationUnitDeclaration, int, int, boolean, HashtableOfObjectToInt, Map) line: 491
SourceElementParser.parseCompilationUnit(ICompilationUnit, boolean, IProgressMonitor) line: 989
CompilationUnit.buildStructure(OpenableElementInfo, IProgressMonitor, Map, IResource) line: 279
CompilationUnit(Openable).generateInfos(IElementInfo, Map, IProgressMonitor) line: 250
CompilationUnit(JavaElement).openWhenClosed(IElementInfo, boolean, IProgressMonitor) line: 571
CompilationUnit.makeConsistent(int, boolean, int, Map, IProgressMonitor) line: 1262
CompilationUnit.makeConsistent(IProgressMonitor) line: 1242

```

The determination of whether a constructor is canonical happens ATM in `org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding.addRequiredSpecialRecordMethods()` well after parsing.

It may be possible to advance this a bit - but just parse won't do

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.