Class OperatorTargetMethodResolver
aggregate.resolveMember(new MethodSymbolSearch(name)) silently gets wrong (see the
dual-glyph note below), and every phase-7 site that needs a resolved callee - whether to read its
defining type or to read its CallMetaDataDetails - must go through here.
Uses resolveMember with the argument types so SymbolMatcher finds the correct overload -
including coercible (promotable) matches, e.g. Float._addAss(Float) for f += celsius
where Celsius promotes to Float. The symbol table keys operator methods by EK9 name
(":=:"), so the JVM method name ("_copy") is reverse-mapped for the search. A
non-operator method name (e.g. iterator, hasNext) is searched as given.
Negate is dual-glyph. The JVM method _negate is aliased by TWO EK9 operators: ~
(declared by Boolean/Bits/List/Colour as operator ~) and the zero-arg unary - (declared
by the numeric types as operator -, split from binary _sub by arity in phase 2's
ValidOperatorOrError.minusOperatorOrError). OperatorMap.getBackward("_negate") only
yields ~ (the - key is taken by binary _sub), so a ~ search misses on a
numeric type whose negate is stored under -. This mirrors, in reverse, the one-way
-/not -> ~ normalisation that UnaryOperationGenerator does on the way
in: on a ~ miss for a zero-arg call, retry the unary -. A zero-parameter search matches
ONLY the unary - (SymbolMatcher rejects arity mismatch), never binary _sub.
Without this the dispatch/defining type silently falls back to the static receiver - correct for the
on-receiver common case, but a wrong, never-emitted symbol for an INHERITED numeric negate on the
eagerly-linked native back-end (the cea4d156c defining-type remedy otherwise no-ops here).
Not-equals is dual-glyph as well. <> and != both map to _neq;
OperatorMap.getBackward("_neq") yields != (registered last), but types DECLARE
operator <>, so a != miss retries <>. Without it every synthesised _neq
fell back to the static receiver - a never-emitted symbol for an INHERITED <> natively.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionResolve a method/operator on the target type, returning the resolved symbol itself (not just type names), so callers can read its defining type, return type and metadata rather than re-deriving them.declaredParameterTypes(ISymbol targetType, String methodName, List<ISymbol> argumentTypes) THE declared parameter types of the operator/method that actually serves a call - read off the RESOLVED member, never copied from the arguments.
-
Constructor Details
-
OperatorTargetMethodResolver
public OperatorTargetMethodResolver()
-
-
Method Details
-
apply
public Optional<ScopedSymbol> apply(ISymbol targetType, String methodName, List<ISymbol> argumentTypes) Resolve a method/operator on the target type, returning the resolved symbol itself (not just type names), so callers can read its defining type, return type and metadata rather than re-deriving them.- Parameters:
targetType- the type the call is made ON (a non-aggregate never resolves)methodName- the JVM method name (_copy) or the EK9 name (:=:) or a plain method name (iterator)argumentTypes- the resolved argument types, driving overload selection- Returns:
- the resolved method, or empty when the target is not an aggregate or declares no such member
-
declaredParameterTypes
public Optional<List<ISymbol>> declaredParameterTypes(ISymbol targetType, String methodName, List<ISymbol> argumentTypes) THE declared parameter types of the operator/method that actually serves a call - read off the RESOLVED member, never copied from the arguments. Use this - do not re-derive it. An operator may take a WIDER type than the argument (its trait, a super,Any), and the call must name the declared descriptor: naming the argument's type asks for a method that does not exist - aNoSuchMethodError C2._cmp(C3)on the JVM forc2 >? c3over a trait's<=>(B18 prerequisite P2), an undefined symbol natively. Shared by the synthesised comparisons, the Scenario-2 wrapper equality and comparison coalescing.- Parameters:
targetType- the type the call is made ONmethodName- the JVM or EK9 name, as forapply(ISymbol, String, List)argumentTypes- the resolved argument types- Returns:
- the declared parameter types, or empty when nothing resolves
-