mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Trivial values don't have ownership tracked, so their uses can't affect the lifetime of the original borrow. Fixes rdar://148457155.
27 lines
470 B
Swift
27 lines
470 B
Swift
// RUN: %target-swift-frontend -emit-sil -verify %s
|
|
|
|
func use(_: Int32) {}
|
|
|
|
struct NoncopyableYieldingSubscript: ~Copyable {
|
|
subscript() -> Int16 {
|
|
_read {
|
|
yield 0
|
|
}
|
|
}
|
|
}
|
|
|
|
func foo(component: inout NoncopyableYieldingSubscript, condition: Bool) {
|
|
let extracted: Int32
|
|
|
|
switch condition {
|
|
case true:
|
|
extracted = Int32(component[])
|
|
|
|
case false:
|
|
extracted = Int32(component[])
|
|
|
|
}
|
|
|
|
use(extracted)
|
|
}
|