Fix MistDemoApp build: explicit inits for NoteEditView & RecordDetailView#420
Conversation
…View (#419) NoteEditView and RecordDetailView mix non-private stored inputs with @State private / @Environment private state. Swift derives the synthesized memberwise initializer's access level from the most restrictive stored property, dropping the init to private. Both views are constructed from other files (QueryView.swift, RecordDetailView.swift), so under Swift 6.3.2 the compiler reports "cannot be constructed because it has no accessible initializers" (plus cascade errors inferring Mode for .create/.edit). Add an explicit internal init to each view exposing only the externally-set properties, mirroring CompositionDisclosure. RecordDetailView seeds its @State note through State(initialValue:). No call sites change. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
ReviewSmall, well-scoped fix — reviewed the diff and the two full view files. Correctness
Style/conventions
Scope
Test coverage
Nits (non-blocking)
Overall: LGTM. Nice, surgical fix with a clear explanation of the Swift access-level inference gotcha. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## v1.0.0-beta.3 #420 +/- ##
=================================================
+ Coverage 71.82% 73.68% +1.86%
=================================================
Files 168 156 -12
Lines 3844 3698 -146
=================================================
- Hits 2761 2725 -36
+ Misses 1083 973 -110
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Closes #419.
Problem
MistDemoAppfails to compile under Swift 6.3.2.NoteEditViewandRecordDetailVieweach mix a non-private stored input with@State private/@Environment privatestate. Swift derives the synthesized memberwise initializer's access level from the most restrictive stored property, so the private state drops the init toprivate. Both views are constructed from other files (QueryView.swift,RecordDetailView.swift), producing:Pre-existing on
v1.0.0-beta.3(andmain); surfaced by the Swift 6.3.2 toolchain. BecauseMistDemoAppis a separate SwiftPM product fromMistDemoKit, only a full-packageswift build/swift testfromExamples/MistDemotrips over it.Fix
Add an explicit
internal initto each view exposing only the externally-set properties, mirroring the existingCompositionDisclosurepattern.@State private/@Environmentmembers keep their inline defaults.RecordDetailViewseeds its@State noteviaState(initialValue:). No call sites change.Only these two views strictly break (non-private input + private state + cross-file construction). The parameterless views (
QueryView,RecordsView, etc.) construct via zero-argView()and compile fine — left untouched.Verification
From
Examples/MistDemo:swift build --target MistDemoApp— previously failed, now succeedsswift build(whole package) — succeedsswift test— 960 tests / 287 suites passswift-formatclean,swiftlint0 violations🤖 Generated with Claude Code