Class OrderingAvailability
java.lang.Object
org.ek9lang.compiler.support.sameness.OrderingAvailability
🛑 THE ONE question "can this
<=> (and the ordering built on it) be used?" (D55, D58, D62, D63, D71) -
orderingSurvives(MethodSymbol, ISymbol), bareOrderingRetracted(IAggregateSymbol, ISymbol), withdrawnOrdering(IAggregateSymbol, ISymbol) and
isUnavailableOrdering(MethodSymbol, ISymbol) with the readings built on them. EVERY use of <=> asks this class - hold
one; never a second "can this be ordered" predicate (E07620, NaturalOrderQueue, D63). The retraction step
that acts on the answer is RetractWithdrawnBareOrdering, its wording WhyNotOrderable.
All its answers read the methods as DECLARED, a retracted one included, so they are the same before, during and after phase 5's retraction pass, whatever order it visits the types in.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanallPropertiesOrderable(IAggregateSymbol aggregate, ISymbol ek9Any) THE "can every property of this type be ordered?" (isOrderable(IAggregateSymbol, ISymbol)for each property's type) - what a baredefault operator's<=>needs of its own fields.booleanbareOrderingRetracted(IAggregateSymbol owner, ISymbol ek9Any) THE retraction decision for a type's BARE ordering family (<=> < <= > >=added by the baredefault operator): its own bare<=>decides for the whole family throughorderingSurvives(MethodSymbol, ISymbol); without one (the ordering family alone, beside a hand-written<=>) the type's own properties decide.(package private) booleanconstrainedOverRetractedOrdering(IAggregateSymbol owner, ISymbol ek9Any) Is this a constrained type whose base's bare ordering is withdrawn? Its copied ordering operators are then withdrawn with it: a constrained type offers exactly the operators its base has (M1).booleanisDegenerateDefaultedOrdering(MethodSymbol operator, ISymbol ek9Any) A defaulted ordering operator on a type whose<=>degenerates because a field cannot be ordered - the case a generic instantiation reaches without any retraction marker:Box of List(its template'sdefault operator <=>is over aTthat became a List).booleanisOrderable(IAggregateSymbol type, ISymbol ek9Any) THE "is this type orderable?" behindHasRealComparator: the nearest<=>it declares or inherits (super chain beforeAny, then its traits) that survives (orderingSurvives(MethodSymbol, ISymbol)).booleanisRetractedOrdering(MethodSymbol operator, ISymbol ek9Any) Is this operator a BARE ordering operator that phase 5 retracts (bareOrderingRetracted(IAggregateSymbol, ISymbol)of its owner)? Order-independent, so usable from POST_RESOLUTION_CHECKS on: a generic's body that uses<=>or<onT, parameterised with a type whose ordering is retracted, is E07620 at the parameterisation (D58, Steve 2026-10-21).booleanisUnavailableOrdering(MethodSymbol operator, ISymbol ek9Any) THE verdict on a call of an ordering operator written as an operator (first < second, acase < x): the operator it resolved to is one phase 5 retracts (isRetractedOrdering(MethodSymbol, ISymbol)) or one that degenerates (isDegenerateDefaultedOrdering(MethodSymbol, ISymbol)).booleanorderingSurvives(MethodSymbol comparison, ISymbol ek9Any) THE "does this<=>still order values once PRE_IR_CHECKS has run?" (D55, Steve 2026-10-20).booleanorderingWithdrawn(IAggregateSymbol type, ISymbol ek9Any) Does a use that needs the type's<=>without naming it (sort,<?, a range) rely on an ordering that is not there: a withdrawn bare<=>(withdrawnOrdering(IAggregateSymbol, ISymbol)) or aDictEntrywhose key cannot be ordered (unorderedDictEntryKey(ISymbol, ISymbol))? THE test of phase 5'sRetractedComparatorUseOrError;WhyNotOrderablewords it.unorderedDictEntryKey(ISymbol type, ISymbol ek9Any) The key type that stops aDictEntry of (K, V)being ordered (Steve, 2026-10-21): a DictEntry orders by its KEY's<=>, then by its VALUE's when the keys are the same (the entries of one Dict have unique keys), so a key type that cannot be ordered (isOrderable(IAggregateSymbol, ISymbol); a function never can) leaves the entry unordered, and a comparator-lesssort,<?, range or natural-order queue over it is E07620 - not the run-time "Sort cannot order" Exception it was.unorderedPropertyBehind(MethodSymbol comparison, ISymbol ek9Any) THE reason a bare<=>does not survive: the first property, from the owner ofcomparisonupward through the<=>s each bare one builds on (read as DECLARED, so it answers the same after the retraction), whose type cannot be ordered (isOrderable(IAggregateSymbol, ISymbol)).withdrawnOrdering(IAggregateSymbol type, ISymbol ek9Any) THE "does a use of this type's<=>rely on an ordering that is withdrawn?" (D58, Steve 2026-10-21): the nearest<=>declared on the type or above it - the one phase 3 resolved the use to - is one the baredefault operatoradded, and it does not survive (orderingSurvives(MethodSymbol, ISymbol)).
-
Constructor Details
-
OrderingAvailability
public OrderingAvailability()
-
-
Method Details
-
orderingSurvives
THE "does this<=>still order values once PRE_IR_CHECKS has run?" (D55, Steve 2026-10-20). A<=>written by hand always does; an explicitdefault operator <=>does when every property can be ordered (it can fail to only in a generic, where a property is aTthat became a type with no<=>- D71). One the BAREdefault operatoradded survives only when every property of its owner can be ordered (HasRealComparator.allPropertiesOrderable(IAggregateSymbol)) AND the nearest<=>above it - the one its generated body calls for the inherited fields - survives too. Otherwise phase 5 retracts it, with the rest of the bare ordering family, and the type is equatable only: a sub-type follows its super. Below aBasewhose bare<=>is retracted (a field's type has==only), aLeaf's bare<=>once compared only Leaf's own fields -Leaf(1, "x") == Leaf(2, "x")was TRUE while their#?differed.Read by phase 5's retraction (
DefaultComparatorRecheckOrError), by E07186, E07190 and E07238 in phase 3, and byHasOwnComparator, so none of them can disagree about whether a type is ordered. The walk above reads the methods as DECLARED, a retracted one included, so the answer is the same before, during and after the retraction pass, whatever order it visits the types in.- Parameters:
comparison- a<=>comparing its owner with itselfek9Any- theAnytype, which never contributes- Returns:
- true when the comparison orders values after PRE_IR_CHECKS
-
isOrderable
THE "is this type orderable?" behindHasRealComparator: the nearest<=>it declares or inherits (super chain beforeAny, then its traits) that survives (orderingSurvives(MethodSymbol, ISymbol)). A bare one that does not survive is passed over, as if thedefault operatorhad never added it.- Parameters:
type- the type asked aboutek9Any- theAnytype, whose degenerate<=>never counts- Returns:
- true when values of the type can be ordered
-
allPropertiesOrderable
THE "can every property of this type be ordered?" (isOrderable(IAggregateSymbol, ISymbol)for each property's type) - what a baredefault operator's<=>needs of its own fields.- Parameters:
aggregate- the type whose properties are asked aboutek9Any- theAnytype- Returns:
- true when every property's type is orderable
-
bareOrderingRetracted
THE retraction decision for a type's BARE ordering family (<=> < <= > >=added by the baredefault operator): its own bare<=>decides for the whole family throughorderingSurvives(MethodSymbol, ISymbol); without one (the ordering family alone, beside a hand-written<=>) the type's own properties decide. Phase 5's retraction (RetractWithdrawnBareOrdering) acts on it, andisRetractedOrdering(MethodSymbol, ISymbol)answers the same question for one operator before or after that pass (D58), so a use and the retraction cannot disagree.- Parameters:
owner- the type whose bare ordering operators are asked aboutek9Any- theAnytype- Returns:
- true when the type's bare ordering operators are (or will be) retracted
-
isRetractedOrdering
Is this operator a BARE ordering operator that phase 5 retracts (bareOrderingRetracted(IAggregateSymbol, ISymbol)of its owner)? Order-independent, so usable from POST_RESOLUTION_CHECKS on: a generic's body that uses<=>or<onT, parameterised with a type whose ordering is retracted, is E07620 at the parameterisation (D58, Steve 2026-10-21).- Parameters:
operator- the operator a use resolved toek9Any- theAnytype- Returns:
- true when the operator will not be generated
-
constrainedOverRetractedOrdering
Is this a constrained type whose base's bare ordering is withdrawn? Its copied ordering operators are then withdrawn with it: a constrained type offers exactly the operators its base has (M1). -
isDegenerateDefaultedOrdering
A defaulted ordering operator on a type whose<=>degenerates because a field cannot be ordered - the case a generic instantiation reaches without any retraction marker:Box of List(its template'sdefault operator <=>is over aTthat became a List). Its==falls back to field by field and it has no ordering (B18 rule 8); without this,first < secondcompiled and was always UNSET.- Parameters:
operator- an operator a use resolved toek9Any- theAnytype- Returns:
- true when the operator is a defaulted ordering over a type that has no comparator of its own
-
withdrawnOrdering
THE "does a use of this type's<=>rely on an ordering that is withdrawn?" (D58, Steve 2026-10-21): the nearest<=>declared on the type or above it - the one phase 3 resolved the use to - is one the baredefault operatoradded, and it does not survive (orderingSurvives(MethodSymbol, ISymbol)). Every use that needs it without naming it -<?>?, asortstage with no comparator,x in a ... b, aforrange - asks here, after phase 5 has retracted it. It is NOTisOrderable(IAggregateSymbol, ISymbol): a sub-type whose own bare<=>is retracted below a super with a hand-written one is "orderable" through the super, yet the use resolved to the sub-type's own<=>(Sub), which is not generated (NoSuchMethodError) - the same answer the binary<gets from the retraction mark. Empty for any other type, so a type that never offered a bare ordering is never touched.- Parameters:
type- the type whose<=>a use needsek9Any- theAnytype- Returns:
- the withdrawn bare
<=>the use relied on, if any
-
unorderedDictEntryKey
The key type that stops aDictEntry of (K, V)being ordered (Steve, 2026-10-21): a DictEntry orders by its KEY's<=>, then by its VALUE's when the keys are the same (the entries of one Dict have unique keys), so a key type that cannot be ordered (isOrderable(IAggregateSymbol, ISymbol); a function never can) leaves the entry unordered, and a comparator-lesssort,<?, range or natural-order queue over it is E07620 - not the run-time "Sort cannot order" Exception it was. A conceptualTkey (inside a generic's body) never counts here: a generic body's ordering of a type BUILT ONT(DictEntry of (K, Integer)) is recorded in phase 3 (conceptual/NoteOrderingUse) and judged whereKis substituted (phase4/ParameterisedTypeOrError), by THIS verdict on the replaced type (D71, D63 residual).- Parameters:
type- the type asked about; anything but a parameterisation ofDictEntryanswers emptyek9Any- theAnytype- Returns:
- the key type that cannot be ordered, if any
-
orderingWithdrawn
Does a use that needs the type's<=>without naming it (sort,<?, a range) rely on an ordering that is not there: a withdrawn bare<=>(withdrawnOrdering(IAggregateSymbol, ISymbol)) or aDictEntrywhose key cannot be ordered (unorderedDictEntryKey(ISymbol, ISymbol))? THE test of phase 5'sRetractedComparatorUseOrError;WhyNotOrderablewords it.- Parameters:
type- the type whose<=>a use needsek9Any- theAnytype- Returns:
- true when the use is E07620
-
unorderedPropertyBehind
THE reason a bare<=>does not survive: the first property, from the owner ofcomparisonupward through the<=>s each bare one builds on (read as DECLARED, so it answers the same after the retraction), whose type cannot be ordered (isOrderable(IAggregateSymbol, ISymbol)).- Parameters:
comparison- a bare<=>ek9Any- theAnytype- Returns:
- the field and its owner, if one is found
-