Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update protocol usage to include 'any' keyword #6125

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions ios/MullvadVPN.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -6480,6 +6480,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
OTHER_SWIFT_FLAGS = "-enable-upcoming-feature ExistentialAny";
PRODUCT_BUNDLE_IDENTIFIER = "$(APPLICATION_IDENTIFIER)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
Expand All @@ -6501,6 +6502,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
OTHER_SWIFT_FLAGS = "-enable-upcoming-feature ExistentialAny";
PRODUCT_BUNDLE_IDENTIFIER = "$(APPLICATION_IDENTIFIER)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
Expand Down Expand Up @@ -7148,6 +7150,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
OTHER_SWIFT_FLAGS = "-enable-upcoming-feature ExistentialAny";
PRODUCT_BUNDLE_IDENTIFIER = "$(APPLICATION_IDENTIFIER)";
PRODUCT_NAME = "$(TARGET_NAME)";
"PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]" = "Mullvad VPN Development";
Expand Down Expand Up @@ -7761,6 +7764,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
OTHER_SWIFT_FLAGS = "-enable-upcoming-feature ExistentialAny";
PRODUCT_BUNDLE_IDENTIFIER = "$(APPLICATION_IDENTIFIER)";
PRODUCT_NAME = "$(TARGET_NAME)";
"PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]" = "Mullvad VPN Development";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ import MullvadTypes

