Files
swift-mirror/test/Concurrency/self_escapes_deinit.swift
Allan Shortlidge c02fc4724d Tests: Remove -disable-availability-checking from many Concurrency tests.
Instead, use the `%target-swift-5.1-abi-triple` substitution to compile the tests
for deployment to the minimum OS versions required for use of _Concurrency APIs.
2024-10-18 16:21:51 -07:00

38 lines
988 B
Swift

// RUN: %target-typecheck-verify-swift -strict-concurrency=complete -target %target-swift-5.1-abi-triple
@MainActor
class C {
let x: Int = 0
deinit {
// expected-warning@+1 {{capture of 'self' in a closure that outlives deinit; this is an error in the Swift 6 language mode}}
Task { @MainActor in
_ = self
}
// expected-warning@+1 {{capture of 'self' in a closure that outlives deinit; this is an error in the Swift 6 language mode}}
Task {
_ = x
}
}
}
func enqueueSomewhereElse(_ closure: @escaping @Sendable () -> Void) {}
@MainActor
class C2 {
let x: Int = 0
deinit {
// expected-warning@+1 {{capture of 'self' in a closure that outlives deinit; this is an error in the Swift 6 language mode}}
enqueueSomewhereElse {
_ = self
}
// expected-warning@+1 {{capture of 'self' in a closure that outlives deinit; this is an error in the Swift 6 language mode}}
enqueueSomewhereElse {
_ = self.x
}
}
}