mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
SILGenBorrowedBaseVisitor did not take subscripts into account during its visit. Add this case following the handling of MemberRefExpr for properties. Fixes rdar://163022690.
24 lines
385 B
Swift
24 lines
385 B
Swift
// RUN: %target-swift-frontend -emit-sil -verify %s
|
|
|
|
func test(foo: borrowing Foo, s: String) -> Bool {
|
|
return foo.children[0].name == s
|
|
}
|
|
|
|
func test2(foo: borrowing Foo) -> String {
|
|
return foo.children[0].name
|
|
}
|
|
|
|
struct Foo: ~Copyable {
|
|
var children: Bar<Foo>
|
|
var name: String
|
|
}
|
|
|
|
struct Bar<T: ~Copyable>: ~Copyable {
|
|
subscript(x: Int) -> T {
|
|
_read {
|
|
fatalError()
|
|
}
|
|
}
|
|
}
|
|
|