Files
swift-mirror/test/SILGen/subscript_borrowable_base.swift
Joe Groff d7ea0b821e SILGen: Subscripts can also be borrowed bases.
SILGenBorrowedBaseVisitor did not take subscripts into account during its
visit. Add this case following the handling of MemberRefExpr for properties.
Fixes rdar://163022690.
2025-10-21 11:50:16 -07:00

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()
}
}
}