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:
- E07170: No developer constructor at all — the developer must write one to initialise properties.
- 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 madeprivate(adefault private X()is fine — privacy blocks external uninitialised construction, internal use is the class's own responsibility), or the properties initialised at declaration.
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.
-
Field Summary
Fields inherited from class RuleSupport
errorListener, symbolsAndScopes -
Constructor Summary
ConstructorsConstructorDescriptionSuitablePropertyInitialisationOrError(SymbolsAndScopes symbolsAndScopes, ErrorListener errorListener) -
Method Summary
Methods inherited from class TypedSymbolAccess
getRecordedAndTypedSymbol, isProcessingScopePure, recordATypedSymbol
-
Constructor Details
-
SuitablePropertyInitialisationOrError
SuitablePropertyInitialisationOrError(SymbolsAndScopes symbolsAndScopes, ErrorListener errorListener)
-
-
Method Details
-
accept
-