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

49 lines
1.2 KiB
Swift

// RUN: %empty-directory(%t/src)
// RUN: split-file %s %t/src
/// Build the library A
// RUN: %target-swift-frontend -emit-module %t/src/A.swift \
// RUN: -target %target-swift-5.1-abi-triple -verify -verify-ignore-unrelated \
// RUN: -module-name A -swift-version 6 \
// RUN: -emit-module-path %t/A.swiftmodule
// Build the client
// RUN: %target-swift-frontend -emit-module %t/src/Client.swift \
// RUN: -target %target-swift-5.1-abi-triple -verify -verify-ignore-unrelated \
// RUN: -module-name Client -I %t -swift-version 6 \
// RUN: -emit-module-path %t/Client.swiftmodule
// REQUIRES: concurrency
//--- A.swift
@MainActor
public protocol P {}
@frozen
public struct ImplicitlySendable {
nonisolated public var prop: Bool = true
nonisolated public init() {}
}
public struct S: P {
nonisolated public var x: Int = 0
public var y: Int = 1
nonisolated public init() {}
}
//--- Client.swift
import A
actor A {
func test() {
var s = S()
s.x += 0 // okay
// expected-error@+1 {{main actor-isolated property 'y' can not be mutated on a nonisolated actor instance}}
s.y += 1
var sendable = ImplicitlySendable()
sendable.prop = false // okay
}
}