Class CovariantBridges

java.lang.Object
org.ek9lang.compiler.phase7.support.CovariantBridges
All Implemented Interfaces:
Consumer<IRModule>

public final class CovariantBridges extends Object implements Consumer<IRModule>
THE recording, in the IR, of an override's narrower (covariant) return - front-end rationalisation N07, Steve 2026-10-02: "this needs to be made clear at the IR generation level".

EK9 lets an override narrow its return type (make() <- rtn as Circle over a parent's <- rtn as Shape), and the object decides which method runs, never the reference or the return type. A JVM method's identity includes its return type, so without a bridge a call through the parent's type never reaches the override: the parent's body ran silently, or an abstract parent failed with AbstractMethodError. Each operation records the parent return types it narrows (OperationInstr.getBridgeReturnTypes()), computed here from the symbols by THE OverriddenDeclarations - the same lookup phase 3's override rule uses - so no back end re-derives it from the symbol table at code-generation time (which incremental builds could not see).

Hold one and give it each IR module. Idempotent: recomputed from the symbols each time. A method is looked at only if it is an override; a function only for its _call.

  • Constructor Details

    • CovariantBridges

      public CovariantBridges()
  • Method Details

    • accept

      public void accept(IRModule irModule)
      Record the narrowed return types on every operation of every construct of the module.
      Specified by:
      accept in interface Consumer<IRModule>