You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Sealed base with explicitSubTypes emits subtype toJson/fromJson calls when generateJson is off (generated code does not compile) #159
A sealed base with explicitSubTypes generates a polymorphic changeTo dispatch that calls Subtype().toJson() / Subtype.fromJson(...) for every declared subtype — even when neither the base nor the subtypes enable generateJson. The generated part therefore fails to analyze/compile:
sealed.dart: undefined_instance_member_read — The member 'toJson' isn't defined for the type 'Circle'.
sealed.dart: undefined_instance_member_read — The member 'toJson' isn't defined for the type 'Square'.
sealed.dart: undefined_static_member_read — The class 'Circle' doesn't have a static member or constructor named 'fromJson'.
Generate with the 2.5.0 pipeline (resolved ClassElement -> ClassAnalyzer -> Orchestrator.generate) and analyze the output: the diagnostics above appear.
Why it was found now
The 2.5.0 analyze-clean release gate (zorphy/test/release/analyze_clean_gate_test.dart) re-analyzes generated output under the pinned analyzer (14.7.0). Previous releases only compared goldens, which never re-compiled the emitted source.
Expected
The subtype toJson/fromJson dispatch must only be emitted when the relevant JSON surface exists (base and/or subtypes with generateJson: true).
Impact
Any sealed hierarchy that does not use JSON generation produces uncompilable code. 2.5.0 keeps byte-identical output (this is a lib/ behavior change), so the gate documents the current behavior as a characterization test and this issue tracks the fix.
Note for whoever fixes this: PR #160 (2.5.0) adds zorphy/test/release/analyze_clean_gate_test.dart with a characterization test for exactly this shape — it asserts the current broken output (contains('toJson()') plus the undefined_instance_member_read / undefined_static_member_read diagnostics) so the fix cannot land silently. When you fix it, that test fails by design: move the _sealedNoJsonFixture into the strict zero-diagnostic group and delete the characterization test. The reason 2.5.0 only characterizes instead of fixing is that 2.5.0 must keep generated output byte-identical (a lib/ behavior change belongs in its own PR).
Activity
arrrrny commentedon Nov 16, 2026
✅ Forklift: shipped — #161
arrrrny commentedon Nov 16, 2026
Note for whoever fixes this: PR #160 (2.5.0) adds
zorphy/test/release/analyze_clean_gate_test.dartwith a characterization test for exactly this shape — it asserts the current broken output (contains('toJson()')plus theundefined_instance_member_read/undefined_static_member_readdiagnostics) so the fix cannot land silently. When you fix it, that test fails by design: move the_sealedNoJsonFixtureinto the strict zero-diagnostic group and delete the characterization test. The reason 2.5.0 only characterizes instead of fixing is that 2.5.0 must keep generated output byte-identical (alib/behavior change belongs in its own PR).fix: require a real base toJson before emitting changeTo (#161)
test: reconcile analyze-clean gate with 2.5.0 and apply dart format
Merge pull request #161 from arrrrny/fix/issue-159