Class OperationDeclarationChecks

java.lang.Object
org.ek9lang.compiler.common.OperationDeclarationChecks
All Implemented Interfaces:
BiConsumer<MethodSymbol, org.antlr.v4.runtime.ParserRuleContext>

public final class OperationDeclarationChecks extends Object implements BiConsumer<MethodSymbol, org.antlr.v4.runtime.ParserRuleContext>
THE checks every method and operator declaration gets - call this, never the rules one by one (front-end rationalisation F12/D5, Steve 2026-10-03). Methods and operators once ran the same rules through two copies in two orders; both now run them here, in this order - a method in phase 1 (ValidMethodOrError), an operator in phase 2 straight after its semantic checks (ValidOperatorOrError, which says why):
  1. in a trait, a constructor is an error and a member without a body is marked abstract (ProcessTraitMethodOrError); anywhere else, a member without a body must be abstract (TraitMethodAcceptableOrError);
  2. an abstract member has no body (AppropriateBodyOrError);
  3. a member is not both 'override' and 'abstract' (OverrideOrAbstractOrError);
  4. only a construct that can be extended declares an abstract member (ContextSupportsAbstractMethodOrError).

The order is observable: only the first error on a token is kept, the first three report on the member's own token and the last on the declaration's first token, which is the same token for a method with no modifier.

  • Constructor Details

    • OperationDeclarationChecks

      public OperationDeclarationChecks(SymbolsAndScopes symbolsAndScopes, ErrorListener errorListener)
      Create the checks for one listener's symbols and error listener.
  • Method Details

    • accept

      public void accept(MethodSymbol operation, org.antlr.v4.runtime.ParserRuleContext declaration)
      Check a method or operator declaration.
      Specified by:
      accept in interface BiConsumer<MethodSymbol, org.antlr.v4.runtime.ParserRuleContext>
      Parameters:
      operation - the method or operator symbol
      declaration - its methodDeclaration or operatorDeclaration