Fix build: annotate list-VM merge locals so .sorted infers its element

The generation-guard refactor moved the fetched.map{…}.sorted{…} chain into an
untyped `let merged`, dropping the type anchor the property assignment used to
provide. A multi-statement .map closure then leaves .sorted's $0 uninferred
(error: cannot infer type of closure parameter). Annotate merged in
OLTListViewModel and ONUListViewModel as [OLTStateDoc]/[ONUStateDoc].

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Jon Vanvik 2026-05-31 16:58:56 +02:00
parent 203465913c
commit 7d8f1c7b2d
2 changed files with 2 additions and 2 deletions

View file

@ -29,7 +29,7 @@ final class OLTListViewModel {
do { do {
let fetched = try await connection.olt.allStates() let fetched = try await connection.olt.allStates()
let names = (try? await connection.olt.nameMap()) ?? [:] let names = (try? await connection.olt.nameMap()) ?? [:]
let merged = fetched let merged: [OLTStateDoc] = fetched
.map { olt in var olt = olt; olt.resolvedName = names[olt.id]; return olt } .map { olt in var olt = olt; olt.resolvedName = names[olt.id]; return olt }
.sorted { $0.displayName.localizedCaseInsensitiveCompare($1.displayName) == .orderedAscending } .sorted { $0.displayName.localizedCaseInsensitiveCompare($1.displayName) == .orderedAscending }
guard gen == loadGeneration, !Task.isCancelled else { return } guard gen == loadGeneration, !Task.isCancelled else { return }

View file

@ -42,7 +42,7 @@ final class ONUListViewModel {
// Registration lives on OLT-STATE, operator names on ONU-CFG. Both best-effort. // Registration lives on OLT-STATE, operator names on ONU-CFG. Both best-effort.
let registration = (try? await connection.olt.registrationMap()) ?? [:] let registration = (try? await connection.olt.registrationMap()) ?? [:]
let names = (try? await connection.onu.nameMap()) ?? [:] let names = (try? await connection.onu.nameMap()) ?? [:]
let merged = fetched let merged: [ONUStateDoc] = fetched
.map { onu in .map { onu in
var onu = onu var onu = onu
onu.resolvedLifecycle = registration[onu.id] onu.resolvedLifecycle = registration[onu.id]