mirror of
https://github.com/icsharpcode/ILSpy.git
synced 2026-10-12 02:15:58 +00:00
A slot kind names one child position, so the generator emits a single typed Slots.X constant for it. A kind used with two different child types had to widen that constant to AstNode, and the typed GetChildren<T> accessor then cast the live AstNodeCollection<Concrete> to AstNodeCollection<AstNode> -- an InvalidCastException waiting for the first caller (latent today, but the model permitted it). Make the loose state unrepresentable instead of guarding it at runtime: DSTG001 errors when a [Slot] kind is declared with more than one child type. The six kinds that only coincidentally shared a name (Body, True, False, Initializer, SwitchSection, Variable) are split into precisely typed kinds; a genuinely either/or position (a lambda body) stays one declared type, AstNode. Every Slots.X now carries its real element type, so the GetChildren cast can no longer fail. Output is unchanged: the Pretty suite stays byte-identical with CheckInvariant green in DEBUG. Assisted-by: Claude:claude-opus-4-8:Claude Code