Skip to content

Commit f1ad0a9

Browse files
author
Jon Petersson
committed
Update protocol usage to include 'any' keyword
1 parent 6973de9 commit f1ad0a9

File tree

87 files changed

+254
-250
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+254
-250
lines changed

ios/MullvadVPN.xcodeproj/project.pbxproj

+4
Original file line numberDiff line numberDiff line change
@@ -6480,6 +6480,7 @@
64806480
"$(inherited)",
64816481
"@executable_path/Frameworks",
64826482
);
6483+
OTHER_SWIFT_FLAGS = "-enable-upcoming-feature ExistentialAny";
64836484
PRODUCT_BUNDLE_IDENTIFIER = "$(APPLICATION_IDENTIFIER)";
64846485
PRODUCT_NAME = "$(TARGET_NAME)";
64856486
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
@@ -6501,6 +6502,7 @@
65016502
"$(inherited)",
65026503
"@executable_path/Frameworks",
65036504
);
6505+
OTHER_SWIFT_FLAGS = "-enable-upcoming-feature ExistentialAny";
65046506
PRODUCT_BUNDLE_IDENTIFIER = "$(APPLICATION_IDENTIFIER)";
65056507
PRODUCT_NAME = "$(TARGET_NAME)";
65066508
SWIFT_VERSION = 5.0;
@@ -7148,6 +7150,7 @@
71487150
"$(inherited)",
71497151
"@executable_path/Frameworks",
71507152
);
7153+
OTHER_SWIFT_FLAGS = "-enable-upcoming-feature ExistentialAny";
71517154
PRODUCT_BUNDLE_IDENTIFIER = "$(APPLICATION_IDENTIFIER)";
71527155
PRODUCT_NAME = "$(TARGET_NAME)";
71537156
"PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]" = "Mullvad VPN Development";
@@ -7761,6 +7764,7 @@
77617764
"$(inherited)",
77627765
"@executable_path/Frameworks",
77637766
);
7767+
OTHER_SWIFT_FLAGS = "-enable-upcoming-feature ExistentialAny";
77647768
PRODUCT_BUNDLE_IDENTIFIER = "$(APPLICATION_IDENTIFIER)";
77657769
PRODUCT_NAME = "$(TARGET_NAME)";
77667770
"PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]" = "Mullvad VPN Development";

ios/MullvadVPN/AccessMethodRepository/ProxyConfigurationTester.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ import MullvadTypes
1414

