mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Looking at the AST-level `getReadImpl` doesn't always correspond to what accessor SILGen prefers to use, due to resilience, ABI rules, and other concerns. In findStorageReferenceExprForMoveOnly, when determining whether a storage reference is borrowable, use the same logic as SILGenLValue actually uses to determine what storage or accessor access strategy to use. Fixes rdar://142509673
23 lines
367 B
Swift
23 lines
367 B
Swift
// RUN: %target-swift-frontend -emit-sil -verify %s
|
|
|
|
// rdar://142509673
|
|
|
|
struct Foo: ~Copyable {
|
|
var storage: UnsafeRawPointer
|
|
}
|
|
|
|
class Bar {
|
|
class var foo: Foo { fatalError() }
|
|
}
|
|
|
|
func test(foo: borrowing Foo) -> Bool {
|
|
fatalError()
|
|
}
|
|
|
|
func test2(bar: Bar.Type) -> Bool {
|
|
guard test(foo: bar.foo) else {
|
|
return false
|
|
}
|
|
return true
|
|
}
|