Skip to content

Test: add coverage for borrowing get #75699

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions test/Interpreter/moveonly_foundation.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// RUN: %target-run-simple-swift(-Xfrontend -sil-verify-all) | %FileCheck %s
// RUN: %target-run-simple-swift(-O -Xfrontend -sil-verify-all) | %FileCheck %s

// REQUIRES: executable_test
// REQUIRES: foundation

import StdlibUnittest
import Foundation

defer { runAllTests() }

var Tests = TestSuite("MoveOnlyFoundationTests")

// coverage for rdar://132915515
// CHECK-LABEL: borrowing get on copyable type
Tests.test("borrowing get on copyable type") {
struct Loaner {
let value: UUID
var property: UUID { borrowing get { value }}
borrowing func method() -> UUID { value }
}

func printLoanedValue(_ loaner: borrowing Loaner) {
// CHECK: UUID = [[UUID_VAL:.*]]
print("UUID = \(loaner.property)")

// CHECK: UUID = [[UUID_VAL]]
print("UUID = \(loaner.method())")
}

do {
let l = Loaner(value: UUID())
printLoanedValue(l)
}
}