Package org.ek9lang.compiler.phase2
While there is focus on explicitly defined type usage, there is some simple inferred typing that is done for declared variables. This is very simple but useful in terms of properties and return variables.
NonInferredTypeDefinition is the main entry point here and it
delegates through to ResolveDefineExplicitTypeListener.
Again the SymbolsAndScopes class is used to manage the scopes.
The Symbols and scopes that were defined in phase3 are now looked up up using the
SymbolsAndScopes and in some cases augmented or in other cases checked.
Following the pass described above and second pass of the 'AST' is done using
TypeHierarchyChecks. This is focussed on checking for loops in type hierarchies.
See org.ek9lang.compiler.phase3 for the next stage of compilation.
-
ClassDescriptionResolves each class in an 'allowingOnly' list (checking it is a suitable CLASS genus) and registers it as an allowed extender of the supplied aggregate.Resolves each trait in a 'traitsList' (checking it is a suitable CLASS_TRAIT to extend) and adds it to the supplied aggregate.Completes every bare 'default operator' once types are known, after every source has been through EXPLICIT_TYPE_SYMBOL_DEFINITION (front-end audit FE74, F2).THE place a constrained type (
Age as Integer constrain as ..., or a plain aliasCoord as Point) gets its base's constructors, methods and operators cloned onto it - in TYPE_HIERARCHY_CHECKS.Gives every class, component and service with no fields, counting inherited ones, its synthesised '?' (FieldlessIsSet, Q-COMPONENT-?, Steve 2026-10-07), after every source has been through EXPLICIT_TYPE_SYMBOL_DEFINITION: supers are linked only then.A generic type's inferring constructor must take exactly its type parameters, in the same order - that is what lets 'Box(21)' infer 'Box of Integer'.Checks HTTP Access for service operations because some require HTTP_SOURCE, but others do not support it.Gives each sub-type that adds a handler to an INHERITED dispatcher its synthesised entry point (InheritedDispatcher, front-end rationalisation D2), after every source has been through EXPLICIT_TYPE_SYMBOL_DEFINITION: supers are linked and parameter types known only then.Sets theCONCURRENT_ENTRY_POINT = "TRUE"squirrelled marker on every non-constructor, non-operator, concrete method of the supplied aggregate.Examines all the service operations on a service and looks at the verbs used and the uri proto paths.Checks for duplicated trait names on an aggregate.Every LOCAL variable of a module checked against the methods of the type it is declared in - its own, inherited and from traits (seeNoNameCollisionOrError.errorsIfLocalNamedLikeAMethod(IAggregateSymbol, ISymbol)).SINGLE THREADED, for the same reason as SymbolDefinition: the parallel machinery was removed because definition serialises on the CompilableProgram lock.Checks that the variable supplied (if not null and has a type), does not have a type that is a genericTypeParameter.For Constrained Types, focus on checking it is possible to constrain the type and if so then clones the appropriate methods/operators over and alters the types as appropriate.What the bare-default and sameness post-passes at the end of EXPLICIT_TYPE_SYMBOL_DEFINITION act on, gathered in ONE walk per source rather than one walk each.A bare 'default operator' and the class, record, component or dynamic class that declares it.Configures a dynamic class in terms of settings its super and configured traits.Configures the dynamic function with it's 'super', but also checks that the super can be used in the way the EK9 source code has been defined.Configures a function's 'super' in the most appropriate way.Configures the trait declaration and completes a number of checks on that trait once configured.Adds various synthetic methods to type defined by the EK9 developer.Checks for inferred declarations of variables in various contexts.Deals with variable only declarations.Processes a variable declaration - attempts to resolve the variable type.A program can only accept specific types of arguments to it.A program can only return an Integer (exit code).A bit of a long-winded name, but this is really the second pass of the second phase of compilation.Completes every type's SAMENESS once types are known, after every source has been through EXPLICIT_TYPE_SYMBOL_DEFINITION (B18 - a type defines sameness once).Checks for inappropriate use of 'sanitized' in variable declarations.Validates that the 'sanitized' keyword is used correctly: 1.The Generic T used in parametric types will exist but won't have any methods on yet.THE place a sub-type (a class, record or component that 'extends'/'is' a super) gets its generated public no-argument constructor - after every source has been through EXPLICIT_TYPE_SYMBOL_DEFINITION, supers first.Checks for a type is resolved and is suitable to be extended from (in basic terms).Only types of a specific genus can be used as constraints on the generic type 'T'.Looks at the function and if it has no super function, attempts to work out what would be the best super function generic type it could implement.Some aggregates like classes, components, etc.SINGLE THREADED - Run across sources to check for types, functions and traits for 'super loops'.A generic's type parameter name must not resolve to ANYTHING (E01091) - not a built-in, not a construct of this module (even one declared later), not a function, not a constant.Checks each operator: first its operator SEMANTICS - arguments, return type and purity, which need resolved types, so this runs in phase 2 - then what every method and operator declaration is checked for (OperationDeclarationChecks, D5).Checks the PATH value (if this is a path parameter) and ensures that the name appears in the path itself on the operation.Check that a service operation complies with EK9 rules and return types etc.Does a simple check (excluding any inheritance) for visibility rules on methods/operators on aggregates.