Class DispatcherWinner

java.lang.Object
org.ek9lang.compiler.support.DispatcherWinner

public final class DispatcherWinner extends Object
THE single source of truth for "which handler WINS for this concrete type".

Third member of the dispatcher family, beside DispatcherHandlers (which handlers compete) and DispatcherReachableTypes (what types can arrive). Together the three answer the whole dispatch question, and they must be used together: a winner computed over a handler set or a type set that some other caller derived differently is a different dispatch model wearing the same name.

Selection rule. Lowest un-coerced assignment cost wins; a negative cost means "not assignable" and does not compete. Phase 5 (DispatcherAmbiguityOrError) has already rejected ties at equal cost, so for a program that compiles the winner is unique — the first-wins tie-break below is therefore unreachable in practice, and is kept only so this is total.

Why the cost comes back with the handler. Phase 7 needs only the winner, but a cost of exactly zero is what distinguishes a handler declared FOR this very type from one it merely inherits into — the DIRECT/INHERITED split the Oracle and IDE dispatcher views show. Recomputing that cost at the call site was how the previous copy drifted, so it is returned rather than left to be re-derived.

Deliberately ISymbol, not IAggregateSymbol. A dispatcher may route over a FUNCTION hierarchy, and FunctionSymbol is an IFunctionSymbol, NOT an IAggregateSymbol. Narrowing the parameter is precisely the defect that made a function handler silently unreachable in phase 5 and phase 7, and it had been re-made a third time in the Oracle extractor. Keep this signature wide.