mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
A read access asserts that the memory location is immutable for the duration of the access, so it can be treated as a borrow rather than a mutable lvalue. Doing this allows the borrow formal access scope fixes from #79084 to apply to situations where a loadable type undergoes an accessor-based access with indirect arguments (such as for public accessors when library evolution is enabled for the type). Fixes rdar://143334632.
23 lines
592 B
Swift
23 lines
592 B
Swift
// rdar://143334632
|
|
|
|
// RUN: %target-swift-emit-silgen -enable-library-evolution %s | %FileCheck %s
|
|
|
|
public struct Foo {
|
|
// CHECK-LABEL: sil {{.*}} @$s{{.*}}3FooV3foo
|
|
mutating func foo() -> Int {
|
|
// CHECK: [[BEGIN_READ:%.*]] = begin_access [read] [unknown] %0
|
|
// CHECK: ([[RESULT:%.*]], [[TOKEN:%.*]]) = begin_apply %{{.*}}([[BEGIN_READ]])
|
|
// CHECK: end_apply [[TOKEN]]
|
|
// CHECK: end_access [[BEGIN_READ]]
|
|
// CHECK: return [[RESULT]]
|
|
return self[]
|
|
}
|
|
|
|
var object : AnyObject
|
|
|
|
subscript() -> Int {
|
|
_read {fatalError()}
|
|
_modify {fatalError()}
|
|
}
|
|
}
|