1515
/// A concrete implementation of an access method proxy configuration.
1616
class ProxyConfigurationTester: ProxyConfigurationTesterProtocol {
17-
private var cancellable: MullvadTypes.Cancellable?
17+
private var cancellable: (any MullvadTypes.Cancellable)?
1818
private let transportProvider: ProxyConfigurationTransportProvider
1919
private var headRequest: REST.APIAvailabilityTestRequest?
2020

2121
init(transportProvider: ProxyConfigurationTransportProvider) {
2222
self.transportProvider = transportProvider
2323
}
2424

25-
func start(configuration: PersistentProxyConfiguration, completion: @escaping (Error?) -> Void) {
25+
func start(configuration: PersistentProxyConfiguration, completion: @escaping ((any Error)?) -> Void) {
2626
do {
2727
let transport = try transportProvider.makeTransport(with: configuration)
2828
let request = REST.APIAvailabilityTestRequest(transport: transport)

ios/MullvadVPN/AccessMethodRepository/ProxyConfigurationTesterProtocol.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ protocol ProxyConfigurationTesterProtocol {
1515
/// - Parameters:
1616
/// - configuration: a proxy configuration.
1717
/// - completion: a completion handler that receives `nil` upon success, otherwise the underlying error.
18-
func start(configuration: PersistentProxyConfiguration, completion: @escaping (Error?) -> Void)
18+
func start(configuration: PersistentProxyConfiguration, completion: @escaping ((any Error)?) -> Void)
1919

2020
/// Cancel testing proxy configuration.
2121
func cancel()

ios/MullvadVPN/AddressCacheTracker/AddressCacheTracker.swift

+6-6
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ final class AddressCacheTracker {
2424
private let application: UIApplication
2525

2626
/// REST API proxy.
27-
private let apiProxy: APIQuerying
27+
private let apiProxy: any APIQuerying
2828

2929
/// Address cache.
3030
private let store: REST.AddressCache
@@ -36,7 +36,7 @@ final class AddressCacheTracker {
3636
private var lastFailureAttemptDate: Date?
3737

3838
/// Timer used for scheduling periodic updates.
39-
private var timer: DispatchSourceTimer?
39+
private var timer: (any DispatchSourceTimer)?
4040

4141
/// Operation queue.
4242
private let operationQueue = AsyncOperationQueue.makeSerial()
@@ -45,7 +45,7 @@ final class AddressCacheTracker {
4545
private let nslock = NSLock()
4646

4747
/// Designated initializer
48-
init(application: UIApplication, apiProxy: APIQuerying, store: REST.AddressCache) {
48+
init(application: UIApplication, apiProxy: any APIQuerying, store: REST.AddressCache) {
4949
self.application = application
5050
self.apiProxy = apiProxy
5151
self.store = store
@@ -84,8 +84,8 @@ final class AddressCacheTracker {
8484
timer = nil
8585
}
8686

87-
func updateEndpoints(completionHandler: ((Result<Bool, Error>) -> Void)? = nil) -> Cancellable {
88-
let operation = ResultBlockOperation<Bool> { finish -> Cancellable in
87+
func updateEndpoints(completionHandler: ((Result<Bool, any Error>) -> Void)? = nil) -> any Cancellable {
88+
let operation = ResultBlockOperation<Bool> { finish -> any Cancellable in
8989
guard self.nextScheduleDate() <= Date() else {
9090
finish(.success(false))
9191
return AnyCancellable()
@@ -121,7 +121,7 @@ final class AddressCacheTracker {
121121
return _nextScheduleDate()
122122
}
123123

124-
private func setEndpoints(from result: Result<[AnyIPEndpoint], Error>) {
124+
private func setEndpoints(from result: Result<[AnyIPEndpoint], any Error>) {
125125
nslock.lock()
126126
defer { nslock.unlock() }
127127

ios/MullvadVPN/AppDelegate.swift

+5-5
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
3131
private(set) var addressCache: REST.AddressCache!
3232

3333
private var proxyFactory: REST.ProxyFactory!
34-
private(set) var apiProxy: APIQuerying!
35-
private(set) var accountsProxy: RESTAccountHandling!
36-
private(set) var devicesProxy: DeviceHandling!
34+
private(set) var apiProxy: (any APIQuerying)!
35+
private(set) var accountsProxy: (any RESTAccountHandling)!
36+
private(set) var devicesProxy: (any DeviceHandling)!
3737

3838
private(set) var addressCacheTracker: AddressCacheTracker!
3939
private(set) var relayCacheTracker: RelayCacheTracker!
@@ -43,7 +43,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
4343
private let migrationManager = MigrationManager()
4444

4545
private(set) var accessMethodRepository = AccessMethodRepository()
46-
private(set) var shadowsocksLoader: ShadowsocksLoaderProtocol!
46+
private(set) var shadowsocksLoader: (any ShadowsocksLoaderProtocol)!
4747
private(set) var configuredTransportProvider: ProxyConfigurationTransportProvider!
4848
private(set) var ipOverrideRepository = IPOverrideRepository()
4949

@@ -450,7 +450,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
450450

451451
case let .failure(error):
452452
let migrationUIHandler = application.connectedScenes
453-
.first { $0 is SettingsMigrationUIHandler } as? SettingsMigrationUIHandler
453+
.first { $0 is (any SettingsMigrationUIHandler) } as? any SettingsMigrationUIHandler
454454

455455
if let migrationUIHandler {
456456
migrationUIHandler.showMigrationError(error) {

ios/MullvadVPN/Classes/AutomaticKeyboardResponder.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ class AutomaticKeyboardResponder {
8080
let fromCoordinateSpace = screen.coordinateSpace
8181

8282
// Get your view's coordinate space.
83-
let toCoordinateSpace: UICoordinateSpace = targetView
83+
let toCoordinateSpace: any UICoordinateSpace = targetView
8484

8585
// Convert the keyboard's frame from the screen's coordinate space to your view's coordinate space.
8686
let convertedKeyboardFrameEnd = fromCoordinateSpace.convert(keyboardFrameEnd, to: toCoordinateSpace)

ios/MullvadVPN/Classes/InputTextFormatter.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ class InputTextFormatter: NSObject, UITextFieldDelegate, UITextPasteDelegate {
186186
// MARK: - UITextPasteDelegate
187187

188188
func textPasteConfigurationSupporting(
189-
_ textPasteConfigurationSupporting: UITextPasteConfigurationSupporting,
189+
_ textPasteConfigurationSupporting: any UITextPasteConfigurationSupporting,
190190
performPasteOf attributedString: NSAttributedString,
191191
to textRange: UITextRange
192192
) -> UITextRange {

ios/MullvadVPN/Containers/CustomSplitViewController.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ import UIKit
1010

1111
class CustomSplitViewController: UISplitViewController, RootContainment {
1212
var preferredHeaderBarPresentation: HeaderBarPresentation {
13-
for case let viewController as RootContainment in viewControllers {
13+
for case let viewController as any RootContainment in viewControllers {
1414
return viewController.preferredHeaderBarPresentation
1515
}
1616
return .default
1717
}
1818

1919
var prefersHeaderBarHidden: Bool {
20-
for case let viewController as RootContainment in viewControllers {
20+
for case let viewController as any RootContainment in viewControllers {
2121
return viewController.prefersHeaderBarHidden
2222
}
2323
return false

ios/MullvadVPN/Containers/Root/RootContainerViewController.swift

+6-6
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ class RootContainerViewController: UIViewController {
115115
viewControllers.last
116116
}
117117

118-
weak var delegate: RootContainerViewControllerDelegate?
118+
weak var delegate: (any RootContainerViewControllerDelegate)?
119119

120120
override var childForStatusBarStyle: UIViewController? {
121121
topViewController
@@ -487,7 +487,7 @@ class RootContainerViewController: UIViewController {
487487
let viewControllersToRemove = viewControllers.filter { !newViewControllers.contains($0) }
488488

489489
// hide in-App notificationBanner when the container decides to keep it invisible
490-
isNavigationBarHidden = (targetViewController as? RootContainment)?.prefersNotificationBarHidden ?? false
490+
isNavigationBarHidden = (targetViewController as? any RootContainment)?.prefersNotificationBarHidden ?? false
491491

492492
configureViewControllers(
493493
viewControllersToAdd: viewControllersToAdd,
@@ -741,20 +741,20 @@ class RootContainerViewController: UIViewController {
741741
}
742742

743743
private func updateHeaderBarStyleFromChildPreferences(animated: Bool) {
744-
if let conforming = topViewController as? RootContainment {
744+
if let conforming = topViewController as? any RootContainment {
745745
setHeaderBarPresentation(conforming.preferredHeaderBarPresentation, animated: animated)
746746
}
747747
}
748748

749749
private func updateDeviceInfoBarHiddenFromChildPreferences() {
750-
if let conforming = topViewController as? RootContainment {
750+
if let conforming = topViewController as? any RootContainment {
751751
headerBarView.isDeviceInfoHidden = conforming.prefersDeviceInfoBarHidden
752752
}
753753
}
754754

755755
private func updateNotificationBarHiddenFromChildPreferences() {
756756
if let notificationController,
757-
let conforming = topViewController as? RootContainment {
757+
let conforming = topViewController as? any RootContainment {
758758
if conforming.prefersNotificationBarHidden {
759759
removeNotificationController(notificationController)
760760
} else {
@@ -766,7 +766,7 @@ class RootContainerViewController: UIViewController {
766766
private func updateHeaderBarHiddenFromChildPreferences(animated: Bool) {
767767
guard overrideHeaderBarHidden == nil else { return }
768768

769-
if let conforming = topViewController as? RootContainment {
769+
if let conforming = topViewController as? any RootContainment {
770770
setHeaderBarHidden(conforming.prefersHeaderBarHidden, animated: animated)
771771
}
772772
}

ios/MullvadVPN/Coordinators/ApplicationCoordinator.swift

+15-15
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,13 @@ final class ApplicationCoordinator: Coordinator, Presenting, RootContainerViewCo
7171
private let storePaymentManager: StorePaymentManager
7272
private let relayCacheTracker: RelayCacheTracker
7373

74-
private let apiProxy: APIQuerying
75-
private let devicesProxy: DeviceHandling
76-
private let accountsProxy: RESTAccountHandling
77-
private var tunnelObserver: TunnelObserver?
78-
private var appPreferences: AppPreferencesDataSource
79-
private var outgoingConnectionService: OutgoingConnectionServiceHandling
80-
private var accessMethodRepository: AccessMethodRepositoryProtocol
74+
private let apiProxy: any APIQuerying
75+
private let devicesProxy: any DeviceHandling
76+
private let accountsProxy: any RESTAccountHandling
77+
private var tunnelObserver: (any TunnelObserver)?
78+
private var appPreferences: any AppPreferencesDataSource
79+
private var outgoingConnectionService: any OutgoingConnectionServiceHandling
80+
private var accessMethodRepository: any AccessMethodRepositoryProtocol
8181
private let configuredTransportProvider: ProxyConfigurationTransportProvider
8282
private let ipOverrideRepository: IPOverrideRepository
8383

@@ -91,12 +91,12 @@ final class ApplicationCoordinator: Coordinator, Presenting, RootContainerViewCo
9191
tunnelManager: TunnelManager,
9292
storePaymentManager: StorePaymentManager,
9393
relayCacheTracker: RelayCacheTracker,
94-
apiProxy: APIQuerying,
95-
devicesProxy: DeviceHandling,
96-
accountsProxy: RESTAccountHandling,
97-
outgoingConnectionService: OutgoingConnectionServiceHandling,
98-
appPreferences: AppPreferencesDataSource,
99-
accessMethodRepository: AccessMethodRepositoryProtocol,
94+
apiProxy: any APIQuerying,
95+
devicesProxy: any DeviceHandling,
96+
accountsProxy: any RESTAccountHandling,
97+
outgoingConnectionService: any OutgoingConnectionServiceHandling,
98+
appPreferences: any AppPreferencesDataSource,
99+
accessMethodRepository: any AccessMethodRepositoryProtocol,
100100
transportProvider: ProxyConfigurationTransportProvider,
101101
ipOverrideRepository: IPOverrideRepository
102102

@@ -193,7 +193,7 @@ final class ApplicationCoordinator: Coordinator, Presenting, RootContainerViewCo
193193
context.dismissedRoutes.forEach { $0.coordinator.removeFromParent() }
194194

195195
case .selectLocation, .account, .settings, .changelog, .alert:
196-
guard let coordinator = dismissedRoute.coordinator as? Presentable else {
196+
guard let coordinator = dismissedRoute.coordinator as? any Presentable else {
197197
completion()
198198
return assertionFailure("Expected presentable coordinator for \(dismissedRoute.route)")
199199
}
@@ -205,7 +205,7 @@ final class ApplicationCoordinator: Coordinator, Presenting, RootContainerViewCo
205205

206206
switch dismissedRoute.route {
207207
case .outOfTime, .welcome:
208-
guard let coordinator = dismissedRoute.coordinator as? Poppable else {
208+
guard let coordinator = dismissedRoute.coordinator as? any Poppable else {
209209
completion()
210210
return assertionFailure("Expected presentable coordinator for \(dismissedRoute.route)")
211211
}

ios/MullvadVPN/Coordinators/CustomLists/AddCustomListCoordinator.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import UIKit
1313

1414
class AddCustomListCoordinator: Coordinator, Presentable, Presenting {
1515
let navigationController: UINavigationController
16-
let interactor: CustomListInteractorProtocol
16+
let interactor: any CustomListInteractorProtocol
1717
let nodes: [LocationNode]
1818
let subject = CurrentValueSubject<CustomListViewModel, Never>(
1919
CustomListViewModel(id: UUID(), name: "", locations: [], tableSections: [.name, .addLocations])
@@ -27,7 +27,7 @@ class AddCustomListCoordinator: Coordinator, Presentable, Presenting {
2727

2828
init(
2929
navigationController: UINavigationController,
30-
interactor: CustomListInteractorProtocol,
30+
interactor: any CustomListInteractorProtocol,
3131
nodes: [LocationNode]
3232
) {
3333
self.navigationController = navigationController

ios/MullvadVPN/Coordinators/CustomLists/AddLocationsViewController.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class AddLocationsViewController: UIViewController {
2020
private let nodes: [LocationNode]
2121
private let customList: CustomList
2222

23-
weak var delegate: AddLocationsViewControllerDelegate?
23+
weak var delegate: (any AddLocationsViewControllerDelegate)?
2424
private let tableView: UITableView = {
2525
let tableView = UITableView()
2626
tableView.separatorColor = .secondaryColor

ios/MullvadVPN/Coordinators/CustomLists/CustomListCellConfiguration.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ struct CustomListCellConfiguration {
4747
contentValidationErrors: validationErrors
4848
)
4949

50-
guard let cell = cell as? DynamicBackgroundConfiguration else { return }
50+
guard let cell = cell as? any DynamicBackgroundConfiguration else { return }
5151

5252
cell.setAutoAdaptingBackgroundConfiguration(.mullvadListGroupedCell(), selectionType: .dimmed)
5353
}
@@ -86,7 +86,7 @@ struct CustomListCellConfiguration {
8686
contentConfiguration.text = itemIdentifier.text
8787
cell.contentConfiguration = contentConfiguration
8888

89-
if let cell = cell as? CustomCellDisclosureHandling {
89+
if let cell = cell as? any CustomCellDisclosureHandling {
9090
cell.disclosureType = .chevron
9191
}
9292
}

ios/MullvadVPN/Coordinators/CustomLists/CustomListInteractor.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ protocol CustomListInteractorProtocol {
1515
}
1616

1717
struct CustomListInteractor: CustomListInteractorProtocol {
18-
let repository: CustomListRepositoryProtocol
18+
let repository: any CustomListRepositoryProtocol
1919

2020
func fetchAll() -> [CustomList] {
2121
repository.fetchAll()

ios/MullvadVPN/Coordinators/CustomLists/CustomListViewController.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ protocol CustomListViewControllerDelegate: AnyObject {
1919
class CustomListViewController: UIViewController {
2020
typealias DataSource = UITableViewDiffableDataSource<CustomListSectionIdentifier, CustomListItemIdentifier>
2121

22-
private let interactor: CustomListInteractorProtocol
22+
private let interactor: any CustomListInteractorProtocol
2323
private let tableView = UITableView(frame: .zero, style: .insetGrouped)
2424
private let subject: CurrentValueSubject<CustomListViewModel, Never>
2525
private var cancellables = Set<AnyCancellable>()
@@ -54,10 +54,10 @@ class CustomListViewController: UIViewController {
5454
return barButtonItem
5555
}()
5656

57-
weak var delegate: CustomListViewControllerDelegate?
57+
weak var delegate: (any CustomListViewControllerDelegate)?
5858

5959
init(
60-
interactor: CustomListInteractorProtocol,
60+
interactor: any CustomListInteractorProtocol,
6161
subject: CurrentValueSubject<CustomListViewModel, Never>,
6262
alertPresenter: AlertPresenter
6363
) {

ios/MullvadVPN/Coordinators/CustomLists/EditCustomListCoordinator.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class EditCustomListCoordinator: Coordinator, Presentable, Presenting {
1717
}
1818

1919
let navigationController: UINavigationController
20-
let customListInteractor: CustomListInteractorProtocol
20+
let customListInteractor: any CustomListInteractorProtocol
2121
let customList: CustomList
2222
let nodes: [LocationNode]
2323
let subject: CurrentValueSubject<CustomListViewModel, Never>
@@ -30,7 +30,7 @@ class EditCustomListCoordinator: Coordinator, Presentable, Presenting {
3030

3131
init(
3232
navigationController: UINavigationController,
33-
customListInteractor: CustomListInteractorProtocol,
33+
customListInteractor: any CustomListInteractorProtocol,
3434
customList: CustomList,
3535
nodes: [LocationNode]
3636
) {

0 commit comments

Comments
 (0)