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

Fix compiler concurrency issues #6843

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
2 changes: 1 addition & 1 deletion ios/MullvadREST/ApiHandlers/RESTNetworkOperation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import MullvadTypes
import Operations

extension REST {
class NetworkOperation<Success>: ResultOperation<Success> {
class NetworkOperation<Success>: ResultOperation<Success>, @unchecked Sendable {
private let requestHandler: RESTRequestHandler
private let responseHandler: any RESTResponseHandler<Success>

Expand Down
4 changes: 2 additions & 2 deletions ios/MullvadREST/Relay/RelaySelectorProtocol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public protocol RelaySelectorProtocol {
}

/// Struct describing the selected relay.
public struct SelectedRelay: Equatable, Codable {
public struct SelectedRelay: Equatable, Codable, Sendable {
/// Selected relay endpoint.
public let endpoint: MullvadEndpoint

Expand All @@ -43,7 +43,7 @@ extension SelectedRelay: CustomDebugStringConvertible {
}
}

public struct SelectedRelays: Equatable, Codable {
public struct SelectedRelays: Equatable, Codable, Sendable {
public let entry: SelectedRelay?
public let exit: SelectedRelay
public let retryAttempt: UInt
Expand Down
2 changes: 1 addition & 1 deletion ios/MullvadTypes/AnyIPEndpoint.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import Foundation
import protocol Network.IPAddress

public enum AnyIPEndpoint: Hashable, Equatable, Codable, CustomStringConvertible {
public enum AnyIPEndpoint: Hashable, Equatable, Codable, CustomStringConvertible, Sendable {
case ipv4(IPv4Endpoint)
case ipv6(IPv6Endpoint)

Expand Down
6 changes: 3 additions & 3 deletions ios/MullvadTypes/Cancellable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ public protocol Cancellable {
extension Operation: Cancellable {}

/// An object representing a cancellation token.
public final class AnyCancellable: Cancellable {
private let block: (() -> Void)?
public final class AnyCancellable: Cancellable, Sendable {
private let block: (@Sendable () -> Void)?

/// Create cancellation token with block handler.
public init(block: @escaping () -> Void) {
public init(block: @Sendable @escaping () -> Void) {
self.block = block
}

Expand Down
2 changes: 1 addition & 1 deletion ios/MullvadTypes/IPv4Endpoint.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import Foundation
import Network

public struct IPv4Endpoint: Hashable, Equatable, Codable, CustomStringConvertible {
public struct IPv4Endpoint: Hashable, Equatable, Codable, CustomStringConvertible, Sendable {
public let ip: IPv4Address
public let port: UInt16

Expand Down
2 changes: 1 addition & 1 deletion ios/MullvadTypes/IPv6Endpoint.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import Foundation
import Network

public struct IPv6Endpoint: Hashable, Equatable, Codable, CustomStringConvertible {
public struct IPv6Endpoint: Hashable, Equatable, Codable, CustomStringConvertible, Sendable {
public let ip: IPv6Address
public let port: UInt16

Expand Down
2 changes: 1 addition & 1 deletion ios/MullvadTypes/Location.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import CoreLocation
import Foundation

public struct Location: Codable, Equatable {
public struct Location: Codable, Equatable, Sendable {
public var country: String
public var countryCode: String
public var city: String
Expand Down
2 changes: 1 addition & 1 deletion ios/MullvadTypes/MullvadEndpoint.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import Foundation
import Network

/// Contains server data needed to connect to a single mullvad endpoint.
public struct MullvadEndpoint: Equatable, Codable {
public struct MullvadEndpoint: Equatable, Codable, Sendable {
public let ipv4Relay: IPv4Endpoint
public let ipv6Relay: IPv6Endpoint?
public let ipv4Gateway: IPv4Address
Expand Down
2 changes: 1 addition & 1 deletion ios/MullvadTypes/RelayConstraint.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import Foundation

private let anyConstraint = "any"

public enum RelayConstraint<T>: Codable, Equatable,
public enum RelayConstraint<T: Sendable>: Codable, Equatable, Sendable,
CustomDebugStringConvertible where T: Codable & Equatable {
case any
case only(T)
Expand Down
2 changes: 1 addition & 1 deletion ios/MullvadTypes/RelayConstraints.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import Foundation

public struct RelayConstraints: Codable, Equatable, CustomDebugStringConvertible {
public struct RelayConstraints: Codable, Equatable, CustomDebugStringConvertible, Sendable {
@available(*, deprecated, renamed: "locations")
private var location: RelayConstraint<RelayLocation> = .only(.country("se"))

Expand Down
4 changes: 2 additions & 2 deletions ios/MullvadTypes/RelayFilter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

import Foundation

public struct RelayFilter: Codable, Equatable {
public enum Ownership: Codable {
public struct RelayFilter: Codable, Equatable, Sendable {
public enum Ownership: Codable, Sendable {
case any
case owned
case rented
Expand Down
6 changes: 3 additions & 3 deletions ios/MullvadTypes/RelayLocation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import Foundation

public enum RelayLocation: Codable, Hashable, CustomDebugStringConvertible {
public enum RelayLocation: Codable, Hashable, CustomDebugStringConvertible, Sendable {
case country(String)
case city(String, String)
case hostname(String, String, String)
Expand Down Expand Up @@ -107,7 +107,7 @@ public enum RelayLocation: Codable, Hashable, CustomDebugStringConvertible {
}
}

public struct UserSelectedRelays: Codable, Equatable {
public struct UserSelectedRelays: Codable, Equatable, Sendable {
public let locations: [RelayLocation]
public let customListSelection: CustomListSelection?

Expand All @@ -118,7 +118,7 @@ public struct UserSelectedRelays: Codable, Equatable {
}

extension UserSelectedRelays {
public struct CustomListSelection: Codable, Equatable {
public struct CustomListSelection: Codable, Equatable, Sendable {
/// The ID of the custom list that the selected relays belong to.
public let listId: UUID
/// Whether the selected relays are subnodes or the custom list itself.
Expand Down
2 changes: 1 addition & 1 deletion ios/MullvadTypes/TransportLayer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import Foundation

public enum TransportLayer: Codable {
public enum TransportLayer: Codable, Sendable {
case udp
case tcp
}
8 changes: 8 additions & 0 deletions ios/MullvadVPN.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -6664,6 +6664,7 @@
SUPPORTS_MACCATALYST = NO;
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = YES;
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_STRICT_CONCURRENCY = targeted;
TARGETED_DEVICE_FAMILY = "1,2";
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
Expand Down Expand Up @@ -6703,6 +6704,7 @@
SUPPORTS_MACCATALYST = NO;
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = YES;
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_STRICT_CONCURRENCY = targeted;
TARGETED_DEVICE_FAMILY = "1,2";
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
Expand Down Expand Up @@ -6808,6 +6810,7 @@
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_PRECOMPILE_BRIDGING_HEADER = NO;
SWIFT_STRICT_CONCURRENCY = targeted;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
Expand Down Expand Up @@ -6866,6 +6869,7 @@
SWIFT_COMPILATION_MODE = wholemodule;
SWIFT_OPTIMIZATION_LEVEL = "-O";
SWIFT_PRECOMPILE_BRIDGING_HEADER = NO;
SWIFT_STRICT_CONCURRENCY = targeted;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
Expand Down Expand Up @@ -7510,6 +7514,7 @@
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_PRECOMPILE_BRIDGING_HEADER = NO;
SWIFT_STRICT_CONCURRENCY = targeted;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
Expand Down Expand Up @@ -7814,6 +7819,7 @@
SUPPORTS_MACCATALYST = NO;
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = YES;
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_STRICT_CONCURRENCY = targeted;
TARGETED_DEVICE_FAMILY = "1,2";
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
Expand Down Expand Up @@ -8350,6 +8356,7 @@
SWIFT_COMPILATION_MODE = wholemodule;
SWIFT_OPTIMIZATION_LEVEL = "-O";
SWIFT_PRECOMPILE_BRIDGING_HEADER = NO;
SWIFT_STRICT_CONCURRENCY = targeted;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
Expand Down Expand Up @@ -8650,6 +8657,7 @@
SUPPORTS_MACCATALYST = NO;
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = YES;
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_STRICT_CONCURRENCY = targeted;
TARGETED_DEVICE_FAMILY = "1,2";
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
Expand Down
2 changes: 1 addition & 1 deletion ios/MullvadVPN/Operations/ProductsRequestOperation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import Operations
import StoreKit

final class ProductsRequestOperation: ResultOperation<SKProductsResponse>,
SKProductsRequestDelegate {
SKProductsRequestDelegate, @unchecked Sendable {
private let productIdentifiers: Set<String>

private let maxRetryCount = 10
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import MullvadTypes
import Operations
import StoreKit

class SendStoreReceiptOperation: ResultOperation<REST.CreateApplePaymentResponse>, SKRequestDelegate {
class SendStoreReceiptOperation: ResultOperation<REST.CreateApplePaymentResponse>, SKRequestDelegate,
@unchecked Sendable {
private let apiProxy: APIQuerying
private let accountNumber: String

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import MullvadSettings
import MullvadTypes
import Operations

class LoadTunnelConfigurationOperation: ResultOperation<Void> {
class LoadTunnelConfigurationOperation: ResultOperation<Void>, @unchecked Sendable {
private let logger = Logger(label: "LoadTunnelConfigurationOperation")
private let interactor: TunnelInteractor

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import NetworkExtension
import Operations
import PacketTunnelCore

class MapConnectionStatusOperation: AsyncOperation {
class MapConnectionStatusOperation: AsyncOperation, @unchecked Sendable {
private let interactor: TunnelInteractor
private let connectionStatus: NEVPNStatus
private var request: Cancellable?
Expand Down
2 changes: 1 addition & 1 deletion ios/MullvadVPN/TunnelManager/RedeemVoucherOperation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import MullvadSettings
import MullvadTypes
import Operations

class RedeemVoucherOperation: ResultOperation<REST.SubmitVoucherResponse> {
class RedeemVoucherOperation: ResultOperation<REST.SubmitVoucherResponse>, @unchecked Sendable {
private let logger = Logger(label: "RedeemVoucherOperation")
private let interactor: TunnelInteractor

Expand Down
2 changes: 1 addition & 1 deletion ios/MullvadVPN/TunnelManager/RotateKeyOperation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import MullvadTypes
import Operations
import WireGuardKitTypes

class RotateKeyOperation: ResultOperation<Void> {
class RotateKeyOperation: ResultOperation<Void>, @unchecked Sendable {
private let logger = Logger(label: "RotateKeyOperation")
private let interactor: TunnelInteractor
private let devicesProxy: DeviceHandling
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ private let connectingStateWaitDelay: Duration = .seconds(5)
/// Default timeout in seconds.
private let defaultTimeout: Duration = .seconds(5)

final class SendTunnelProviderMessageOperation<Output>: ResultOperation<Output> {
final class SendTunnelProviderMessageOperation<Output>: ResultOperation<Output>, @unchecked Sendable {
typealias DecoderHandler = (Data?) throws -> Output

private let backgroundTaskProvider: BackgroundTaskProvider
Expand Down
2 changes: 1 addition & 1 deletion ios/MullvadVPN/TunnelManager/SetAccountOperation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ enum SetAccountAction {
}
}

class SetAccountOperation: ResultOperation<StoredAccountData?> {
class SetAccountOperation: ResultOperation<StoredAccountData?>, @unchecked Sendable {
private let interactor: TunnelInteractor
private let accountsProxy: RESTAccountHandling
private let devicesProxy: DeviceHandling
Expand Down
2 changes: 1 addition & 1 deletion ios/MullvadVPN/TunnelManager/StartTunnelOperation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import NetworkExtension
import Operations
import PacketTunnelCore

class StartTunnelOperation: ResultOperation<Void> {
class StartTunnelOperation: ResultOperation<Void>, @unchecked Sendable {
typealias EncodeErrorHandler = (Error) -> Void

private let interactor: TunnelInteractor
Expand Down
2 changes: 1 addition & 1 deletion ios/MullvadVPN/TunnelManager/StopTunnelOperation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import Foundation
import Operations

class StopTunnelOperation: ResultOperation<Void> {
class StopTunnelOperation: ResultOperation<Void>, @unchecked Sendable {
private let interactor: TunnelInteractor

init(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import MullvadSettings
import MullvadTypes
import Operations

class UpdateAccountDataOperation: ResultOperation<Void> {
class UpdateAccountDataOperation: ResultOperation<Void>, @unchecked Sendable {
private let logger = Logger(label: "UpdateAccountDataOperation")
private let interactor: TunnelInteractor
private let accountsProxy: RESTAccountHandling
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import MullvadTypes
import Operations
import WireGuardKitTypes

class UpdateDeviceDataOperation: ResultOperation<StoredDeviceData> {
class UpdateDeviceDataOperation: ResultOperation<StoredDeviceData>, @unchecked Sendable {
private let interactor: TunnelInteractor
private let devicesProxy: DeviceHandling

Expand Down
2 changes: 1 addition & 1 deletion ios/Operations/AsyncBlockOperation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import Foundation
import protocol MullvadTypes.Cancellable

/// Asynchronous block operation
public class AsyncBlockOperation: AsyncOperation {
public class AsyncBlockOperation: AsyncOperation, @unchecked Sendable {
private var executor: ((@escaping (Error?) -> Void) -> Cancellable?)?
private var cancellableTask: Cancellable?

Expand Down
2 changes: 1 addition & 1 deletion ios/Operations/AsyncOperation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import Foundation
}

/// A base implementation of an asynchronous operation
open class AsyncOperation: Operation {
open class AsyncOperation: Operation, @unchecked Sendable {
/// Mutex lock used for guarding critical sections of operation lifecycle.
private let operationLock = NSRecursiveLock()

Expand Down
2 changes: 1 addition & 1 deletion ios/Operations/AsyncOperationQueue.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import Foundation

public final class AsyncOperationQueue: OperationQueue {
public final class AsyncOperationQueue: OperationQueue, @unchecked Sendable {
override public func addOperation(_ operation: Operation) {
if let operation = operation as? AsyncOperation {
let categories = operation.conditions
Expand Down
4 changes: 2 additions & 2 deletions ios/Operations/BackgroundObserver.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@
}

public func didAttach(to operation: Operation) {
let expirationHandler = cancelUponExpiration ? { operation.cancel() } : nil
let expirationHandler: (@MainActor @Sendable () -> Void)? = { operation.cancel() }

taskIdentifier = backgroundTaskProvider.beginBackgroundTask(

Check failure on line 31 in ios/Operations/BackgroundObserver.swift

View workflow job for this annotation

GitHub Actions / Unit tests

type of expression is ambiguous without a type annotation
withName: name,
expirationHandler: expirationHandler
expirationHandler: cancelUponExpiration ? expirationHandler : nil
)
}

Expand Down
2 changes: 1 addition & 1 deletion ios/Operations/GroupOperation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import Foundation

public final class GroupOperation: AsyncOperation {
public final class GroupOperation: AsyncOperation, @unchecked Sendable {
private let operationQueue = AsyncOperationQueue()
private let children: [Operation]

Expand Down
2 changes: 1 addition & 1 deletion ios/Operations/ResultBlockOperation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import Foundation
import protocol MullvadTypes.Cancellable

public final class ResultBlockOperation<Success>: ResultOperation<Success> {
public final class ResultBlockOperation<Success>: ResultOperation<Success>, @unchecked Sendable {
private var executor: ((@escaping (Result<Success, Error>) -> Void) -> Cancellable?)?
private var cancellableTask: Cancellable?

Expand Down
2 changes: 1 addition & 1 deletion ios/Operations/ResultOperation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import Foundation

/// Base class for operations producing result.
open class ResultOperation<Success>: AsyncOperation, OutputOperation {
open class ResultOperation<Success>: AsyncOperation, OutputOperation, @unchecked Sendable {
public typealias CompletionHandler = (Result<Success, Error>) -> Void

private let nslock = NSLock()
Expand Down
Loading
Loading