mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
The storage kind has been replaced with three separate "impl kinds", one for each of the basic access kinds (read, write, and read/write). This makes it far easier to mix-and-match implementations of different accessors, as well as subtleties like implementing both a setter and an independent read/write operation. AccessStrategy has become a bit more explicit about how exactly the access should be implemented. For example, the accessor-based kinds now carry the exact accessor intended to be used. Also, I've shifted responsibilities slightly between AccessStrategy and AccessSemantics so that AccessSemantics::Ordinary can be used except in the sorts of semantic-bypasses that accessor synthesis wants. This requires knowing the correct DC of the access when computing the access strategy; the upshot is that SILGenFunction now needs a DC. Accessor synthesis has been reworked so that only the declarations are built immediately; body synthesis can be safely delayed out of the main decl-checking path. This caused a large number of ramifications, especially for lazy properties, and greatly inflated the size of this patch. That is... really regrettable. The impetus for changing this was necessity: I needed to rework accessor synthesis to end its reliance on distinctions like Stored vs. StoredWithTrivialAccessors, and those fixes were exposing serious re-entrancy problems, and fixing that... well. Breaking the fixes apart at this point would be a serious endeavor.
50 lines
1.3 KiB
Swift
50 lines
1.3 KiB
Swift
// RUN: %target-swift-frontend -dump-ast %s 2>&1 | %FileCheck %s
|
|
// RUN: %target-swift-frontend -emit-ir %s > /dev/null
|
|
|
|
// RUN: %target-swift-frontend -dump-ast -DVAR %s 2>&1 | %FileCheck %s
|
|
// RUN: %target-swift-frontend -emit-ir -DVAR %s > /dev/null
|
|
|
|
// CHECK: (top_level_code_decl
|
|
// CHECK: (guard_stmt
|
|
#if VAR
|
|
guard var x = Optional(0) else { fatalError() }
|
|
#else
|
|
guard let x = Optional(0) else { fatalError() }
|
|
#endif
|
|
|
|
// CHECK: (top_level_code_decl
|
|
_ = 0 // intervening code
|
|
|
|
// CHECK-LABEL: (func_decl{{.*}}"function()" interface type='() -> ()' access=internal captures=(x<direct>)
|
|
func function() {
|
|
_ = x
|
|
}
|
|
|
|
// CHECK-LABEL: (closure_expr
|
|
// CHECK: location={{.*}}top-level-guard.swift:[[@LINE+3]]
|
|
// CHECK: captures=(x<direct>)
|
|
// CHECK: (var_decl{{.*}}"closure"
|
|
let closure: () -> Void = {
|
|
_ = x
|
|
}
|
|
|
|
// CHECK-LABEL: (capture_list
|
|
// CHECK: location={{.*}}top-level-guard.swift:[[@LINE+5]]
|
|
// CHECK: (closure_expr
|
|
// CHECK: location={{.*}}top-level-guard.swift:[[@LINE+3]]
|
|
// CHECK: captures=(x<direct>)
|
|
// CHECK: (var_decl{{.*}}"closureCapture"
|
|
let closureCapture: () -> Void = { [x] in
|
|
_ = x
|
|
}
|
|
|
|
// CHECK-LABEL: (defer_stmt
|
|
// CHECK-NEXT: (func_decl{{.*}}implicit "$defer()" interface type='() -> ()' access=fileprivate captures=(x<direct><noescape>)
|
|
defer {
|
|
_ = x
|
|
}
|
|
|
|
#if VAR
|
|
x = 5
|
|
#endif
|