Skip to content

Commit c8a02cc

Browse files
authored
Merge pull request #64443 from xedin/two-way-args-in-result-builders-reland
[CSSimplify] Don't enable `OneWayBindParam` for result builder transformed closures
2 parents 7fd2f52 + ff51291 commit c8a02cc

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
@@ -10996,8 +10996,7 @@ bool ConstraintSystem::resolveClosure(TypeVariableType *typeVar,
1099610996
// type as seen in the body of the closure and the external parameter
1099710997
// type.
1099810998
bool oneWayConstraints =
10999-
getASTContext().LangOpts.hasFeature(Feature::OneWayClosureParameters) ||
11000-
resultBuilderType;
10999+
getASTContext().LangOpts.hasFeature(Feature::OneWayClosureParameters);
1100111000

1100211001
auto *paramList = closure->getParameters();
1100311002
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
@@ -623,7 +623,7 @@ func wrapperifyInfer<T, U>(_ cond: Bool, @WrapperBuilder body: (U) -> T) -> T {
623623
}
624624

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

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

0 commit comments

Comments
 (0)