Class NearestOperatorAbove

java.lang.Object
org.ek9lang.compiler.support.operators.NearestOperatorAbove

public final class NearestOperatorAbove extends Object
THE nearest operator ABOVE a type: the declaration a type would inherit, found by walking its super CLASS chain (never its traits) and stopping at the first level that declares it. Hold one and use it - never a walk of your own, and never a look at the immediate super alone.

C2 (Steve, 2026-10-08): the generated operators and their phase-3 check once asked only the IMMEDIATE super (resolveInThisScopeOnly). A field-less Middle between Base (which declares $) and Leaf (which defaults it) then gave a false E07190, so the middle had to declare the operator itself and added an empty layer (Leaf(Middle(Base(id=1)), name=leaf)). Every generated operator now calls the NEAREST implementation above, and names its OWNER (OperatorOwner) in the IR (CALL (Base)super._string()) so a back end never re-derives which class that is (Contract 19 in EK9_BACKEND_IR_CONTRACTS.md, the same shape as the close chain's CloseSteps#parentClose, which is built on this walk).

The walk returns the nearest declaration whatever it is - abstract, hand-written or defaulted - and the caller decides what that means (an abstract one has nothing to call). The family: NearestAbove (any level test), NearestSelfComparisonAbove (a sameness operator, by signature), AllOperatorsAbove (every one, for overriding each inherited signature), OperatorDeclarationSite (where a missing one belongs) and DeclaredOperator (one level's own).

  • Constructor Details

    • NearestOperatorAbove

      public NearestOperatorAbove()
  • Method Details

    • of

      public Optional<MethodSymbol> of(IAggregateSymbol aggregate, String operatorName, ISymbol ek9Any)
      The nearest operator called operatorName declared ABOVE the aggregate, never Any's: Any declares ? $ $$ #? == <=> for every type, which says nothing about a hierarchy's data. Where a level declares several overloads, the one taking that level itself is preferred (its self-comparison or copy).
      Parameters:
      aggregate - the type whose super chain is walked (the type itself is not consulted)
      operatorName - the operator, e.g. "$"
      ek9Any - the Any type, which is never an answer
      Returns:
      the nearest declaration, if any