From 46db70d58ba29f4caef9be29d5c9ecf4ad9f5db3 Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Sat, 8 Oct 2022 11:45:02 -0400 Subject: [PATCH] Fix building in release mode When handleEvent dispatches to the other methods, it crashes the compiler during an optimization pass. Seems to be related to: https://github.com/apple/swift/issues/61350 --- Tusker.xcodeproj/project.pbxproj | 2 -- ...TimelineLikeCollectionViewController.swift | 21 -------------- Tusker/TimelineLikeController.swift | 28 +++++++++++++++++-- 3 files changed, 26 insertions(+), 25 deletions(-) diff --git a/Tusker.xcodeproj/project.pbxproj b/Tusker.xcodeproj/project.pbxproj index 13bbc456..7118f38e 100644 --- a/Tusker.xcodeproj/project.pbxproj +++ b/Tusker.xcodeproj/project.pbxproj @@ -2216,7 +2216,6 @@ MARKETING_VERSION = 2022.1; OTHER_CODE_SIGN_FLAGS = ""; OTHER_LDFLAGS = ""; - "OTHER_SWIFT_FLAGS[sdk=iphone*14*]" = "$(inherited) -D SDK_IOS_14"; PRODUCT_BUNDLE_IDENTIFIER = space.vaccor.Tusker; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -2245,7 +2244,6 @@ ); MARKETING_VERSION = 2022.1; OTHER_CODE_SIGN_FLAGS = ""; - "OTHER_SWIFT_FLAGS[sdk=iphone*14*]" = "$(inherited) -D SDK_IOS_14"; PRODUCT_BUNDLE_IDENTIFIER = space.vaccor.Tusker; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; diff --git a/Tusker/Screens/Utilities/TimelineLikeCollectionViewController.swift b/Tusker/Screens/Utilities/TimelineLikeCollectionViewController.swift index cfe9065b..281cdd15 100644 --- a/Tusker/Screens/Utilities/TimelineLikeCollectionViewController.swift +++ b/Tusker/Screens/Utilities/TimelineLikeCollectionViewController.swift @@ -63,27 +63,6 @@ extension TimelineLikeCollectionViewController { } } - func handleEvent(_ event: TimelineLikeController.Event) async { - switch event { - case .addLoadingIndicator: - await handleAddLoadingIndicator() - case .removeLoadingIndicator: - await handleRemoveLoadingIndicator() - case .loadAllError(let error, _): - await handleLoadAllError(error) - case .replaceAllItems(let items, _): - await handleReplaceAllItems(items) - case .loadNewerError(let error, _): - await handleLoadNewerError(error) - case .prependItems(let items, _): - await handlePrependItems(items) - case .loadOlderError(let error, _): - await handleLoadOlderError(error) - case .appendItems(let items, _): - await handleAppendItems(items) - } - } - func handleAddLoadingIndicator() async { var snapshot = dataSource.snapshot() if !snapshot.sectionIdentifiers.contains(.footer) { diff --git a/Tusker/TimelineLikeController.swift b/Tusker/TimelineLikeController.swift index 9f53e1ed..e64f5aa8 100644 --- a/Tusker/TimelineLikeController.swift +++ b/Tusker/TimelineLikeController.swift @@ -20,7 +20,14 @@ protocol TimelineLikeControllerDelegate: AnyObject { func canLoadOlder() async -> Bool - func handleEvent(_ event: TimelineLikeController.Event) async + func handleAddLoadingIndicator() async + func handleRemoveLoadingIndicator() async + func handleLoadAllError(_ error: Swift.Error) async + func handleReplaceAllItems(_ timelineItems: [TimelineItem]) async + func handleLoadNewerError(_ error: Swift.Error) async + func handlePrependItems(_ timelineItems: [TimelineItem]) async + func handleLoadOlderError(_ error: Swift.Error) async + func handleAppendItems(_ timelineItems: [TimelineItem]) async } private let logger = Logger(subsystem: Bundle.main.bundleIdentifier!, category: "TimelineLikeController") @@ -112,7 +119,24 @@ actor TimelineLikeController { private func emit(event: Event) async { precondition(state.canEmit(event: event)) - await delegate.handleEvent(event) + switch event { + case .addLoadingIndicator: + await delegate.handleAddLoadingIndicator() + case .removeLoadingIndicator: + await delegate.handleRemoveLoadingIndicator() + case .loadAllError(let error, _): + await delegate.handleLoadAllError(error) + case .replaceAllItems(let items, _): + await delegate.handleReplaceAllItems(items) + case .loadNewerError(let error, _): + await delegate.handleLoadNewerError(error) + case .prependItems(let items, _): + await delegate.handlePrependItems(items) + case .loadOlderError(let error, _): + await delegate.handleLoadOlderError(error) + case .appendItems(let items, _): + await delegate.handleAppendItems(items) + } } enum State: Equatable, CustomDebugStringConvertible {