Files
swift-mirror/test/Concurrency/import_nsnotificationname_constants_as_nonisolated.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

46 lines
1.2 KiB
Swift

// RUN: %empty-directory(%t/src)
// RUN: %empty-directory(%t/sdk)
// RUN: split-file %s %t/src
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -typecheck %t/src/main.swift \
// RUN: -import-objc-header %t/src/Test.h \
// RUN: -strict-concurrency=complete \
// RUN: -target %target-swift-5.1-abi-triple \
// RUN: -module-name main -I %t -verify
// REQUIRES: objc_interop
// REQUIRES: concurrency
//--- Test.h
#define SWIFT_MAIN_ACTOR __attribute__((swift_attr("@MainActor")))
#pragma clang assume_nonnull begin
@import Foundation;
SWIFT_MAIN_ACTOR
@interface Test : NSObject
@end
extern NSNotificationName const TestDidTrigger __attribute__((swift_name("Test.didTrigger")));
SWIFT_MAIN_ACTOR
extern NSNotificationName const TestIsolatedTrigger __attribute__((swift_name("Test.isolatedTrigger")));
#pragma clang assume_nonnull end
//--- main.swift
func testAsync() async {
print(Test.didTrigger) // Ok (property is nonisolated)
print(Test.isolatedTrigger)
// expected-warning@-1 {{expression is 'async' but is not marked with 'await'; this is an error in the Swift 6 language mode}}
// expected-note@-2 {{property access is 'async'}}
}
@MainActor
func testMainActor() {
print(Test.didTrigger) // Ok
print(Test.isolatedTrigger) // Ok
}