Package org.ek9lang.compiler.phase3


package org.ek9lang.compiler.phase3
G - Full Symbol Resolution can now take place.

If the EK9 developer has defined all the necessary symbols then this whole phase should be able to resolve them. This includes Parameterized Generic/Template types.

SymbolResolution is the main entry point for this phase. Most of the processing is delegated to ResolveDefineInferredTypeListener.

This now follows the same pattern as most of the other Listeners, using SymbolsAndScopes for handling scope traversals and locating recorded symbols and scopes.

This phase is quite complex because it involves processing 'calls' and 'expressions'. There are also lot's more rules that can now be applied, because all 'types' are present.

  • Class
    Description
    C' (Steve, 2026-10-08): an ABSTRACT $, $$ or #? declared on a type that HAS fields, counting inherited ones, is an error (E07185), reported at the abstract operator.
    Just gets the left and right hand side of values in an expression.
    Just gets both of the ternary expression parts (not the control).
    Check that a symbol can be accessed issues error if not possible.
    Data structure to facilitate checks on methods on an aggregate.
    Checks that all the text bodies that are on the super are also present in the language variant.
    Validates assertDoesNotThrow expression and sets the return type to Void.
    Validates assertPanic expression - the test-only counterpart to assertThrows that traps an org.ek9.lang::Panic.
    Checks that the assert statement actually has a boolean result from the expression.
    Validates assertThrows expression - checks that the type argument extends Exception and sets the return type of the expression to that exception type.
    Used to decouple checks from the grammar contexts.
    Just really pulls up the appropriate symbol from the expression into this context.
    Checks the assignments for operator : := = and :=? that's all.
    Used in the full resolution phase to check assignments.
    T8 (EK9_NATIVE_CYCLE_COLLECTOR_DESIGN.md §13.11): in a stream pipeline that contains an async stage, every function a stage is given is a concurrent entry point - not only the element functions the workers run.
    Designed to add in methods on the aggregate where the 'traits' use is 'traits by'.
    The ek9 developer does not need to redeclare incoming or returning parameters for dynamic functions.
    Designed to deal with this following part of the EK9 grammar.
    Blocks direct assignment from sanitized parameters to local variables.
    Decides THE capture constructor of a dynamic class, creating the sole synthetic constructor when it must.
    A dynamic function never re-points a variable it captured (E08280).
    THE phase-3 answer to "whose code is running here?" for a property field (a private property or a capture) - shared by the access check (E06180 in IdentifierReferenceOrError) and the "read it through a capture" wording of an unresolved name inside a dynamic body (IdentifierReferenceOrError, IdentifierOrError).
    A field of the code around a dynamic body, whether that body is a dynamic class's (else a function's), and whether the code around it is itself denied the field (a super's property, D81).
    Checks that methods from a super and one or more traits do not conflict.
    What an operator check needs: the operand, where the operator is used, and the operator search.
    The close operator is never called by EK9 code (E81060, Steve 2026-10-05, 2026-10-06).
    E07187 (D24 Q4 REVISED, Steve 2026-10-20): the comparison coalescing operators <? and >? select one operand by <=>.
    Given a symbol, this check that the type that the symbol has can support the '<=>' operator.
    Sets CONCURRENT_ENTRY_POINT = "TRUE" squirrelled data on function/method symbols passed as the handler argument to stdlib thread-spawning calls (TCP.accept, TCP.acceptUntilComplete, HTTP.serveUntilComplete, Signals.register) - a plain call (CallOrError) or a method call on a receiver (ObjectAccessExpressionOrError: the usual server.accept(handler) form, never marked before 2026-10-31).
    Checks that a specific constructor can be called on a particular type of Aggregate.
    Inside a constructor body, 'this' must not be passed as an argument to any NON-PURE call.
    Checks that an expression used as a control (if/else if, while, do/while, a ternary) is a condition: a Boolean, or a type that promotes to one with '#^'.
    Used for checking covariance based on a variable.
    Given a symbol, this check that the type that the symbol has can support the '--' operator.
    Checks that operators that have been 'defaulted' could actually be implemented.
    To be used when checking if a variable Symbol is a function delegate and can accept a set of call arguments.
    THE text of a denied bare-name reference (CaptureEvaluationScope.deniesAccessTo(ParseTree, ISymbol)), the same at every site: what was named and where it is declared - reference to 'name' on line: N:.
    Creates/Updates an ek9 Dict (Dictionary/Map) of a specific types if the expressions are typed correctly.
    A trait may not supply a dispatcher handler (E07825, front-end rationalisation D21, Steve 2026-10-20): a dispatcher and every one of its handlers live in one class hierarchy.
    Resolves the variables to be captured and defines new variable symbols against the appropriate scopes.
    The dynamic-class half of SuperConstructorAccessOrError (D98, fuzz6 2026-11-09).
    Checks if a dynamic function body is needed and provided, and that a body whose super returns a value can actually return it (not every path throws - E07380, as for a named function; front-end audit FE65).
    Creates/Updates an enumerated type adding methods as appropriate.
    THE places an enumeration TYPE (base or constrained, IsEnumerationType) may stand as an expression: the source of for x in Season and of cat Season, where the type means its values, and the receiver of an operator, whose own check reports E07630 ($Season, Season > x, either side of <? >? ?:).
    Checks that the symbol passed has a type and that the type is compatible with an EK9 Exception.
    Checks that an expression is a condition - a Boolean, or a type that promotes to one with '#^' (IsCondition, THE rule for every condition) - emitting ONLY_COMPATIBLE_WITH_BOOLEAN otherwise.
    Ensures that 'expression' is now resolved and 'typed' or a not resolved error.
    This listener just deals with expressions and the types that result from expressions.
    Useful in expressions to contain the left and right hand symbols.
    Deals with the for loop for phase 3, which is basically working out the type of the variable being iterated over and ensuring that the expression is something that can be iterated over.
    Pulls the type from the 'range' into the loop variable, so it is correctly typed or emits an error.
    Deals with checking the 'for' statement/expression.
    To be used when checking if a function can accept a set of call arguments.
    Check is the data passed in enabled a delegate function to be resolved and if so return that Function.
    Checks that the function correctly overrides the signature if it has a super.
    Attempts to locate an Trait by name.
    Given a 'type' (the IAggregateSymbol passed in), see it would be possible to iterator over it with some other type.
    Given a symbol, this check that the type that the symbol has can support the '#?' operator.
    Checks the possible operation variable, literal or function for suitability for use with 'head', 'tail' and 'skip'.
    Deals with the checking and setting initialised of the identifier.
    Used for pure identifier resolution and recording.
    Ensures that 'identifierReference' is now resolved and hangs together and is 'typed' or emit "not resolved" error.
    Checks the IfStatement is valid or emits errors.
    Given a symbol, this check that the type that the symbol has can support the '++' operator.
    C2 fix 2 (Steve, 2026-10-08): a type that ADDS fields must declare its own $, $$ and :=: when it would otherwise INHERIT one (E07238), as E07235 already requires of ?.
    An injected component is always set, so any check that it is set is always true - dead code that reads as though the injection might not arrive (E08266).
    Checks that variable only and variable declarations have symbols that have been referenced.
    THE rule for what a condition may be: can a value of this type (first argument) be a condition, given the Boolean type (second argument) - a Boolean, or a type that promotes to Boolean with '#^'.
    Checks if a type has the $ 'toString' method or a 'promotion' #^ to a String method.
    Checks that aggregates with properties/fields define their own '?' (isSet) operator.
    Given a symbol, this check that the type that the symbol has can support the '?' operation.
    THE access rule through a receiver: may the symbol be reached from the scope the access is made in.
    Checks the left hand side and the right hand side for assignment compatibility.
    Creates/Updates an ek9 list of a specific type if the expressions are typed correctly.
    THE declared (target) type of a List or Dict literal - use it, do not re-derive the walk.
    Outbound-encapsulation check: data inside a MutexLock must be purely contained — the lock holds the only reference to its protected payload.
    Returns the appropriate operator text symbol for the expression.
    THE one place a METHOD_AMBIGUOUS diagnostic is emitted in phase 3, and the only place its three message shapes are spelt.
    To be used when resolving a method by name and call arguments within a specific scope (an aggregate).
    Check overrides on methods.
    Create a MethodSearch symbol for an operation that could have a single expression or two expressions.
    Checks if a symbol can be mutated, this is nothing to do with a pure context.
    Inbound-encapsulation check on MutexLock(...) constructor calls.
    Restricts the construction of MutexLock to field initialisers on classes or components.
    As it is possible to have a variable that is a delegate 'function', it means that to call that function, the ek9 developer would use variable-name(parameters).
    THE check that an aggregate does not redeclare a property its super chain already declares - one rule for records, classes, components and dynamic classes (traits cannot declare properties, E07075).
    THE 'cannot call an abstract function or type' check (CANNOT_CALL_ABSTRACT_TYPE), with the located message.
    Records, on each conceptual T a resolved call carries, the ordering step the call is (D91 step 4), so a generic's own <=> that compares its T values through a call is judged as one that compares them directly (D89; read by TypeParameterOrderedInOwnComparison, judged by phase4/ParameterisedTypeOrError, E07188): a call of one of the generic's own methods - on itself or on another value of the same generic over the same parameters (other.itemOrder(this)), an override it declares included - hands every T on to that method's body; a call of a generic function (rankOf(item), its type inferred) hands each T on to the type parameter it is bound to, in the function's body; a T value given to a function delegate (a variable or property holding ordering() of T, or a function a call returned) is taken to be ordered there, whatever the delegate does: what it is cannot be known here (strict, as E06070). Only the steps from the generic's own <=> are followed, so recording a call anywhere else changes nothing.
    A resolved call: what it calls, whether that is a function delegate, and its arguments (needed only for a delegate).
    Records, on a conceptual T, that the body being resolved compares its values with <=> (item <=> other.item over item as T?) - one ordering step (D89, D91 step 4).
    Used where traits are implemented 'by' a variable.
    This is the second part of the method/function chaining resolution and can be recursive via objectAccess.
    Processes the Object Access start, this is the start of chained method/function calls.
    Used for resolving operation calls on aggregates, which can include properties that are delegates to functions.
    Provides a common set of operations for checking operators.
    THE body an ordering step is written in (D91 step 4): the named method or function around the code being resolved - a dynamic function inside it is part of it - and whether it is its generic's own hand-written self-comparison <=>, the only body whose steps are followed.
    The body, and whether it is its generic's own hand-written <=>.
    THE message prefix naming an own declaration and the other declaration it is paired with (an override and what it overrides, a dispatcher handler and its entry point): 'own' and 'other' <location>:.
    Used for checking parameter list types match.
    Checks the number and types of the two sets of parameter list match exactly.
    Process the stream pipeline part, ensuring that it can be resolved.
    Checks that the pre-flow expressions are valid.
    Ensures that 'primary' is now resolved and 'typed' or a not resolved error.
    Deals with checking the 'while' or 'do/while control variable in the statement/expression.
    Checks if there is any application associated with the program.
    Used for resolving and recoding of fields on specific types.
    For doing pure checks on method and functions.
    Checks if the pure modifier has been used correctly on methods and functions.
    Just check that with in the current 'context' - if pure that the processing call is pure.
    Checks the Range and ensures that there a Symbol recorded against that context.
    F1 (Steve, 2026-10-07): a record exists only to carry data, so a CONCRETE record with no fields, counting inherited ones, is an error (E07237).
    THE check of what a 'register' statement registers (decision 10, 2026-10-07).
    Stores registration data on the application symbol for both component and service registrations.
    To be used with operators on aggregates (except for the is-set ? operator, that has to deal with functions).
    Checks that the require statement actually has a boolean result from the expression.
    THE rule for when a write to a local resets its 'referenced' flag (E08090): a write is not a use.
    Used where traits are implemented 'by' a variable.
    This is a really critical point, because this attempts to ensure that ANY expression results in a symbol that has been 'typed'.
    Used for resolving a function (by just name) or a variable that is a function delegate.
    Check for valid function parameters.
    Locate a possible call to an identifierReference, so some sort of call.
    Resolves a method (by name and call arguments) within a given scope, emitting an error if it cannot be resolved or is ambiguous.
    Given a search for a method from an aggregate - and include supers/traits etc., this function will try and locate the method.
    Accesses the aggregate and gets just the 'default' operators defined on that aggregate (not any hierarchy).
    THE check that a for, while, switch or try is used correctly in or out of an expression: as a statement it must NOT have a returning section (it makes no sense), as an expression it MUST have one.
    B18 - a type defines SAMENESS once (Steve, 2026-09-30).
    Checks for inappropriate use of 'sanitized' at function/method call sites.
    Data holder for checking that an overriding declaration keeps every 'sanitized' parameter of the declaration it overrides.
    Checks that an overriding method or function keeps every 'sanitized' parameter of the declaration it overrides (E07940).
    Alters an 'Application' from being a general application to a service application when it registers a service.
    Looks at the returning param (if not null) and sets the symbol type as appropriate.
    Validates that the statement is OK and emits errors if this is not the case.
    Used in Stream assembly processing to check aggregate use validity.
    The construct for a Stream statement/expression.
    Processes/updates and checks that a stream assembly is actually viable in terms of types.
    Deals with working out what the type being 'catted' is.
    THE rule that a stream's element type is never closeable (E81073, Steve 2026-10-26, decision (a) of the closeables lane) - the stream analogue of E81061, which says a closeable is never a type argument.
    Now does the check/processing of the whole stream pipeline.
    Process and ensure that the stream termination can function correctly.
    Deals with working out what the type being "for'd" is.
    Checks that the arguments in the function are compatible with the current pipeline type.
    Used in Stream assembly processing to check function validity.
     
    Now does the check/processing of the whole stream pipeline.
    Process and ensure that the stream termination can function correctly.
    Every EK9 constructor chains to a super constructor: an explicit super(...), an explicit this(...) delegation, or - when neither is written - a hidden IMPLICIT super() to the super's no-arg constructor.
    Deals with checking if the switch can be used as an expression and whether the variable being switched on has the appropriate operators to meet the case criteria.
    Used when checking access to fields/properties and methods.
    Returns the appropriate symbol from the symbol and scope management component.
    Checks if a symbol has been referenced or not (can be null - no error).
    MULTI THREADED Now try and check that all symbols used have a type.
    Just extracts the ISymbols from the expression contexts and issues not resolved errors if any are not present.
    Provides the PossibleGenericSymbol type of the symbol if it has been typed, or empty.
    A text made with a plain String literal naming a language that has no defines text for block is an error (E07157, Steve 2026-11-02).
    Just focus on resolving 'this' or 'super' in respect to a 'call'.
    Checks and assigns type a 'this' or 'super' symbol, but only if it valid.
    Checks that the throw statement actually throws and Exception type.
    Checks that a trait access like T1.xyz() - is allowed i.e.
    Gets the abstract methods and then resolves each to see what the resulting method would be.
    Deals with checking the try statement/expression.
    TO be used when checking the left hand side and the right hand side with specific operators.
    Checks that any recursive type constraints on a type are valid.
    Checks the covariance compatibility of two variables, this will traverse them to get their types.
    Check that the types of two symbol ar compatible with each other.
    Check if any dispatcher methods on the aggregate and ensure that they are valid.
    Checks if a function extends another function and if it is abstract.
    If the Ek9 developer has used named parameters, then they must be validated.
    Checks on the assignment during a declaration and emits an error if not valid.
    Focus on checking a variable only declaration, now that types are all known.
    Checks if a symbol's type is Void and emits E10010 if so.
    Deals with checking the 'while' or 'do/while statement/expression.