Skip to content

Commit ec463f9

Browse files
authored
Disfavor overloads of __checkFunctionCall() with variadic generics. (#1389)
This works around rdar://122011759 which appears to have been exacerbated by swiftlang/swift#84907. For example: ```swift let file = try #require(fmemopen(nil, 1, "wb+")) ``` The third parameter of `fmemopen()` is of type `const char *` (AKA `UnsafePointer<CChar>`) and we're passing the string literal `"wb+"` which is implicitly cast to a C string by the compiler. However, overload resolution of the expansion function used by `#require()` is now preferring an overload that uses variadic generics, and that overload is impacted by a compiler issue (rdar://122011759) that causes it to pass a garbage pointer as the temporary C string. Previously, the type checker would pick an overload with a concrete, finite set of generic arguments (`<T, Arg0, Arg1, Arg2, R>` instead of `<T, each U, R>`.) ### Checklist: - [x] Code and documentation should follow the style of the [Style Guide](https://github.com/apple/swift-testing/blob/main/Documentation/StyleGuide.md). - [x] If public symbols are renamed or modified, DocC references should be updated.
1 parent 664d24f commit ec463f9

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

Sources/Testing/Expectations/ExpectationChecking+Macro.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ private func _callBinaryOperator<T, U, R>(
198198
///
199199
/// - Warning: This function is used to implement the `#expect()` and
200200
/// `#require()` macros. Do not call it directly.
201+
@_disfavoredOverload
201202
public func __checkFunctionCall<T, each U>(
202203
_ lhs: T, calling functionCall: (T, repeat each U) throws -> Bool, _ arguments: repeat each U,
203204
expression: __Expression,
@@ -367,6 +368,7 @@ public func __checkInoutFunctionCall<T, /*each*/ U>(
367368
///
368369
/// - Warning: This function is used to implement the `#expect()` and
369370
/// `#require()` macros. Do not call it directly.
371+
@_disfavoredOverload
370372
public func __checkFunctionCall<T, each U, R>(
371373
_ lhs: T, calling functionCall: (T, repeat each U) throws -> R?, _ arguments: repeat each U,
372374
expression: __Expression,

0 commit comments

Comments
 (0)