Class ExcessiveCallChainOrError

java.lang.Object
org.ek9lang.compiler.phase5.ExcessiveCallChainOrError
All Implemented Interfaces:
Consumer<EK9Parser.CallContext>

final class ExcessiveCallChainOrError extends Object implements Consumer<EK9Parser.CallContext>
Detects call chains deeper than one level (E11069).

EK9 supports single-level nested calls as idiomatic functional patterns: getTransformer("upper")("text") is clear — the reader can see getTransformer returns a delegate, and that delegate is called with "text".

However, deeper chaining like a()()()) forces inside-out mental evaluation and obscures the types flowing through the chain. This is the same readability problem as C's nested pointer dereferences.

The fix is always the same — extract an intermediate variable:

  //Rejected: too deep
  result <- getMaker("x")("seed")("text")

  //Accepted: clear intermediate
  maker <- getMaker("x")
  transformer <- maker("seed")
  result <- transformer("text")

Detection uses pure grammar structure: the call rule is recursive via alternative 6 (call paramExpression). If a call's inner call is itself a nested call (ctx.call().call() != null), the chain is 2+ levels deep.