SLeeLa Constructor Series and Joining Structure
Purpose
Provide one authoritative model for constructor selection, constructor chaining, instance initialization, and allocation. The series joins constructor declarations into a validated initialization plan before IR lowering.
Joining sequence
type lookup -> constructor set -> overload resolution -> access/capability check -> allocation plan -> base/delegating constructor chain -> field initializers -> constructor body -> publish initialized instance
- Type lookup: resolve the declared type and its namespace.
- Constructor set: collect constructors visible for the selected type and language profile.
- Overload resolution: choose one best match using declared parameter types and language conversion rules. Ambiguity is an error.
- Validation: check visibility, capabilities, argument compatibility, and inheritance/base initialization rules.
- Chain planning: represent
this(...)delegation and base-constructor calls as explicit edges. - Cycle detection: reject constructor-delegation cycles.
- Initialization order: execute base initialization, instance field initializers, and the selected constructor body in the order defined by the language specification.
- Commit object state: publish the instance only after successful initialization; clean up allocation and owned resources on failure.
Invariants
- Exactly one constructor path initializes each required portion of the object.
- Delegation cycles are rejected before execution.
- No ambiguous overload is selected by arbitrary ordering.
new Type(args)and resolvedType(args)use the same constructor plan.- A failed constructor cannot expose a partially initialized instance.
- Constructor metadata records source location, parameter signature, visibility, and delegation target.
Intermediate representation
Represent the series as a directed graph with a single selected entry constructor. Each edge identifies a delegation or base-construction step. The graph must be acyclic; the lowering stage emits a deterministic initialization sequence from the validated graph.
Diagnostics
Report distinct errors for missing constructors, ambiguous overloads, inaccessible constructors, incompatible arguments, invalid base calls, delegation cycles, capability denial, allocation failure, and initialization failure.