Files
swift-mirror/test/Concurrency/predates_concurrency_import_deinit.swift
Doug Gregor c326fd3db2 Respect @preconcurrency for instance properties of non-sendable types in deinit
Instance properties of non-sendable types cannot safely be
accessed within deinitializers. Make sure we respect `@preconcurrency`
when diagnosing these.
2024-05-16 22:42:54 -07:00

23 lines
872 B
Swift

// RUN: %empty-directory(%t)
// RUN: %target-swift-frontend -emit-module -emit-module-path %t/StrictModule.swiftmodule -module-name StrictModule -swift-version 6 %S/Inputs/StrictModule.swift
// RUN: %target-swift-frontend -emit-module -emit-module-path %t/NonStrictModule.swiftmodule -module-name NonStrictModule %S/Inputs/NonStrictModule.swift
// RUN: %target-swift-frontend -I %t %s -emit-sil -o /dev/null -verify -strict-concurrency=complete
// REQUIRES: concurrency
// REQUIRES: asserts
@preconcurrency import NonStrictModule
@preconcurrency import StrictModule
@available(SwiftStdlib 5.1, *)
actor ActorWithDeinit {
var ns: NonStrictClass = NonStrictClass()
var ss: StrictStruct = StrictStruct()
deinit {
print(ns)
print(ss) // expected-warning{{cannot access property 'ss' with a non-sendable type 'StrictStruct' from non-isolated deinit}}
}
}