Class Sameness
A type's SAMENESS is its <=> (an ordered type) or its == (an equatable-only type), chosen by the
author. Every other comparison with the type itself (== <> < <= >
>=) is generated from it, #? goes with it, and it is declared once per hierarchy, concretely.
🔑 SELF means "any type this type is assignable to" - itself, a super, a trait, Any. A
==(Any) or an override ==(Base) compares the type with itself as surely as ==(Self) does;
treating those as "other types" left the disagreement B18 removes reachable (Fable review F1). Operators taking a
genuinely unrelated type (==(Integer), <(Date)) are not self-comparisons.
-
Field Summary
FieldsModifier and TypeFieldDescriptionThe operators whose presence the type's sameness decides - never added by the baredefault operatorby name in phase 1, only once types are known (OperationFactory.completeSameness). -
Method Summary
Modifier and TypeMethodDescriptionstatic Optional<MethodSymbol> inheritedSameness(IAggregateSymbol aggregate, ISymbol ek9Any) The concrete sameness this type INHERITS - from its super chain (stopping beforeAny) or any of its traits (its own, a super's, a trait's trait) - if any.static booleanisDerivedComparison(IAggregateSymbol owner, MethodSymbol operator) True for a<><<=>>=comparing the owner with itself - always generated from the sameness, never written.static booleanisExplicitlyDefaulted(MethodSymbol operator) True for an explicitdefault operator X, as opposed to one added by the baredefault operator.static booleanisGenerated(MethodSymbol operator) True for a comparison generated from the type's sameness (never written or requested).static booleanisHandWritten(MethodSymbol operator) True when the developer wrote the operator's body (notdefault operator).static booleanisHashCode(MethodSymbol operator) True for the zero-argument#?.static booleanisSamenessOperator(IAggregateSymbol owner, MethodSymbol operator) True for a<=>or==comparing the owner with itself - a declaration of its sameness.static booleanisSelfComparison(IAggregateSymbol owner, MethodSymbol operator) True for an operator taking exactly one argument of a type the owner is assignable to.
-
Field Details
-
SAMENESS_FAMILY
-
-
Method Details
-
isSelfComparison
True for an operator taking exactly one argument of a type the owner is assignable to. -
isSamenessOperator
True for a<=>or==comparing the owner with itself - a declaration of its sameness. -
isDerivedComparison
True for a<><<=>>=comparing the owner with itself - always generated from the sameness, never written. -
isHashCode
True for the zero-argument#?. -
isHandWritten
True when the developer wrote the operator's body (notdefault operator). -
isExplicitlyDefaulted
True for an explicitdefault operator X, as opposed to one added by the baredefault operator. -
isGenerated
True for a comparison generated from the type's sameness (never written or requested). -
inheritedSameness
The concrete sameness this type INHERITS - from its super chain (stopping beforeAny) or any of its traits (its own, a super's, a trait's trait) - if any. Such a type may not declare sameness or#?of its own: the hierarchy's sameness is sealed where it is declared.DEFENSIVE: this runs at the end of EXPLICIT_TYPE_SYMBOL_DEFINITION, before TYPE_HIERARCHY_CHECKS reports a circular hierarchy, so it walks with its own visited set rather than
getAllTraits()(which recurses without one and overflowed on a loop). A broken hierarchy must neither error nor crash here.
-