Class SameRuntimeOperator
Some operators have more than one spelling: unary - and ~ are both negation, _negate
(OperatorMap.getPrefixForward(String); word not is a third spelling, but cannot be declared). Two such
declarations with the same parameter types are the same method once lowered, so they are judged by the runtime
name OperatorMap.resolvedMethodName(MethodSymbol) gives them - derived from the map, never a hand list of aliases.
D59 (2026-10-21): a class declaring both unary - and ~ compiled and failed at class load with
ClassFormatError: Duplicate method name "_negate", because the duplicate check matched EK9 names. Phase 2's
NoDuplicateOperationsOrError reports the second in one type, and phase 3's override check reports a
sub-type spelling an inherited operator differently (super ~, sub-type -), which compiled and ran
different code for -x and ~x. Both are E02030.
-
Method Summary
Modifier and TypeMethodDescriptionstatic booleandifferentSpellingsOfOne(MethodSymbol first, MethodSymbol second) Are these two operators, spelt differently, one runtime operator with the same parameter types?static Optional<MethodSymbol> otherSpellingIn(MethodSymbol operator, Iterable<MethodSymbol> candidates) The first ofcandidatesthat is a different spelling of the same runtime operator asoperator.static StringruntimeName(MethodSymbol operator) The runtime name of an operator, asOperatorMap.resolvedMethodName(MethodSymbol)gives it (arity-aware).
-
Method Details
-
differentSpellingsOfOne
Are these two operators, spelt differently, one runtime operator with the same parameter types?- Parameters:
first- an operatorsecond- another operator- Returns:
- true when both lower to the same runtime method and only the spelling differs
-
runtimeName
The runtime name of an operator, asOperatorMap.resolvedMethodName(MethodSymbol)gives it (arity-aware).- Parameters:
operator- an operator- Returns:
- its runtime method name
-
otherSpellingIn
public static Optional<MethodSymbol> otherSpellingIn(MethodSymbol operator, Iterable<MethodSymbol> candidates) The first ofcandidatesthat is a different spelling of the same runtime operator asoperator.- Parameters:
operator- the operator asked aboutcandidates- the operators to look through- Returns:
- the other spelling, if any
-