Skip to content

Commit

Permalink
[NFC] Update concurrency validation test.
Browse files Browse the repository at this point in the history
  • Loading branch information
hborla committed May 16, 2024
1 parent e044e3d commit 1b0dca0
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions validation-test/Sema/SwiftUI/rdar76252310.swift
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
// RUN: %target-typecheck-verify-swift -target %target-cpu-apple-macosx10.15 -swift-version 5 -strict-concurrency=targeted
// RUN: %target-typecheck-verify-swift -target %target-cpu-apple-macosx10.15 -swift-version 5 -strict-concurrency=complete

// REQUIRES: objc_interop
// REQUIRES: OS=macosx

import SwiftUI

class Visibility: ObservableObject { // expected-note 2{{class 'Visibility' does not conform to the 'Sendable' protocol}}
@MainActor
class Visibility: ObservableObject {
nonisolated init() {}

@Published var yes = false // some nonsense
}

struct CoffeeTrackerView: View { // expected-note 4{{consider making struct 'CoffeeTrackerView' conform to the 'Sendable' protocol}}
struct CoffeeTrackerView: View {
nonisolated init() {}

@ObservedObject var showDrinkList: Visibility = Visibility()

var storage: Visibility = Visibility()
Expand All @@ -34,24 +39,16 @@ func fromMainActor() async {


func fromConcurrencyAware() async {
// expected-note@+3 {{calls to initializer 'init()' from outside of its actor context are implicitly asynchronous}}
// expected-warning@+2 {{expression is 'async' but is not marked with 'await'}}
// expected-warning@+1 {{non-sendable type 'CoffeeTrackerView' returned by call to main actor-isolated function cannot cross actor boundary}}
let view = CoffeeTrackerView()
let view = CoffeeTrackerView() // synthesized 'init' is 'nonisolated'

// expected-warning@+4 {{non-sendable type 'CoffeeTrackerView' passed in implicitly asynchronous call to main actor-isolated property 'body' cannot cross actor boundary}}
// expected-note@+3 {{property access is 'async'}}
// expected-warning@+2 {{non-sendable type 'some View' in implicitly asynchronous access to main actor-isolated property 'body' cannot cross actor boundary}}
// expected-warning@+1 {{expression is 'async' but is not marked with 'await'}}
_ = view.body

// expected-warning@+4 {{non-sendable type 'CoffeeTrackerView' passed in implicitly asynchronous call to main actor-isolated property 'showDrinkList' cannot cross actor boundary}}
// expected-note@+3 {{property access is 'async'}}
// expected-warning@+2 {{non-sendable type 'Visibility' in implicitly asynchronous access to main actor-isolated property 'showDrinkList' cannot cross actor boundary}}
// expected-note@+2 {{property access is 'async'}}
// expected-warning@+1 {{expression is 'async' but is not marked with 'await'}}
_ = view.showDrinkList

// expected-warning@+2 {{non-sendable type 'CoffeeTrackerView' passed in implicitly asynchronous call to main actor-isolated property 'storage' cannot cross actor boundary}}
// expected-warning@+1 {{non-sendable type 'Visibility' in implicitly asynchronous access to main actor-isolated property 'storage' cannot cross actor boundary}}
_ = await view.storage
_ = view.storage
}

0 comments on commit 1b0dca0

Please sign in to comment.