Skip to content

Commit 9888ffd

Browse files
authored
Merge pull request #63140 from xedin/two-way-args-in-result-builders
[CSSimplify] Don't enable `OneWayBindParam` for result builder transf…
2 parents a18eebf + 5659d7e commit 9888ffd

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

lib/Sema/CSSimplify.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10879,8 +10879,7 @@ bool ConstraintSystem::resolveClosure(TypeVariableType *typeVar,
1087910879
// type as seen in the body of the closure and the external parameter
1088010880
// type.
1088110881
bool oneWayConstraints =
10882-
getASTContext().LangOpts.hasFeature(Feature::OneWayClosureParameters) ||
10883-
resultBuilderType;
10882+
getASTContext().LangOpts.hasFeature(Feature::OneWayClosureParameters);
1088410883

1088510884
auto *paramList = closure->getParameters();
1088610885
SmallVector<AnyFunctionType::Param, 4> parameters;

test/Constraints/result_builder_diags.swift

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -622,7 +622,7 @@ func wrapperifyInfer<T, U>(_ cond: Bool, @WrapperBuilder body: (U) -> T) -> T {
622622
}
623623

624624
let intValue = 17
625-
wrapperifyInfer(true) { x in // expected-error{{unable to infer type of a closure parameter 'x' in the current context}}
625+
_ = wrapperifyInfer(true) { x in // Ok
626626
intValue + x
627627
}
628628

@@ -1000,3 +1000,17 @@ func test_requirement_failure_in_buildBlock() {
10001000
}
10011001
}
10021002
}
1003+
1004+
func test_partially_resolved_closure_params() {
1005+
struct S<T> {
1006+
var a: String = ""
1007+
}
1008+
1009+
func test<T>(@TupleBuilder _: (S<T>) -> T) { // expected-note {{in call to function 'test'}}
1010+
}
1011+
1012+
test { // expected-error {{generic parameter 'T' could not be inferred}}
1013+
$0.a
1014+
42
1015+
}
1016+
}

0 commit comments

Comments
 (0)