Class HasRealComparator

java.lang.Object
org.ek9lang.compiler.common.HasRealComparator
All Implemented Interfaces:
Predicate<IAggregateSymbol>

public final class HasRealComparator extends Object implements Predicate<IAggregateSymbol>
THE shared test for "is this type orderable?" - does it have a REAL <=> operator, one it declares itself or inherits from a real (user) super, as opposed to only the degenerate Any._cmp that EVERY type inherits and which is not value ordering.

It walks the super chain with resolveInThisScopeOnly (declared-at-that-level only) and stops BEFORE Any. This is exactly why a direct list <=> list is rejected with E07620: List declares no <=> and Any._cmp does not count. Used to decide whether a default operator comparison (<=>,<,<=,>,>=) can be produced over a field of this type - reuse this, do not re-derive the "excludes Any._cmp" walk. Construct once with the resolved Any type.

This is now a thin "<=>" specialisation of HasRealOperator - the same walk generalised to any operator glyph (used for ==/$/#? by the equals/toString/hashCode generators). Kept as a named signpost because phase3/phase5 orderability checks refer to "the comparator predicate".

D55 (2026-10-20): a <=> the BARE default operator added counts only where it survives phase 5 (OrderingAvailability.orderingSurvives(MethodSymbol, ISymbol)) - its own fields orderable and the <=> above it surviving too. Before, a Holder whose field was such a Base kept its own bare <=>, and that called Base._cmp(Base), which phase 5 had retracted: a NoSuchMethodError at run time. The rule itself lives in Sameness; this class is its predicate form.

  • Constructor Details

    • HasRealComparator

      public HasRealComparator(ISymbol ek9Any)
  • Method Details

    • test

      public boolean test(IAggregateSymbol type)
      Specified by:
      test in interface Predicate<IAggregateSymbol>
    • allPropertiesOrderable

      public boolean allPropertiesOrderable(IAggregateSymbol aggregate)
      THE test that every property of the type has a REAL <=> (test(IAggregateSymbol)) - so a BARE default operator's <=> over them survives. Where one does not, phase 5 (DefaultComparatorRecheckOrError) retracts the bare ordering operators, and the type is equatable only.