|
1 |
| -// REQUIRES: swift_swift_parser |
2 |
| - |
3 |
| -// XFAIL: * |
4 |
| - |
5 |
| -// RUN: not %target-swift-frontend %s -swift-version 5 -module-name main -disable-availability-checking -typecheck -plugin-path %swift-plugin-dir -dump-macro-expansions 2>&1 | %FileCheck --match-full-lines %s |
6 |
| -// RUN: %target-typecheck-verify-swift %s -swift-version 5 -module-name main -disable-availability-checking -typecheck -plugin-path %swift-plugin-dir -verify |
7 |
| - |
| 1 | +//--- test.swift |
8 | 2 | @_SwiftifyImport(.countedBy(pointer: .param(1), count: "len"))
|
9 | 3 | func myFunc(_ ptr: UnsafePointer<CInt>, _ len: String) {
|
10 | 4 | }
|
| 5 | +// expected-note@-3 2{{in expansion of macro '_SwiftifyImport' on global function 'myFunc' here}} |
11 | 6 |
|
12 |
| -// CHECK: @_alwaysEmitIntoClient @_disfavoredOverload |
13 |
| -// CHECK-NEXT: func myFunc(_ ptr: UnsafeBufferPointer<CInt>) { |
14 |
| -// CHECK-NEXT: myFunc(ptr.baseAddress!, String(exactly: ptr.count)!) |
15 |
| -// CHECK-NEXT: } |
| 7 | +// expected-error@@__swiftmacro_4main6myFunc15_SwiftifyImportfMp_.swift:4:15{{no exact matches in call to initializer}} |
| 8 | +// expected-error@@__swiftmacro_4main6myFunc15_SwiftifyImportfMp_.swift:4:48{{cannot force unwrap value of non-optional type 'String'}} |
16 | 9 |
|
17 |
| -// expected-error@_SwiftifyImport:2{{no exact matches in call to initializer}} |
| 10 | +// REQUIRES: swift_swift_parser |
| 11 | +// RUN: %empty-directory(%t) |
| 12 | +// RUN: split-file %s %t |
| 13 | +// RUN: %target-swift-frontend %t/test.swift -swift-version 5 -module-name main -disable-availability-checking -typecheck -plugin-path %swift-plugin-dir -dump-macro-expansions -verify 2> %t/dump.txt |
| 14 | +// RUN: diff %t/myFunc.expected %t/dump.txt |
| 15 | + |
| 16 | +//--- myFunc.expected |
| 17 | +@__swiftmacro_4main6myFunc15_SwiftifyImportfMp_.swift |
| 18 | +------------------------------ |
| 19 | +/// This is an auto-generated wrapper for safer interop |
| 20 | +@_alwaysEmitIntoClient @_disfavoredOverload |
| 21 | +func myFunc(_ ptr: UnsafeBufferPointer<CInt>) { |
| 22 | + let len = String(exactly: unsafe ptr.count)! |
| 23 | + return unsafe myFunc(ptr.baseAddress!, len) |
| 24 | +} |
| 25 | +------------------------------ |
0 commit comments