swiftlang / swift

The Swift Programming Language
https://swift.org
Apache License 2.0
67.67k stars 10.38k forks source link

[SR-1793] Type inference does not work with autoclosure #44402

Open swift-ci opened 8 years ago

swift-ci commented 8 years ago
Previous ID SR-1793
Radar rdar://problem/21786778
Original Reporter fpg1503 (JIRA User)
Type Bug
Environment Xcode 8.0 beta (8S128d) Playgrounds (Happens at least since Swift 2.0)
Additional Detail from JIRA | | | |------------------|-----------------| |Votes | 2 | |Component/s | Compiler | |Labels | Bug, TypeChecker | |Assignee | None | |Priority | Medium | md5: a6cf52ed16f45c857930e752fd76c7b6

is duplicated by:

Issue Description:

General Swift cannot infer autoclosure when you apply a high order function, i.e.

func reduceBools(values: [Bool]) -> Bool {
    return values.reduce(false, combine: ||)
}

Gives the error "Ambiguous reference to member '||'"

Expected results: Code compiles and works fine.

typesanitizer commented 4 years ago

Related question on Swift forums today: https://forums.swift.org/t/adding-autoclosure-breaks-the-functions-usage/37738