Class SuitablePropertyInitialisationOrError

java.lang.Object
org.ek9lang.compiler.common.RuleSupport
org.ek9lang.compiler.common.TypedSymbolAccess
org.ek9lang.compiler.phase5.SuitablePropertyInitialisationOrError
All Implemented Interfaces:
Consumer<org.antlr.v4.runtime.tree.ParseTree>

class SuitablePropertyInitialisationOrError extends TypedSymbolAccess implements Consumer<org.antlr.v4.runtime.tree.ParseTree>
Used with aggregates to check that if they have any properties that are not initialised at declaration the developer has taken appropriate steps to ensure initialisation. Two checks are made:
  1. E07170: No developer constructor at all — the developer must write one to initialise properties.
  2. E07175: A no-arg constructor that does not initialise the properties is still PUBLIC — allowing external code to create a partially-initialised object. This applies whether the no-arg constructor is compiler-synthetic OR a developer-written default X(). It must be made private (a default private X() is fine — privacy blocks external uninitialised construction, internal use is the class's own responsibility), or the properties initialised at declaration.
Properties whose type is a conceptual type parameter (value as T? in a generic type) are exempt — they cannot be initialised at declaration and a generic is required to carry a no-arg default constructor (E06040). See isConceptualTypeParameterTyped(ISymbol).

ABSTRACT aggregates are exempt from the E07175 "must be private" check: an abstract type cannot be constructed directly (E50080 / E10030), so a public no-arg constructor on it carries no external uninitialised-construction risk — it exists only for subclass super() chaining. The risk is checked at the concrete subclass instead.

  • Constructor Details

  • Method Details

    • accept

      public void accept(org.antlr.v4.runtime.tree.ParseTree node)
      Specified by:
      accept in interface Consumer<org.antlr.v4.runtime.tree.ParseTree>