Skip to content

Commit 61dd55d

Browse files
committed
Test: add coverage for borrowing get
resolves rdar://132915515
1 parent df9ff6c commit 61dd55d

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

test/Interpreter/moveonly.swift

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
// RUN: %target-run-simple-swift(-Xfrontend -sil-verify-all)
2-
// RUN: %target-run-simple-swift(-O -Xfrontend -sil-verify-all)
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
33

44
// REQUIRES: executable_test
55

66
import StdlibUnittest
7+
import Foundation
78

89
defer { runAllTests() }
910

@@ -155,3 +156,25 @@ Tests.test("global borrowing access") {
155156
expectEqual(HasStatic.b.y.data, 121)
156157
}
157158

159+
// coverage for rdar://132915515
160+
// CHECK-LABEL: borrowing get on copyable type
161+
Tests.test("borrowing get on copyable type") {
162+
struct Loaner {
163+
let value: UUID
164+
var property: UUID { borrowing get { value }}
165+
borrowing func method() -> UUID { value }
166+
}
167+
168+
func printLoanedValue(_ loaner: borrowing Loaner) {
169+
// CHECK: UUID = [[UUID_VAL:.*]]
170+
print("UUID = \(loaner.property)")
171+
172+
// CHECK: UUID = [[UUID_VAL]]
173+
print("UUID = \(loaner.method())")
174+
}
175+
176+
do {
177+
let l = Loaner(value: UUID())
178+
printLoanedValue(l)
179+
}
180+
}

0 commit comments

Comments
 (0)