Class ConstrainedConstructionOrError
- All Implemented Interfaces:
Consumer<EK9Parser.CallContext>
🔑 This runs inside PreIRListener's walk, and that placement IS the feature. The
check previously had a walk of its own, so it could only ever see the token in front of it — which
is why it was literal-only. Sharing PreIRListener's walk gives it the live
ValueTrackingAnalyzer state, so a value that ARRIVES at the constructor is judged, however
it got there: assigned from a literal, carried through branches, or narrowed by a path condition
(if raw == UNDER_AGE narrows to a ConstantValue). The analyzer already models
branch join, try/catch edges, loops, unreachable arms and unknown assignments, so none of that has
to be re-derived here — an assignment the analyzer cannot evaluate becomes TOP and this check goes
quiet, which is exactly the required behaviour.
Conservative by construction. An error is emitted ONLY when the value is provably violating. Anything else — TOP, an unrenderable constant kind, a base type outside the numeric set below, any reflective failure — yields no error and the existing runtime check stands. A FALSE POSITIVE rejects a valid program, which is worse than missing a bug, so every uncertainty resolves to silence.
-
Field Summary
Fields inherited from class RuleSupport
errorListener, symbolsAndScopes -
Constructor Summary
ConstructorsConstructorDescriptionConstrainedConstructionOrError(SymbolsAndScopes symbolsAndScopes, ErrorListener errorListener, ValueTrackingAnalyzer valueTracker) -
Method Summary
Methods inherited from class TypedSymbolAccess
getRecordedAndTypedSymbol, isProcessingScopePure, recordATypedSymbol
-
Constructor Details
-
ConstrainedConstructionOrError
ConstrainedConstructionOrError(SymbolsAndScopes symbolsAndScopes, ErrorListener errorListener, ValueTrackingAnalyzer valueTracker)
-
-
Method Details
-
accept
- Specified by:
acceptin interfaceConsumer<EK9Parser.CallContext>
-