Class SamenessOrError
java.lang.Object
org.ek9lang.compiler.common.RuleSupport
org.ek9lang.compiler.common.TypedSymbolAccess
org.ek9lang.compiler.phase3.SamenessOrError
- All Implemented Interfaces:
Consumer<AggregateSymbol>
B18 - a type defines SAMENESS once (Steve, 2026-09-30). The rule is in
Sameness; this reports breaches:
- E07181 - a comparison with the type itself other than its sameness is written, or requested with an
explicit
default operator: they are always generated (==from<=>, and the rest). - E07182 - sameness declared by a type that inherits one WRITTEN BY HAND on an ABSTRACT base or a TRAIT (D24 rule 1; a defaulted one there is per concrete type, follow-up Q1): that is one sameness for the whole hierarchy, sealed where it is declared, because any sub-type refinement of a hierarchy-wide ordering is non-transitive once base and sub-type values mix. A CONCRETE type's sameness is its own (D24 rule 2): a sub-type may declare its own, and different run-time types are never the same.
- E07183 - abstract sameness: sibling implementations would order a mixed collection inconsistently, so the abstraction writes the body over its own abstract accessors.
- E07186 - a sub-type of an ORDERED type (its super has
<=>) that declares its own sameness as==only (D24 follow-up Q2): the inherited<=>compares only the super's fields, so the sub-type's==and<=>would disagree (==false,<=>0). It declares<=>instead, by hand ordefault operator <=>, and==is generated from it. - E07186 also - a BARE
default operatorwhose<=>cannot survive below an ORDERED super (D51, Steve 2026-10-21): a field of the sub-type has no<=>, so phase 5 would retract the generated<=>and leave the type with the==alone while its super is ordered - the very disagreement above, made silently. Asked here throughSameness.orderingSurvives(MethodSymbol, ISymbol), and the message names the field. - E07184 - a
#?that does not go with the sameness (hand-written with hand-written, defaulted with defaulted, inherited with inherited, none without) - and, where the sameness is declared, an ABSTRACT#?(C3, 2026-10-08), even on a field-less abstract root.
default operator are never reported: what the catch-all may produce is
decided by synthesis.-
Field Summary
Fields inherited from class RuleSupport
errorListener, symbolsAndScopes -
Constructor Summary
ConstructorsConstructorDescriptionSamenessOrError(SymbolsAndScopes symbolsAndScopes, ErrorListener errorListener) -
Method Summary
Methods inherited from class TypedSymbolAccess
emitTypeNotResolvedError, getRecordedAndTypedSymbol, isAlreadyInError, isProcessingScopePure, isPureReassignmentDisallowed, recordATypedSymbol
-
Constructor Details
-
SamenessOrError
SamenessOrError(SymbolsAndScopes symbolsAndScopes, ErrorListener errorListener)
-
-
Method Details
-
accept
- Specified by:
acceptin interfaceConsumer<AggregateSymbol>
-