Files
swift-mirror/test/Concurrency/async_let_isolation.swift
Michael Gottesman df2844d267 [concurrency] Cleanup verify-additional-prefix usage in tests.
This includes a bunch of fixes. It is not exhaustive but fit my time boxed time
period I set aside to look at this today.

A quick non-exhaustive list:

1. I removed unnecessary verify-additional-prefix lines.
2. Split tests with typechecker error and non-typechecker error components.
3. Removed complete- lines that we used when testing w/without send
non sednable.
4. Translated complete-and-tns- lines to be just complete- since they are just
testing strict-concurrency=complete and we are not testing complete without
send non sendable anymore.
2025-08-12 10:56:02 -07:00

56 lines
1.7 KiB
Swift

// First without any concurrency enabled.
// RUN: %target-swift-frontend -target %target-swift-5.1-abi-triple %s -emit-sil -o /dev/null -verify -verify-additional-prefix without-transferring-
// Then with targeted.
// RUN: %target-swift-frontend -target %target-swift-5.1-abi-triple %s -emit-sil -o /dev/null -verify -strict-concurrency=targeted -verify-additional-prefix without-transferring-
// Then strict-concurrency with everything.
// RUN: %target-swift-frontend -target %target-swift-5.1-abi-triple %s -emit-sil -o /dev/null -verify -strict-concurrency=complete
// REQUIRES: concurrency
// REQUIRES: asserts
actor MyActor {
let immutable: Int = 17
var text: [String] = []
func synchronous() -> String { text.first ?? "nothing" }
func asynchronous() async -> String { synchronous() }
func testAsyncLetIsolation() async {
async let x = self.synchronous()
async let y = await self.asynchronous()
async let z = synchronous()
var localText = text
async let w = localText.removeLast() // expected-without-transferring-warning {{mutation of captured var 'localText' in concurrently-executing code}}
_ = await x
_ = await y
_ = await z
_ = await w
}
}
final class MyFinalActor {
let immutable: Int = 17
var text: [String] = []
func testAsyncLetIsolation() async {
var localText = text
async let w = localText.removeLast() // expected-without-transferring-warning {{mutation of captured var 'localText' in concurrently-executing code}}
_ = await w
}
}
func outside() async {
let a = MyActor()
async let x = a.synchronous() // okay, await is implicit
async let y = await a.synchronous()
_ = await x
_ = await y
}