-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[RemoteMirror] Handle UnsafeContinuation
UnsafeContinuations can be stored in variables or properties, so it's important for RemoteMirror to be able to at least minimally recognize them. This just treats an UnsafeContinuation as a refcounted pointer. Which might be "good enough" for now. Working towards rdar://110351406
- Loading branch information
Showing
3 changed files
with
66 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
validation-test/Reflection/reflect_UnsafeContinuation.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// RUN: %empty-directory(%t) | ||
// RUN: %target-build-swift -lswiftSwiftReflectionTest %s -o %t/reflect_UnsafeContinuation | ||
// RUN: %target-codesign %t/reflect_UnsafeContinuation | ||
|
||
// RUN: %target-run %target-swift-reflection-test %t/reflect_UnsafeContinuation | %FileCheck %s --check-prefix=CHECK-%target-ptrsize | ||
|
||
// REQUIRES: reflection_test_support | ||
// REQUIRES: executable_test | ||
// UNSUPPORTED: use_os_stdlib | ||
// UNSUPPORTED: ASAN | ||
|
||
import SwiftReflectionTest | ||
|
||
struct MyValue { | ||
let u: UInt | ||
} | ||
|
||
struct MyError: Error { | ||
let i: Int | ||
} | ||
|
||
@available(SwiftStdlib 5.1, *) | ||
class MyClass { | ||
let cont: UnsafeContinuation<MyValue, any Error> | ||
|
||
init(cont: UnsafeContinuation<MyValue, any Error>) { | ||
self.cont = cont | ||
} | ||
} | ||
|
||
if #available(SwiftStdlib 5.1, *) { | ||
_ = try await withUnsafeThrowingContinuation { unsafeContinuation in | ||
let myClass = MyClass(cont: unsafeContinuation) | ||
reflect(object: myClass) | ||
unsafeContinuation.resume(returning: MyValue(u: 1)) | ||
} | ||
} | ||
|
||
// CHECK: Reflecting an object. | ||
// CHECK-NEXT: Instance pointer in child address space: 0x{{[0-9a-fA-F]+}} | ||
// CHECK-NEXT: Type reference: | ||
// CHECK-NEXT: (class reflect_UnsafeContinuation.MyClass) | ||
|
||
// CHECK-64: Type info: | ||
// CHECK-64-NEXT: (class_instance size=24 alignment=8 stride=24 num_extra_inhabitants=0 bitwise_takable=1 | ||
// CHECK-64-NEXT: (field name=cont offset=16 | ||
// CHECK-64-NEXT: (struct size=8 alignment=8 stride=8 num_extra_inhabitants=2147483647 bitwise_takable=1 | ||
// CHECK-64-NEXT: (field name=context offset=0 | ||
// CHECK-64-NEXT: (reference kind=strong refcounting=native))))) | ||
|
||
// TODO: 32-bit layout | ||
|
||
doneReflecting() | ||
|
||
// CHECK-64: Done. | ||
|
||
// CHECK-32: Done. |