-
Notifications
You must be signed in to change notification settings - Fork 162
Fix compile error with final field assignment in constructor with prologue in local class in constructor #4701
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
f0b0f26 to
962c1d9
Compare
|
Two previous Jenkins build silently did nothing... I've manually triggered Jenkins build https://ci.eclipse.org/jdt/job/eclipse.jdt.core-Github/job/PR-4701/3/console If the problem persists, please file a ticket at https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/issues/ or ping me here. |
| AbstractMethodDeclaration method = this.methods[i]; | ||
| if (method.isConstructor()) { | ||
| FlowInfo ctorInfo = flowInfo.copy(); | ||
| FlowInfo ctorInfo = flowInfo.unconditionalFieldLessCopy(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool, this effectively fixes the issue, but something smells strangely here: the flow info that produced the bogus error concerned the field a of the outer class, i.e., we were actually misinterpreting the field index 0.
@coehlrich do you think we can streamline this code section wrt field of the enclosing class? See this comment few lines above:
// discards info about fields of inclosing classes
Given that no analysis within the current type should bother about fields of the enclosing class (?), could we find a single location for calling unconditionalFieldLessCopy() once and for all?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently internalAnalyseCode uses flowInfo without calling unconditionalFieldLessCopy in 5 locations:
- 2 times as arguments for
InitializationFlowContextwhich only uses it ingetInitsForFinalBlankInitializationCheckwhich also looks for the correct parent before returning the correspondingFlowInfo - 2 times for calls to
reachModewhich is copied when callingunconditionalFieldLessCopy - 1 time as an argument when calling
analyseCodeon all methods that aren't for initialization
None of the regression tests failed when adding flowInfo = flowInfo.unconditionalFieldLessCopy() to the top of internalAnalyseCode
While looking into this I did also notice that constructors with prologues aren't checked to see if all of the blank final fields have been initialized
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all uses of the methods relating to fields in FlowInfo in ast either only look at fields in the same class or have a check for if the current class is the same as the one containing the field with some also only calling it on the output of getInitsForFinalBlankInitializationCheck. for subclasses of FlowContext I couldn't get it to recognize final field assignments for the outer class in finally blocks or in the condition of a while loop (which still did give a compile error).
962c1d9 to
840812c
Compare
prologue in local class in constructor
840812c to
e2dd748
Compare
|
Jenkins had another issue with building this PR. For a while after the builds failed the https://ci.eclipse.org/jdt/ was timing out while https://ci.eclipse.org was fine. |
What it does
Fixes #4700
How to test
Attempt to compile
Author checklist