Skip to content

Commit c972b83

Browse files
authored
Merge pull request #32728 from xedin/rdar-65088975-5.3
[5.3][CSBindings] Open collection binding associated with @autoclosure argument
2 parents f278447 + 6c68982 commit c972b83

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

lib/Sema/CSBindings.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1038,8 +1038,9 @@ bool TypeVarBindingProducer::computeNext() {
10381038

10391039
auto srcLocator = binding.getLocator();
10401040
if (srcLocator &&
1041-
srcLocator->isLastElement<LocatorPathElt::ApplyArgToParam>() &&
1042-
!type->hasTypeVariable() && CS.isCollectionType(type)) {
1041+
(srcLocator->isLastElement<LocatorPathElt::ApplyArgToParam>() ||
1042+
srcLocator->isLastElement<LocatorPathElt::AutoclosureResult>()) &&
1043+
!type->hasTypeVariable() && CS.isCollectionType(type)) {
10431044
// If the type binding comes from the argument conversion, let's
10441045
// instead of binding collection types directly, try to bind
10451046
// using temporary type variables substituted for element

test/Constraints/keyword_arguments.swift

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -874,3 +874,19 @@ func generic_and_missing_label<T>(x: T) {}
874874

875875
generic_and_missing_label(42)
876876
// expected-error@-1 {{missing argument label 'x:' in call}} {{27-27=x: }}
877+
878+
// SR-13135: Type inference regression in Swift 5.3 - can't infer a type of @autoclosure result.
879+
func sr13135() {
880+
struct Foo {
881+
var bar: [Int] = []
882+
}
883+
884+
let baz: Int? = nil
885+
886+
func foo<T: Equatable>(
887+
_ a: @autoclosure () throws -> T,
888+
_ b: @autoclosure () throws -> T
889+
) {}
890+
891+
foo(Foo().bar, [baz])
892+
}

0 commit comments

Comments
 (0)