Class ServiceReturnEscapeLinker

java.lang.Object
org.ek9lang.compiler.phase5.ServiceReturnEscapeLinker

final class ServiceReturnEscapeLinker extends Object
Links the escaping-return-value contract of service operations into the call graph.

A service operation (HTTP/runtime-dispatched root) returns a value whose declared type is a contract the runtime then drives — e.g. an HTTPResponse trait. The runtime, not user code, invokes that contract's API (status(), content(), contentType(), …) on the returned value to build the response. Those override implementations therefore have no user-code call site, so before this pass they appear as dead code (a false positive in find_unused_code).

This pass closes that gap, soundly and RTA-bounded. For every service operation whose return type R is an aggregate/trait, it links the operation to the override methods of R's contract on every allocated type that implements R:

  1. RTA filter — only types actually allocated in the program are considered, so an unused implementation of the contract is not resurrected.
  2. Assignability filterIAggregateSymbol.isImplementingInSomeWay(IAggregateSymbol) confines the link to types that genuinely implement/extend the returned contract.
  3. Contract filter — only methods that override a member declared through R are linked; a private helper on the implementing type stays dead.

The synthesised edges are polymorphic CallType.TRAIT_METHOD_CALL edges — the runtime dispatches across whatever concrete type flows to the return, which RTA over-approximates as the allocated implementors.

Ordering: this runs LAST in phase 5 — after the concurrency, assertion and DI analyses, immediately before the call graph is persisted. These edges are only a dead-code reachability device: the service operation does not itself call the overrides (the runtime does, per request, on a fresh response object), so feeding them into the operation's concurrent call-tree would raise spurious data-race errors (E08251) on per-request-local response state. Keeping the link out of those analyses, and in the persisted graph only, confines its effect to find_unused_code.

  • Constructor Details

    • ServiceReturnEscapeLinker

      ServiceReturnEscapeLinker(CallGraph callGraph)
  • Method Details

    • link

      void link()