Skip to content

Commit 9abe480

Browse files
authored
Merge pull request #1208 from swiftlang/jgrynspan/revert-1171
Revert "Work around a compiler regression affecting exit test value capturing. (#1171)"
2 parents 8517508 + 3980e9f commit 9abe480

File tree

3 files changed

+1
-55
lines changed

3 files changed

+1
-55
lines changed

Sources/Testing/Expectations/ExpectationChecking+Macro.swift

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1175,7 +1175,6 @@ public func __checkClosureCall(
11751175
///
11761176
/// - Warning: This function is used to implement the `#expect()` and
11771177
/// `#require()` macros. Do not call it directly.
1178-
#if SWT_FIXED_154221449
11791178
@_spi(Experimental)
11801179
public func __checkClosureCall<each T>(
11811180
identifiedBy exitTestID: (UInt64, UInt64, UInt64, UInt64),
@@ -1200,32 +1199,6 @@ public func __checkClosureCall<each T>(
12001199
sourceLocation: sourceLocation
12011200
)
12021201
}
1203-
#else
1204-
@_spi(Experimental)
1205-
public func __checkClosureCall<each T>(
1206-
identifiedBy exitTestID: (UInt64, UInt64, UInt64, UInt64),
1207-
encodingCapturedValues capturedValues: repeat each T,
1208-
processExitsWith expectedExitCondition: ExitTest.Condition,
1209-
observing observedValues: [any PartialKeyPath<ExitTest.Result> & Sendable] = [],
1210-
performing _: @convention(c) () -> Void,
1211-
expression: __Expression,
1212-
comments: @autoclosure () -> [Comment],
1213-
isRequired: Bool,
1214-
isolation: isolated (any Actor)? = #isolation,
1215-
sourceLocation: SourceLocation
1216-
) async -> Result<ExitTest.Result?, any Error> where repeat each T: Codable & Sendable {
1217-
await callExitTest(
1218-
identifiedBy: exitTestID,
1219-
encodingCapturedValues: Array(repeat each capturedValues),
1220-
processExitsWith: expectedExitCondition,
1221-
observing: observedValues,
1222-
expression: expression,
1223-
comments: comments(),
1224-
isRequired: isRequired,
1225-
sourceLocation: sourceLocation
1226-
)
1227-
}
1228-
#endif
12291202
#endif
12301203

12311204
// MARK: -

Sources/TestingMacros/ConditionMacro.swift

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -98,20 +98,7 @@ extension ConditionMacro {
9898
if let trailingClosureIndex {
9999
// Assume that the comment, if present is the last argument in the
100100
// argument list prior to the trailing closure that has no label.
101-
#if SWT_FIXED_154221449
102101
commentIndex = macroArguments[..<trailingClosureIndex].lastIndex { $0.label == nil }
103-
#else
104-
commentIndex = macroArguments[..<trailingClosureIndex].lastIndex { argument in
105-
guard argument.label == nil else {
106-
return false
107-
}
108-
if let expr = argument.expression.as(MacroExpansionExprSyntax.self),
109-
expr.macroName.tokenKind == .identifier("__capturedValue") {
110-
return false
111-
}
112-
return true
113-
}
114-
#endif
115102
} else if macroArguments.count > 1 {
116103
// If there is no trailing closure argument and there is more than one
117104
// argument, then the comment is the last argument with no label (and also
@@ -560,7 +547,6 @@ extension ExitTestConditionMacro {
560547
var leadingArguments = [
561548
Argument(label: "identifiedBy", expression: idExpr),
562549
]
563-
#if SWT_FIXED_154221449
564550
if !capturedValues.isEmpty {
565551
leadingArguments.append(
566552
Argument(
@@ -573,19 +559,6 @@ extension ExitTestConditionMacro {
573559
)
574560
)
575561
}
576-
#else
577-
if let firstCapturedValue = capturedValues.first {
578-
leadingArguments.append(
579-
Argument(
580-
label: "encodingCapturedValues",
581-
expression: firstCapturedValue.typeCheckedExpression
582-
)
583-
)
584-
leadingArguments += capturedValues.dropFirst()
585-
.map(\.typeCheckedExpression)
586-
.map { Argument(expression: $0) }
587-
}
588-
#endif
589562
arguments = leadingArguments + arguments
590563

591564
// Replace the exit test body (as an argument to the macro) with a stub

Sources/TestingMacros/Support/ClosureCaptureListParsing.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ struct CapturedValueInfo {
3636

3737
/// The expression to assign to the captured value with type-checking applied.
3838
var typeCheckedExpression: ExprSyntax {
39-
#"#__capturedValue(\#(expression.trimmed), \#(literal: name.trimmedDescription), \#(type.trimmed).self)"#
39+
#"#__capturedValue(\#(expression.trimmed), \#(literal: name.trimmedDescription), (\#(type.trimmed)).self)"#
4040
}
4141

4242
init(_ capture: ClosureCaptureSyntax, in context: some MacroExpansionContext) {

0 commit comments

Comments
 (0)