Files
swift-mirror/test/ClangImporter/objc_isolation_complete.swift
Henrik G. Olsson cbc0ec3b88 Add -verify-ignore-unrelated where necessary (NFC)
These are tests that fail in the next commit without this flag. This
does not add -verify-ignore-unrelated to all tests with -verify, only
the ones that would fail without it. This is NFC since this flag is
currently a no-op.
2025-10-04 14:19:52 -07:00

59 lines
1.7 KiB
Swift

// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -typecheck -I %S/Inputs/custom-modules %s -verify -verify-ignore-unrelated -strict-concurrency=complete -parse-as-library
// REQUIRES: objc_interop
// REQUIRES: concurrency
// REQUIRES: asserts
import Foundation
import ObjCConcurrency
// expected-note@+1 2{{add '@MainActor' to make global function 'unsatisfiedPreconcurrencyIsolation(view:)' part of global actor 'MainActor'}}
func unsatisfiedPreconcurrencyIsolation(view: MyView) {
// expected-warning@+1 {{call to main actor-isolated instance method 'display()' in a synchronous nonisolated context}}
view.display()
// expected-warning@+1 {{main actor-isolated property 'isVisible' can not be referenced from a nonisolated context}}
_ = view.isVisible
}
@preconcurrency @MainActor
class IsolatedSub: NXSender {
var mainActorState = 0 // expected-note {{property declared here}}
override func sendAny(_: any Sendable) -> any Sendable {
return mainActorState
// expected-warning@-1 {{main actor-isolated property 'mainActorState' can not be referenced from a nonisolated context}}
}
@MainActor
override func sendOptionalAny(_: (any Sendable)?) -> (any Sendable)? {
// expected-warning@-1 {{main actor-isolated instance method 'sendOptionalAny' has different actor isolation from nonisolated overridden declaration; this is an error in the Swift 6 language mode}}
return mainActorState
}
}
class NotSendable {}
@MainActor
class NSObjectInitOverride: NSObject {
var ns: NotSendable
override init() {
self.ns = NotSendable()
super.init()
}
}
@objc
@MainActor
class Test : NSObject {
static var shared: Test?
override init() {
super.init()
Self.shared = self
}
}