Files
swift-mirror/test/decl/var/effectful_properties_global.swift
Kavon Farvardin e17e09c294 Enable effectful properties (SE-310) by default.
1. Removes gating on -enable-experimental-concurrency.
2. Updates eff. prop tests to remove experimental flag,
   and also adjusts some tests slightly to avoid things
   that are still behind that flag.
2021-05-03 14:10:44 -07:00

41 lines
1016 B
Swift

// RUN: %target-typecheck-verify-swift
var intAsyncProp : Int {
get async { 0 }
}
var intThrowsProp : Int {
get throws { 0 }
}
var asyncThrowsProp : Int {
get async throws { try await intAsyncProp + intThrowsProp }
}
func hello() async {
_ = intThrowsProp // expected-error{{property access can throw, but it is not marked with 'try' and the error is not handled}}
// expected-error@+1{{expression is 'async' but is not marked with 'await'}}{{7-7=await }}
_ = intAsyncProp // expected-note{{property access is 'async'}}
}
class C {
var counter : Int = 0
}
var refTypeThrowsProp : C {
get throws { return C() }
}
var refTypeAsyncProp : C {
get async { return C() }
}
func salam() async {
_ = refTypeThrowsProp // expected-error{{property access can throw, but it is not marked with 'try' and the error is not handled}}
// expected-error@+1 {{expression is 'async' but is not marked with 'await'}}{{7-7=await }}
_ = refTypeAsyncProp // expected-note {{property access is 'async'}}
}