Files
swift-mirror/test/Interop/ObjC/swiftify-import/counted-by-in-class.swift
Henrik G. Olsson c335b80ebd [Swiftify] Don't create safe wrapper for autoreleasing pointers (#81568) (#81590)
_SwiftifyImport doesn't know how to handle
AutoreleasingUnsafeMutablePointer, so we should not attach any
.countedBy information for pointers that are imported as this type.

This also adds defensive checks against adding .countedBy to any pointer
type that _SwiftifyImport doesn't know how to transform.

rdar://151479521
2025-05-20 08:03:10 -07:00

28 lines
918 B
Swift

// REQUIRES: swift_feature_SafeInteropWrappers
// RUN: rm -rf %t
// RUN: split-file %s %t
// RUN: %target-swift-ide-test -plugin-path %swift-plugin-dir -I %t/Inputs -enable-experimental-feature SafeInteropWrappers -print-module -module-to-print=Method -source-filename=x | %FileCheck %s
// RUN: %target-swift-frontend -plugin-path %swift-plugin-dir -I %t/Inputs -enable-experimental-feature SafeInteropWrappers %t/method.swift -dump-macro-expansions -typecheck -verify
// CHECK: class Foo {
// CHECK: func bar(_ p: UnsafeMutableBufferPointer<Float>)
//--- Inputs/module.modulemap
module Method {
header "method.h"
}
//--- Inputs/method.h
@interface Foo
-(void)bar:(float *)p count:(int)len __attribute__((swift_attr("@_SwiftifyImport(.countedBy(pointer: .param(1), count: \"len\"))")));
@end
//--- method.swift
import Method
func test(foo: Foo, s: UnsafeMutableBufferPointer<Float>) {
foo.bar(s)
}