Skip to content

Commit 76ed2cd

Browse files
authored
Merge pull request #32724 from xedin/rdar-65088975
[CSBindings] Open collection binding associated with @autoclosure arg…
2 parents cea9d5c + 739ba4b commit 76ed2cd

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

lib/Sema/CSBindings.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1034,7 +1034,8 @@ bool TypeVarBindingProducer::computeNext() {
10341034

10351035
auto srcLocator = binding.getLocator();
10361036
if (srcLocator &&
1037-
srcLocator->isLastElement<LocatorPathElt::ApplyArgToParam>() &&
1037+
(srcLocator->isLastElement<LocatorPathElt::ApplyArgToParam>() ||
1038+
srcLocator->isLastElement<LocatorPathElt::AutoclosureResult>()) &&
10381039
!type->hasTypeVariable() && type->isKnownStdlibCollectionType()) {
10391040
// If the type binding comes from the argument conversion, let's
10401041
// instead of binding collection types directly, try to bind

test/Constraints/argument_matching.swift

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1607,3 +1607,19 @@ struct DiagnoseAllLabels {
16071607
f(aax: 0, bbx: 1, dd: 3, ff: 5) // expected-error {{incorrect argument labels in call (have 'aax:bbx:dd:ff:', expected 'aa:bb:dd:ff:')}} {{7-10=aa}} {{15-18=bb}} {{none}}
16081608
}
16091609
}
1610+
1611+
// SR-13135: Type inference regression in Swift 5.3 - can't infer a type of @autoclosure result.
1612+
func sr13135() {
1613+
struct Foo {
1614+
var bar: [Int] = []
1615+
}
1616+
1617+
let baz: Int? = nil
1618+
1619+
func foo<T: Equatable>(
1620+
_ a: @autoclosure () throws -> T,
1621+
_ b: @autoclosure () throws -> T
1622+
) {}
1623+
1624+
foo(Foo().bar, [baz])
1625+
}

0 commit comments

Comments
 (0)