Class InheritedOperatorOverFieldsOrError
- All Implemented Interfaces:
Consumer<AggregateSymbol>
$, $$ and :=:
when it would otherwise INHERIT one (E07238), as E07235 already requires of ?.
An inherited $, $$ or :=: was written for the super's fields; it cannot know the fields
this type adds. So Leaf extends Base with a name property and no $ of its own printed
Base(id=1) - the name silently missing - and its copy silently copied half the object. The type declares
its own: default operator $ (which folds in the nearest super's, C2 fix 1) or a hand-written one.
"Would inherit" is THE nearest operator above (InheritedOperators.nearestAbove(IAggregateSymbol, String, ISymbol): the super CLASS chain,
never Any's - every type inherits Any's $ and $$, which are not written for any
data), abstract or not: below an abstract one a sub-type's generated operator covers only its own fields, so a
type in between that adds fields and declares nothing would lose them. "Adds fields" is the type's own
GeneratedOperatorFields.of(AggregateSymbol) - properties, and a dynamic class's captures.
D24 follow-up Q5 (Steve, 2026-10-20): the same for SAMENESS on a CONCRETE type. A type that adds fields and would
inherit the super's <=> (an ordered super) or == (an equatable-only one), and its #?,
compared and hashed only the super's fields: Leaf(1, "x") == Leaf(1, "y") was TRUE, <=> 0 and the
hashes equal. D24's run-time-type check does not help - both values ARE Leafs. The type declares its own:
default operator <=> (or == below an equatable-only super), the bare default operator, or a
hand-written one with its hand-written #?. "Would inherit" is Sameness.nearestSurvivingSamenessAbove(IAggregateSymbol, ISymbol):
below a super whose bare <=> phase 5 retracts, that is its == (D55), so default operator ==
is what this error offers there.
Exempt: a type that declares sameness of its own (E07186 and E07184 judge it) and a type below sameness WRITTEN BY
HAND on an abstract base or a trait (Sameness.sealedSameness(IAggregateSymbol, ISymbol)): that is hierarchy-wide sameness, sealed
(E07182).
R15a (Steve, 2026-10-21): the sameness half applies to an ABSTRACT type too (the $ $$ :=: half always did).
Abstract Middle adding code below Base with a defaulted sameness gave
Leaf(1, "x") == Leaf(1, "y") TRUE: the inherited sameness never saw code. An abstract type then has
two choices, and the message names both: a sameness WRITTEN BY HAND is hierarchy-wide and sealed (P4: every
sub-type compares by it and may not declare its own), a DEFAULTED one is per-type (each concrete sub-type has its
own over all its fields).
? is E07235. One error per type, naming every operator it would inherit.
-
Field Summary
Fields inherited from class RuleSupport
errorListener, symbolsAndScopes -
Constructor Summary
ConstructorsConstructorDescriptionInheritedOperatorOverFieldsOrError(SymbolsAndScopes symbolsAndScopes, ErrorListener errorListener) -
Method Summary
Methods inherited from class TypedSymbolAccess
emitTypeNotResolvedError, getRecordedAndTypedSymbol, isAlreadyInError, isProcessingScopePure, isPureReassignmentDisallowed, recordATypedSymbol
-
Constructor Details
-
InheritedOperatorOverFieldsOrError
InheritedOperatorOverFieldsOrError(SymbolsAndScopes symbolsAndScopes, ErrorListener errorListener)
-
-
Method Details
-
accept
- Specified by:
acceptin interfaceConsumer<AggregateSymbol>
-