mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[test]: update existing tests for new fixit
This commit is contained in:
@@ -50,7 +50,7 @@ actor BankAccount {
|
||||
}
|
||||
|
||||
func testSelfBalance() async {
|
||||
_ = await balance() // expected-warning {{no 'async' operations occur within 'await' expression}}
|
||||
_ = await balance() // expected-warning {{no 'async' operations occur within 'await' expression}}{{9-15=}}
|
||||
}
|
||||
|
||||
// returns the amount actually withdrawn
|
||||
@@ -357,12 +357,12 @@ actor Calculator {
|
||||
// We will error on the next line when we get past type checking. But since we
|
||||
// error in the type checker, we do not make further progress.
|
||||
let _ = (await bananaAdd(1))(2)
|
||||
let _ = await (await bananaAdd(1))(2) // expected-warning{{no 'async' operations occur within 'await' expression}}
|
||||
let _ = await (await bananaAdd(1))(2) // expected-warning{{no 'async' operations occur within 'await' expression}}{{11-17=}}
|
||||
|
||||
let calc = Calculator()
|
||||
|
||||
let _ = (await calc.addCurried(1))(2)
|
||||
let _ = await (await calc.addCurried(1))(2) // expected-warning{{no 'async' operations occur within 'await' expression}}
|
||||
let _ = await (await calc.addCurried(1))(2) // expected-warning{{no 'async' operations occur within 'await' expression}}{{11-17=}}
|
||||
|
||||
let plusOne = await calc.addCurried(await calc.add(0, 1))
|
||||
let _ = plusOne(2)
|
||||
|
||||
@@ -54,7 +54,7 @@ actor Act {
|
||||
nonisolated let act = Act()
|
||||
|
||||
func bad() async {
|
||||
// expected-warning@+3 {{no 'async' operations occur within 'await' expression}}
|
||||
// expected-warning@+3 {{no 'async' operations occur within 'await' expression}}{{5-11=}}
|
||||
// expected-error@+2 {{actor-isolated property 'i' can not be mutated from a nonisolated context}}
|
||||
// expected-note@+1 {{consider declaring an isolated method on 'Act' to perform the mutation}}
|
||||
await act.i = 666
|
||||
@@ -66,13 +66,13 @@ protocol Proto: Actor {
|
||||
extension Act: Proto {}
|
||||
|
||||
func good() async {
|
||||
// expected-warning@+3 {{no 'async' operations occur within 'await' expression}}
|
||||
// expected-warning@+3 {{no 'async' operations occur within 'await' expression}}{{5-11=}}
|
||||
// expected-error@+2 {{actor-isolated property 'i' can not be mutated from a nonisolated context}}
|
||||
// expected-note@+1 {{consider declaring an isolated method on 'Proto' to perform the mutation}}
|
||||
await (act as any Proto).i = 42
|
||||
let aIndirect: any Proto = act
|
||||
|
||||
// expected-warning@+3 {{no 'async' operations occur within 'await' expression}}
|
||||
// expected-warning@+3 {{no 'async' operations occur within 'await' expression}}{{5-11=}}
|
||||
// expected-error@+2 {{actor-isolated property 'i' can not be mutated from a nonisolated context}}
|
||||
// expected-note@+1 {{consider declaring an isolated method on 'Proto' to perform the mutation}}
|
||||
await aIndirect.i = 777
|
||||
|
||||
@@ -275,7 +275,7 @@ extension MyActor {
|
||||
// expected-note@-1{{consider declaring an isolated method on 'MyActor' to perform the mutation}}
|
||||
acceptInout(&otherActor.mutable) // expected-error{{actor-isolated property 'mutable' can not be used 'inout' on a nonisolated actor instance}}
|
||||
// expected-error@+3{{actor-isolated property 'mutable' can not be mutated on a nonisolated actor instance}}
|
||||
// expected-warning@+2{{no 'async' operations occur within 'await' expression}}
|
||||
// expected-warning@+2{{no 'async' operations occur within 'await' expression}}{{5-11=}}
|
||||
// expected-note@+1{{consider declaring an isolated method on 'MyActor' to perform the mutation}}
|
||||
await otherActor.mutable = 0
|
||||
|
||||
@@ -616,7 +616,7 @@ func testGlobalRestrictions(actor: MyActor) async {
|
||||
|
||||
// stored and computed properties can be accessed. Only immutable stored properties can be accessed without 'await'
|
||||
_ = actor.immutable
|
||||
_ = await actor.immutable // expected-warning {{no 'async' operations occur within 'await' expression}}
|
||||
_ = await actor.immutable // expected-warning {{no 'async' operations occur within 'await' expression}}{{7-13=}}
|
||||
_ = actor.mutable // expected-error{{actor-isolated property 'mutable' cannot be accessed from outside of the actor}}{{7-7=await }}
|
||||
_ = await actor.mutable
|
||||
_ = actor.text[0] // expected-error{{actor-isolated property 'text' cannot be accessed from outside of the actor}}{{7-7=await }}
|
||||
@@ -1205,7 +1205,7 @@ extension MyActor {
|
||||
}
|
||||
|
||||
acceptAsyncSendableClosureInheriting {
|
||||
_ = await synchronous() // expected-warning{{no 'async' operations occur within 'await' expression}}
|
||||
_ = await synchronous() // expected-warning{{no 'async' operations occur within 'await' expression}}{{11-17=}}
|
||||
counter += 1 // okay
|
||||
}
|
||||
|
||||
|
||||
@@ -53,15 +53,15 @@ func checkIsolationValueType(_ formance: InferredFromConformance,
|
||||
_ = anno.counter
|
||||
|
||||
// make sure it's just a warning if someone was awaiting on it previously
|
||||
_ = await ext.point // expected-warning {{no 'async' operations occur within 'await' expression}}
|
||||
_ = await formance.counter // expected-warning {{no 'async' operations occur within 'await' expression}}
|
||||
_ = await anno.counter // expected-warning {{no 'async' operations occur within 'await' expression}}
|
||||
_ = await ext.point // expected-warning {{no 'async' operations occur within 'await' expression}}{{7-13=}}
|
||||
_ = await formance.counter // expected-warning {{no 'async' operations occur within 'await' expression}}{{7-13=}}
|
||||
_ = await anno.counter // expected-warning {{no 'async' operations occur within 'await' expression}}{{7-13=}}
|
||||
|
||||
// this does not need an await, since the property is 'Sendable' and of a
|
||||
// value type
|
||||
_ = anno.point
|
||||
_ = await anno.point
|
||||
// expected-warning@-1 {{no 'async' operations occur within 'await' expression}}
|
||||
// expected-warning@-1 {{no 'async' operations occur within 'await' expression}}{{7-13=}}
|
||||
|
||||
// these do need await, regardless of reference or value type
|
||||
_ = await (formance as any MainCounter).counter
|
||||
|
||||
@@ -48,7 +48,7 @@ struct Kappa {
|
||||
// though we could try to could give a better message
|
||||
if let await maybeData { // expected-error{{unwrap condition requires a valid identifier}}
|
||||
// expected-error@-1{{pattern variable binding cannot appear in an expression}}
|
||||
// expected-warning@-2{{no 'async' operations occur within 'await' expression}}
|
||||
// expected-warning@-2{{no 'async' operations occur within 'await' expression}}{{12-18=}}
|
||||
return maybeData // expected-error{{expression is 'async' but is not marked with 'await'}}
|
||||
// expected-note@-1{{property access is 'async'}}
|
||||
}
|
||||
|
||||
@@ -653,7 +653,7 @@ func acceptAsyncSendableClosureInheriting<T>(@_inheritActorContext _: @Sendable
|
||||
}
|
||||
|
||||
acceptAsyncSendableClosureInheriting {
|
||||
await onlyOnMainActor() // expected-warning{{no 'async' operations occur within 'await' expression}}
|
||||
await onlyOnMainActor() // expected-warning{{no 'async' operations occur within 'await' expression}}{{5-11=}}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ func asyncFunction() async {}
|
||||
|
||||
func callReasyncFunction() async {
|
||||
reasyncFunction { }
|
||||
await reasyncFunction { } // expected-warning {{no 'async' operations occur within 'await' expression}}
|
||||
await reasyncFunction { } // expected-warning {{no 'async' operations occur within 'await' expression}}{{3-9=}}
|
||||
|
||||
reasyncFunction { await asyncFunction() }
|
||||
// expected-error@-1:3 {{expression is 'async' but is not marked with 'await'}}{{3-3=await }}
|
||||
@@ -58,11 +58,11 @@ enum HorseError : Error {
|
||||
func callReasyncRethrowsFunction() async throws {
|
||||
reasyncRethrowsFunction { }
|
||||
await reasyncRethrowsFunction { }
|
||||
// expected-warning@-1 {{no 'async' operations occur within 'await' expression}}
|
||||
// expected-warning@-1 {{no 'async' operations occur within 'await' expression}}{{3-9=}}
|
||||
try reasyncRethrowsFunction { }
|
||||
// expected-warning@-1 {{no calls to throwing functions occur within 'try' expression}}
|
||||
try await reasyncRethrowsFunction { }
|
||||
// expected-warning@-1 {{no 'async' operations occur within 'await' expression}}
|
||||
// expected-warning@-1 {{no 'async' operations occur within 'await' expression}}{{7-13=}}
|
||||
// expected-warning@-2 {{no calls to throwing functions occur within 'try' expression}}
|
||||
|
||||
reasyncRethrowsFunction { await asyncFunction() }
|
||||
@@ -84,10 +84,10 @@ func callReasyncRethrowsFunction() async throws {
|
||||
await reasyncRethrowsFunction { throw HorseError.colic }
|
||||
// expected-error@-1 {{call can throw but is not marked with 'try'}}
|
||||
// expected-note@-2 {{call is to 'rethrows' function, but argument function can throw}}
|
||||
// expected-warning@-3 {{no 'async' operations occur within 'await' expression}}
|
||||
// expected-warning@-3 {{no 'async' operations occur within 'await' expression}}{{3-9=}}
|
||||
try reasyncRethrowsFunction { throw HorseError.colic }
|
||||
try await reasyncRethrowsFunction { throw HorseError.colic }
|
||||
// expected-warning@-1 {{no 'async' operations occur within 'await' expression}}
|
||||
// expected-warning@-1 {{no 'async' operations occur within 'await' expression}}{{7-13=}}
|
||||
|
||||
reasyncRethrowsFunction { await asyncFunction(); throw HorseError.colic }
|
||||
// expected-error@-1 {{call can throw but is not marked with 'try'}}
|
||||
|
||||
@@ -19,7 +19,7 @@ func isolatedSync() { // expected-note 2 {{calls to global function 'isolatedSyn
|
||||
}
|
||||
|
||||
func nonIsolatedAsync() async {
|
||||
await print(a) // expected-warning {{no 'async' operations occur within 'await' expression}}
|
||||
await print(a) // expected-warning {{no 'async' operations occur within 'await' expression}}{{5-11=}}
|
||||
a = a + 10
|
||||
}
|
||||
|
||||
|
||||
@@ -72,14 +72,14 @@ func testActorCrossingBoundary() async {
|
||||
let _ = await (await mainActorResult(1))(2)
|
||||
// expected-error @-1 {{non-Sendable '(Int) -> Int'-typed result can not be returned from main actor-isolated global function 'mainActorResult' to global actor 'CustomActor'-isolated context}}
|
||||
// expected-note @-2 {{a function type must be marked '@Sendable' to conform to 'Sendable'}}
|
||||
// expected-warning @-3 {{no 'async' operations occur within 'await' expression}}
|
||||
// expected-warning @-3 {{no 'async' operations occur within 'await' expression}}{{11-17=}}
|
||||
|
||||
let calc = Calculator()
|
||||
|
||||
let _ = (await calc.addCurried(1))(2)
|
||||
// expected-error @-1 {{non-Sendable '(Int) -> Int'-typed result can not be returned from actor-isolated instance method 'addCurried' to global actor 'CustomActor'-isolated context}}
|
||||
// expected-note@-2{{a function type must be marked '@Sendable' to conform to 'Sendable'}}
|
||||
let _ = await (await calc.addCurried(1))(2) // expected-warning{{no 'async' operations occur within 'await' expression}}
|
||||
let _ = await (await calc.addCurried(1))(2) // expected-warning{{no 'async' operations occur within 'await' expression}}{{11-17=}}
|
||||
// expected-error @-1 {{non-Sendable '(Int) -> Int'-typed result can not be returned from actor-isolated instance method 'addCurried' to global actor 'CustomActor'-isolated context}}
|
||||
// expected-note @-2 {{a function type must be marked '@Sendable' to conform to 'Sendable'}}
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ func outside_good_generic<DP: DistProtocol>(dp: DP) async throws {
|
||||
_ = dp.local() // expected-error{{only 'distributed' instance methods can be called on a potentially remote distributed actor}}
|
||||
_ = await dp.local() // expected-error{{only 'distributed' instance methods can be called on a potentially remote distributed actor}}
|
||||
// the below warning is expected because we don't apply the "implicitly async" to the not-callable func
|
||||
// expected-warning@-2{{no 'async' operations occur within 'await' expression}}
|
||||
// expected-warning@-2{{no 'async' operations occur within 'await' expression}}{{7-13=}}
|
||||
|
||||
_ = try dp.local() // expected-error{{only 'distributed' instance methods can be called on a potentially remote distributed actor}}
|
||||
// the below warning is expected because we don't apply the "implicitly throwing" to the not-callable func
|
||||
|
||||
@@ -301,7 +301,7 @@ do {
|
||||
// expected-warning@-1 {{no calls to throwing functions occur within 'try' expression}}
|
||||
} // expected-error {{expected expression after operator}}
|
||||
|
||||
_ = await /x/ // expected-warning {{no 'async' operations occur within 'await' expression}}
|
||||
_ = await /x/ // expected-warning {{no 'async' operations occur within 'await' expression}}{{5-11=}}
|
||||
|
||||
/x/ = 0 // expected-error {{cannot assign to value: literals are not mutable}}
|
||||
/x/() // expected-error {{cannot call value of non-function type 'Regex<Substring>'}}
|
||||
|
||||
@@ -223,7 +223,7 @@ func composed2<U : None & A >(u : U) async {
|
||||
_ = u.someProp
|
||||
// FIXME: this ^ should raise "property access is 'async' but is not marked with 'await'""
|
||||
|
||||
_ = await u.someProp // expected-warning {{no 'async' operations occur within 'await' expression}}
|
||||
_ = await u.someProp // expected-warning {{no 'async' operations occur within 'await' expression}}{{7-13=}}
|
||||
}
|
||||
|
||||
func composed3<U : T & None >(u : U) throws {
|
||||
|
||||
@@ -6,7 +6,7 @@ func test1(asyncfp : () async -> Int, fp : () -> Int) async {
|
||||
_ = await asyncfp()
|
||||
_ = await asyncfp() + asyncfp()
|
||||
_ = await asyncfp() + fp()
|
||||
_ = await fp() + 42 // expected-warning {{no 'async' operations occur within 'await' expression}}
|
||||
_ = await fp() + 42 // expected-warning {{no 'async' operations occur within 'await' expression}}{{7-13=}}
|
||||
_ = 32 + asyncfp() + asyncfp() // expected-error {{expression is 'async' but is not marked with 'await'}}{{7-7=await }}
|
||||
// expected-note@-1:12{{call is 'async'}}
|
||||
// expected-note@-2:24{{call is 'async'}}
|
||||
|
||||
Reference in New Issue
Block a user