Skip to content

Fix MistDemoApp build: explicit inits for NoteEditView & RecordDetailView#420

Merged
leogdion merged 1 commit into
v1.0.0-beta.3from
fix/mistdemo-app-view-inits
Jul 1, 2026
Merged

Fix MistDemoApp build: explicit inits for NoteEditView & RecordDetailView#420
leogdion merged 1 commit into
v1.0.0-beta.3from
fix/mistdemo-app-view-inits

Conversation

@leogdion

@leogdion leogdion commented Jul 1, 2026

Copy link
Copy Markdown
Member

Closes #419.

Problem

MistDemoApp fails to compile under Swift 6.3.2. NoteEditView and RecordDetailView each mix a non-private stored input with @State private / @Environment private state. Swift derives the synthesized memberwise initializer's access level from the most restrictive stored property, so the private state drops the init to private. Both views are constructed from other files (QueryView.swift, RecordDetailView.swift), producing:

'RecordDetailView' cannot be constructed because it has no accessible initializers
'NoteEditView' cannot be constructed because it has no accessible initializers
cannot infer contextual base in reference to member 'create' / 'edit'   # cascades

Pre-existing on v1.0.0-beta.3 (and main); surfaced by the Swift 6.3.2 toolchain. Because MistDemoApp is a separate SwiftPM product from MistDemoKit, only a full-package swift build / swift test from Examples/MistDemo trips over it.

Fix

Add an explicit internal init to each view exposing only the externally-set properties, mirroring the existing CompositionDisclosure pattern. @State private / @Environment members keep their inline defaults. RecordDetailView seeds its @State note via State(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-arg View() and compile fine — left untouched.

Verification

From Examples/MistDemo:

  • swift build --target MistDemoApp — previously failed, now succeeds
  • swift build (whole package) — succeeds
  • swift test — 960 tests / 287 suites pass
  • swift-format clean, swiftlint 0 violations

🤖 Generated with Claude Code

…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>
@coderabbitai

coderabbitai Bot commented Jul 1, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 78236998-a857-4cdf-b538-7a4939eac08a

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/mistdemo-app-view-inits

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@claude

claude Bot commented Jul 1, 2026

Copy link
Copy Markdown

Review

Small, well-scoped fix — reviewed the diff and the two full view files.

Correctness

  • Root cause analysis is accurate: Swift derives a synthesized memberwise initializer's access level from the most restrictive stored property, so the @State private / @Environment private members were dropping both inits to private, making the views un-constructible from other files. Adding an explicit internal init exposing only the externally-set properties is the right fix.
  • RecordDetailView's self._note = State(initialValue: note) correctly seeds the @State property wrapper's backing storage — this is the standard pattern for parameterizing @State via an explicit init.
  • Verified both call sites (QueryView.swift:52 and QueryView.swift:69, plus RecordDetailView.swift:78) match the new init signatures (mode:onSaved: and note:onChange:) — no call-site changes needed, as claimed.

Style/conventions

  • Matches the existing CompositionDisclosure pattern referenced in the PR description (explicit internal init placed after the property/computed-property declarations, before the private methods) — consistent with the SwiftLint type_contents_order convention noted in CLAUDE.md (initializer after instance properties, before methods).
  • No new imports needed; existing internal import modifiers untouched.

Scope

  • Correctly limited to the two views that actually break (non-private input + private state + cross-file construction). Good judgment call leaving the zero-arg-constructed views (QueryView, RecordsView, etc.) untouched rather than speculatively "fixing" things that already compile.

Test coverage

  • This is a compile-time access-level fix with no behavior change, so there isn't much to unit-test beyond "it builds." The PR description notes swift build --target MistDemoApp, full-package swift build/swift test (960 tests passing), swift-format, and swiftlint were all run locally — that's appropriate coverage for this kind of change. Nothing to add.

Nits (non-blocking)

  • None — the diff is about as tight as this fix could be.

Overall: LGTM. Nice, surgical fix with a clear explanation of the Swift access-level inference gotcha.

@codecov

codecov Bot commented Jul 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 73.68%. Comparing base (9894d48) to head (449ed8d).
⚠️ Report is 6 commits behind head on v1.0.0-beta.3.

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     
Flag Coverage Δ
mistdemo-spm-macos 11.19% <ø> (-0.23%) ⬇️
mistdemo-swift-6.2-jammy 11.19% <ø> (-0.23%) ⬇️
mistdemo-swift-6.2-noble 11.19% <ø> (-0.23%) ⬇️
mistdemo-swift-6.3-jammy 11.19% <ø> (-0.23%) ⬇️
mistdemo-swift-6.3-noble 11.19% <ø> (-0.23%) ⬇️
spm 71.60% <ø> (+0.08%) ⬆️
swift-6.1-jammy 71.54% <ø> (-0.19%) ⬇️
swift-6.1-noble 71.62% <ø> (-0.25%) ⬇️
swift-6.2-jammy 71.59% <ø> (-0.06%) ⬇️
swift-6.2-noble 71.76% <ø> (+0.16%) ⬆️
swift-6.3-jammy 71.51% <ø> (-0.03%) ⬇️
swift-6.3-noble 71.62% <ø> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@leogdion leogdion merged commit 0cdd108 into v1.0.0-beta.3 Jul 1, 2026
70 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant