Skip to content

Commit f0ce346

Browse files
authored
Merge pull request #75699 from kavon/test-coverage-132915515
Test: add coverage for borrowing get
2 parents 688715e + c8aff34 commit f0ce346

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// RUN: %target-run-simple-swift(-Xfrontend -sil-verify-all) | %FileCheck %s
2+
// RUN: %target-run-simple-swift(-O -Xfrontend -sil-verify-all) | %FileCheck %s
3+
4+
// REQUIRES: executable_test
5+
// REQUIRES: foundation
6+
7+
import StdlibUnittest
8+
import Foundation
9+
10+
defer { runAllTests() }
11+
12+
var Tests = TestSuite("MoveOnlyFoundationTests")
13+
14+
// coverage for rdar://132915515
15+
// CHECK-LABEL: borrowing get on copyable type
16+
Tests.test("borrowing get on copyable type") {
17+
struct Loaner {
18+
let value: UUID
19+
var property: UUID { borrowing get { value }}
20+
borrowing func method() -> UUID { value }
21+
}
22+
23+
func printLoanedValue(_ loaner: borrowing Loaner) {
24+
// CHECK: UUID = [[UUID_VAL:.*]]
25+
print("UUID = \(loaner.property)")
26+
27+
// CHECK: UUID = [[UUID_VAL]]
28+
print("UUID = \(loaner.method())")
29+
}
30+
31+
do {
32+
let l = Loaner(value: UUID())
33+
printLoanedValue(l)
34+
}
35+
}

0 commit comments

Comments
 (0)