/// A concrete implementation of an access method proxy configuration.
class ProxyConfigurationTester: ProxyConfigurationTesterProtocol {
private var cancellable: MullvadTypes.Cancellable?
private var cancellable: (any MullvadTypes.Cancellable)?
private let transportProvider: ProxyConfigurationTransportProvider
private var headRequest: REST.APIAvailabilityTestRequest?

init(transportProvider: ProxyConfigurationTransportProvider) {
self.transportProvider = transportProvider
}

func start(configuration: PersistentProxyConfiguration, completion: @escaping (Error?) -> Void) {
func start(configuration: PersistentProxyConfiguration, completion: @escaping ((any Error)?) -> Void) {
do {
let transport = try transportProvider.makeTransport(with: configuration)
let request = REST.APIAvailabilityTestRequest(transport: transport)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ protocol ProxyConfigurationTesterProtocol {
/// - Parameters:
/// - configuration: a proxy configuration.
/// - completion: a completion handler that receives `nil` upon success, otherwise the underlying error.
func start(configuration: PersistentProxyConfiguration, completion: @escaping (Error?) -> Void)
func start(configuration: PersistentProxyConfiguration, completion: @escaping ((any Error)?) -> Void)

/// Cancel testing proxy configuration.
func cancel()
Expand Down
12 changes: 6 additions & 6 deletions ios/MullvadVPN/AddressCacheTracker/AddressCacheTracker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ final class AddressCacheTracker {
private let application: UIApplication

/// REST API proxy.
private let apiProxy: APIQuerying
private let apiProxy: any APIQuerying

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

/// Timer used for scheduling periodic updates.
private var timer: DispatchSourceTimer?
private var timer: (any DispatchSourceTimer)?

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

/// Designated initializer
init(application: UIApplication, apiProxy: APIQuerying, store: REST.AddressCache) {
init(application: UIApplication, apiProxy: any APIQuerying, store: REST.AddressCache) {
self.application = application
self.apiProxy = apiProxy
self.store = store
Expand Down Expand Up @@ -84,8 +84,8 @@ final class AddressCacheTracker {
timer = nil
}

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

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

Expand Down
10 changes: 5 additions & 5 deletions ios/MullvadVPN/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
private(set) var addressCache: REST.AddressCache!

private var proxyFactory: REST.ProxyFactory!
private(set) var apiProxy: APIQuerying!
private(set) var accountsProxy: RESTAccountHandling!
private(set) var devicesProxy: DeviceHandling!
private(set) var apiProxy: (any APIQuerying)!
private(set) var accountsProxy: (any RESTAccountHandling)!
private(set) var devicesProxy: (any DeviceHandling)!

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

private(set) var accessMethodRepository = AccessMethodRepository()
private(set) var shadowsocksLoader: ShadowsocksLoaderProtocol!
private(set) var shadowsocksLoader: (any ShadowsocksLoaderProtocol)!
private(set) var configuredTransportProvider: ProxyConfigurationTransportProvider!
private(set) var ipOverrideRepository = IPOverrideRepository()

Expand Down Expand Up @@ -450,7 +450,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD

case let .failure(error):
let migrationUIHandler = application.connectedScenes
.first { $0 is SettingsMigrationUIHandler } as? SettingsMigrationUIHandler
.first { $0 is (any SettingsMigrationUIHandler) } as? any SettingsMigrationUIHandler

if let migrationUIHandler {
migrationUIHandler.showMigrationError(error) {
Expand Down
2 changes: 1 addition & 1 deletion ios/MullvadVPN/Classes/AutomaticKeyboardResponder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class AutomaticKeyboardResponder {
let fromCoordinateSpace = screen.coordinateSpace

// Get your view's coordinate space.
let toCoordinateSpace: UICoordinateSpace = targetView
let toCoordinateSpace: any UICoordinateSpace = targetView

// Convert the keyboard's frame from the screen's coordinate space to your view's coordinate space.
let convertedKeyboardFrameEnd = fromCoordinateSpace.convert(keyboardFrameEnd, to: toCoordinateSpace)
Expand Down
2 changes: 1 addition & 1 deletion ios/MullvadVPN/Classes/InputTextFormatter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ class InputTextFormatter: NSObject, UITextFieldDelegate, UITextPasteDelegate {
// MARK: - UITextPasteDelegate

func textPasteConfigurationSupporting(
_ textPasteConfigurationSupporting: UITextPasteConfigurationSupporting,
_ textPasteConfigurationSupporting: any UITextPasteConfigurationSupporting,
performPasteOf attributedString: NSAttributedString,
to textRange: UITextRange
) -> UITextRange {
Expand Down
4 changes: 2 additions & 2 deletions ios/MullvadVPN/Containers/CustomSplitViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ import UIKit

class CustomSplitViewController: UISplitViewController, RootContainment {
var preferredHeaderBarPresentation: HeaderBarPresentation {
for case let viewController as RootContainment in viewControllers {
for case let viewController as any RootContainment in viewControllers {
return viewController.preferredHeaderBarPresentation
}
return .default
}

var prefersHeaderBarHidden: Bool {
for case let viewController as RootContainment in viewControllers {
for case let viewController as any RootContainment in viewControllers {
return viewController.prefersHeaderBarHidden
}
return false
Expand Down
12 changes: 6 additions & 6 deletions ios/MullvadVPN/Containers/Root/RootContainerViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ class RootContainerViewController: UIViewController {
viewControllers.last
}

weak var delegate: RootContainerViewControllerDelegate?
weak var delegate: (any RootContainerViewControllerDelegate)?

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

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

configureViewControllers(
viewControllersToAdd: viewControllersToAdd,
Expand Down Expand Up @@ -741,20 +741,20 @@ class RootContainerViewController: UIViewController {
}

private func updateHeaderBarStyleFromChildPreferences(animated: Bool) {
if let conforming = topViewController as? RootContainment {
if let conforming = topViewController as? any RootContainment {
setHeaderBarPresentation(conforming.preferredHeaderBarPresentation, animated: animated)
}
}

private func updateDeviceInfoBarHiddenFromChildPreferences() {
if let conforming = topViewController as? RootContainment {
if let conforming = topViewController as? any RootContainment {
headerBarView.isDeviceInfoHidden = conforming.prefersDeviceInfoBarHidden
}
}

private func updateNotificationBarHiddenFromChildPreferences() {
if let notificationController,
let conforming = topViewController as? RootContainment {
let conforming = topViewController as? any RootContainment {
if conforming.prefersNotificationBarHidden {
removeNotificationController(notificationController)
} else {
Expand All @@ -766,7 +766,7 @@ class RootContainerViewController: UIViewController {
private func updateHeaderBarHiddenFromChildPreferences(animated: Bool) {
guard overrideHeaderBarHidden == nil else { return }

if let conforming = topViewController as? RootContainment {
if let conforming = topViewController as? any RootContainment {
setHeaderBarHidden(conforming.prefersHeaderBarHidden, animated: animated)
}
}
Expand Down
30 changes: 15 additions & 15 deletions ios/MullvadVPN/Coordinators/ApplicationCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,13 @@ final class ApplicationCoordinator: Coordinator, Presenting, RootContainerViewCo
private let storePaymentManager: StorePaymentManager
private let relayCacheTracker: RelayCacheTracker

private let apiProxy: APIQuerying
private let devicesProxy: DeviceHandling
private let accountsProxy: RESTAccountHandling
private var tunnelObserver: TunnelObserver?
private var appPreferences: AppPreferencesDataSource
private var outgoingConnectionService: OutgoingConnectionServiceHandling
private var accessMethodRepository: AccessMethodRepositoryProtocol
private let apiProxy: any APIQuerying
private let devicesProxy: any DeviceHandling
private let accountsProxy: any RESTAccountHandling
private var tunnelObserver: (any TunnelObserver)?
private var appPreferences: any AppPreferencesDataSource
private var outgoingConnectionService: any OutgoingConnectionServiceHandling
private var accessMethodRepository: any AccessMethodRepositoryProtocol
private let configuredTransportProvider: ProxyConfigurationTransportProvider
private let ipOverrideRepository: IPOverrideRepository

Expand All @@ -91,12 +91,12 @@ final class ApplicationCoordinator: Coordinator, Presenting, RootContainerViewCo
tunnelManager: TunnelManager,
storePaymentManager: StorePaymentManager,
relayCacheTracker: RelayCacheTracker,
apiProxy: APIQuerying,
devicesProxy: DeviceHandling,
accountsProxy: RESTAccountHandling,
outgoingConnectionService: OutgoingConnectionServiceHandling,
appPreferences: AppPreferencesDataSource,
accessMethodRepository: AccessMethodRepositoryProtocol,
apiProxy: any APIQuerying,
devicesProxy: any DeviceHandling,
accountsProxy: any RESTAccountHandling,
outgoingConnectionService: any OutgoingConnectionServiceHandling,
appPreferences: any AppPreferencesDataSource,
accessMethodRepository: any AccessMethodRepositoryProtocol,
transportProvider: ProxyConfigurationTransportProvider,
ipOverrideRepository: IPOverrideRepository

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

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

switch dismissedRoute.route {
case .outOfTime, .welcome:
guard let coordinator = dismissedRoute.coordinator as? Poppable else {
guard let coordinator = dismissedRoute.coordinator as? any Poppable else {
completion()
return assertionFailure("Expected presentable coordinator for \(dismissedRoute.route)")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import UIKit

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

init(
navigationController: UINavigationController,
interactor: CustomListInteractorProtocol,
interactor: any CustomListInteractorProtocol,
nodes: [LocationNode]
) {
self.navigationController = navigationController
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class AddLocationsViewController: UIViewController {
private let nodes: [LocationNode]
private let customList: CustomList

weak var delegate: AddLocationsViewControllerDelegate?
weak var delegate: (any AddLocationsViewControllerDelegate)?
private let tableView: UITableView = {
let tableView = UITableView()
tableView.separatorColor = .secondaryColor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ struct CustomListCellConfiguration {
contentValidationErrors: validationErrors
)

guard let cell = cell as? DynamicBackgroundConfiguration else { return }
guard let cell = cell as? any DynamicBackgroundConfiguration else { return }

cell.setAutoAdaptingBackgroundConfiguration(.mullvadListGroupedCell(), selectionType: .dimmed)
}
Expand Down Expand Up @@ -86,7 +86,7 @@ struct CustomListCellConfiguration {
contentConfiguration.text = itemIdentifier.text
cell.contentConfiguration = contentConfiguration

if let cell = cell as? CustomCellDisclosureHandling {
if let cell = cell as? any CustomCellDisclosureHandling {
cell.disclosureType = .chevron
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ protocol CustomListInteractorProtocol {
}

struct CustomListInteractor: CustomListInteractorProtocol {
let repository: CustomListRepositoryProtocol
let repository: any CustomListRepositoryProtocol

func fetchAll() -> [CustomList] {
repository.fetchAll()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ protocol CustomListViewControllerDelegate: AnyObject {
class CustomListViewController: UIViewController {
typealias DataSource = UITableViewDiffableDataSource<CustomListSectionIdentifier, CustomListItemIdentifier>

private let interactor: CustomListInteractorProtocol
private let interactor: any CustomListInteractorProtocol
private let tableView = UITableView(frame: .zero, style: .insetGrouped)
private let subject: CurrentValueSubject<CustomListViewModel, Never>
private var cancellables = Set<AnyCancellable>()
Expand Down Expand Up @@ -54,10 +54,10 @@ class CustomListViewController: UIViewController {
return barButtonItem
}()

weak var delegate: CustomListViewControllerDelegate?
weak var delegate: (any CustomListViewControllerDelegate)?

init(
interactor: CustomListInteractorProtocol,
interactor: any CustomListInteractorProtocol,
subject: CurrentValueSubject<CustomListViewModel, Never>,
alertPresenter: AlertPresenter
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class EditCustomListCoordinator: Coordinator, Presentable, Presenting {
}

let navigationController: UINavigationController
let customListInteractor: CustomListInteractorProtocol
let customListInteractor: any CustomListInteractorProtocol
let customList: CustomList
let nodes: [LocationNode]
let subject: CurrentValueSubject<CustomListViewModel, Never>
Expand All @@ -30,7 +30,7 @@ class EditCustomListCoordinator: Coordinator, Presentable, Presenting {

init(
navigationController: UINavigationController,
customListInteractor: CustomListInteractorProtocol,
customListInteractor: any CustomListInteractorProtocol,
customList: CustomList,
nodes: [LocationNode]
) {
Expand Down
Loading
Loading