Skip to content

[CSBindings] Open collection binding associated with @autoclosure arg… #32724

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/Sema/CSBindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1034,7 +1034,8 @@ bool TypeVarBindingProducer::computeNext() {

auto srcLocator = binding.getLocator();
if (srcLocator &&
srcLocator->isLastElement<LocatorPathElt::ApplyArgToParam>() &&
(srcLocator->isLastElement<LocatorPathElt::ApplyArgToParam>() ||
srcLocator->isLastElement<LocatorPathElt::AutoclosureResult>()) &&
!type->hasTypeVariable() && type->isKnownStdlibCollectionType()) {
// If the type binding comes from the argument conversion, let's
// instead of binding collection types directly, try to bind
Expand Down
16 changes: 16 additions & 0 deletions test/Constraints/argument_matching.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1607,3 +1607,19 @@ struct DiagnoseAllLabels {
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}}
}
}

// SR-13135: Type inference regression in Swift 5.3 - can't infer a type of @autoclosure result.
func sr13135() {
struct Foo {
var bar: [Int] = []
}

let baz: Int? = nil

func foo<T: Equatable>(
_ a: @autoclosure () throws -> T,
_ b: @autoclosure () throws -> T
) {}

foo(Foo().bar, [baz])
}