mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Previously we would only add @_disfavoredOverload if the only type changed was the return type, because in any other case it is unambiguous which overload to call. However it is still ambiguous when storing the function as a value rather than calling the function, unless explicit type annotations are used. To avoid breaking any existing code, this patch adds @_disfavoredOverload to every overload generated by @_SwiftifyImport. rdar://151206394
22 lines
1.3 KiB
Swift
22 lines
1.3 KiB
Swift
// REQUIRES: swift_feature_SafeInteropWrappers
|
|
|
|
// RUN: %target-swift-ide-test -print-module -module-to-print=NoSwiftifyClang -plugin-path %swift-plugin-dir -I %S/Inputs -source-filename=x -enable-experimental-feature SafeInteropWrappers | %FileCheck %s
|
|
|
|
// RUN: %empty-directory(%t)
|
|
// RUN: %target-swift-frontend -emit-module -plugin-path %swift-plugin-dir -o %t/NoSwiftify.swiftmodule -I %S/Inputs -enable-experimental-feature SafeInteropWrappers %s -verify -verify-additional-file %S/Inputs/objc-no-swiftify.h
|
|
|
|
import NoSwiftifyClang
|
|
|
|
// CHECK-NOT: @_alwaysEmitIntoClient @_disfavoredOverload public func callAutoreleaseParam
|
|
// CHECK-NOT: @_alwaysEmitIntoClient @_disfavoredOverload public func callAutoreleaseReturn
|
|
|
|
public func callAutoreleaseParam(_ p: UnsafeMutableBufferPointer<SomeClass>) {
|
|
// expected-error@+2{{missing argument for parameter #2 in call}}
|
|
// expected-error@+1{{cannot convert value of type 'UnsafeMutableBufferPointer<SomeClass>' to expected argument type 'AutoreleasingUnsafeMutablePointer<SomeClass?>'}}
|
|
autoreleaseParam(p)
|
|
}
|
|
|
|
public func callAutoreleaseReturn() {
|
|
// expected-error@+1{{cannot convert value of type 'AutoreleasingUnsafeMutablePointer<SomeClass?>?' to specified type 'UnsafeMutableBufferPointer<SomeClass>'}}
|
|
let p: UnsafeMutableBufferPointer<SomeClass> = autoreleaseReturn(10)
|
|
} |