Preparation
+ renamed the feature from "Statements before Super" to
"Flexible Constructor Bodies"
+ move the main flag, let ClassScope manage early construction contexts
Implement updates for JEP 482:
+ change wording towards "early construction context"
+ determine early-ctor-ctx based on target class
+ fine tuning:
- where should enclosing types be considered?
- search for enclosings first
but also consider their supers in a second round
+ reduce # mechanisms for detecting early construction context
+ allow assignment to fields of uninitialized instance
+ differentiate new errors:
- FieldReadInEarlyConstructionContext
- ThisInEarlyConstructionContext
- AllocationInEarlyConstructionContext
- MessageSendInEarlyConstructionContext
- DuplicateExplicitConstructorCall
- ConstructorCallNotAllowedHere
- SuperFieldAssignInEarlyConstructionContext
- AssignFieldWithInitializerInEarlyConstructionContext
+ generation of synth args and fields for enclosing instances
- such synthetics allow to skip over unavailable enclosing instances
towards outer instances that are available
Documentation of key strategies as javadoc / code comments:
+ enablement: JavaFeature.FLEXIBLE_CONSTRUCTOR_BODIES
2-step strategy
- does compliance generally allow the use of this feature?
already at this level we may suggest to enable the feature
- is the preview feature enabled?
+ detection / analysis: ClassScope.insideEarlyConstructionContext
- describes the combination of structural and temporary contexts
+ explicit vs implicit constructor calls: CD.resolveStatements()
- code comment describing updated contract of CD.constructorCall
+ code gen: TypeDeclaration.manageEnclosingInstanceAccessIfNecessary()
- code comment describing the strategy to generate synth args & fields
for various outer classes, which orchestrates code generation
Fixes https://github.com/eclipse-jdt/eclipse.jdt.core/issues/2472