File: reflect_CheckedContinuation.swift

package info (click to toggle)
swiftlang 6.2.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,856,264 kB
  • sloc: cpp: 9,995,718; ansic: 2,234,019; asm: 1,092,167; python: 313,940; objc: 82,726; f90: 80,126; lisp: 38,373; pascal: 25,580; sh: 20,378; ml: 5,058; perl: 4,751; makefile: 4,725; awk: 3,535; javascript: 3,018; xml: 918; fortran: 664; cs: 573; ruby: 396
file content (58 lines) | stat: -rw-r--r-- 1,766 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// RUN: %empty-directory(%t)
// RUN: %target-build-swift -lswiftSwiftReflectionTest %s -o %t/reflect_CheckedContinuation
// RUN: %target-codesign %t/reflect_CheckedContinuation

// RUN: %target-run %target-swift-reflection-test %t/reflect_CheckedContinuation | %FileCheck %s --check-prefix=CHECK-%target-ptrsize %add_num_extra_inhabitants

// REQUIRES: reflection_test_support
// REQUIRES: executable_test
// UNSUPPORTED: use_os_stdlib
// UNSUPPORTED: asan
// UNSUPPORTED: back_deployment_runtime

import SwiftReflectionTest

struct MyValue {
    let u: UInt
}

struct MyError: Error {
    let i: Int
}

@available(SwiftStdlib 5.1, *)
class MyClass {
    let cont: CheckedContinuation<MyValue, any Error>

    init(cont: CheckedContinuation<MyValue, any Error>) {
        self.cont = cont
    }
}

if #available(SwiftStdlib 5.1, *) {
  _ = try await withCheckedThrowingContinuation { checkedContinuation in
    let myClass = MyClass(cont: checkedContinuation)
    reflect(object: myClass)
    checkedContinuation.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_CheckedContinuation.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=[[#num_extra_inhabitants_64bit]] bitwise_takable=1
// CHECK-64-NEXT:       (field name=canary offset=0
// CHECK-64-NEXT:         (reference kind=strong refcounting=native)))))

// TODO: 32-bit layout

doneReflecting()

// CHECK-64: Done.

// CHECK-32: Done.