mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[Diagnostics] Use argument mismatch fix for @autoclosure result positions
`@autoclosure` is associated with a parameter, we use argument mismatch fix
to diagnose missing explicit calls as well as any mismatches in that position.
Resolves: rdar://110527062
(cherry picked from commit b3e9cf3424)
This commit is contained in:
@@ -4282,7 +4282,8 @@ ConstraintSystem::matchExistentialTypes(Type type1, Type type2,
|
||||
if (!path.empty()) {
|
||||
auto last = path.back();
|
||||
|
||||
if (last.is<LocatorPathElt::ApplyArgToParam>()) {
|
||||
if (last.is<LocatorPathElt::ApplyArgToParam>() ||
|
||||
last.is<LocatorPathElt::AutoclosureResult>()) {
|
||||
auto proto = protoDecl->getDeclaredInterfaceType();
|
||||
// Impact is 2 here because there are two failures
|
||||
// 1 - missing conformance and 2 - incorrect argument type.
|
||||
|
||||
@@ -1337,3 +1337,13 @@ func rdar143338891() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
do {
|
||||
struct V {
|
||||
init(value: @autoclosure @escaping () -> any Hashable) { }
|
||||
init(other: @autoclosure @escaping () -> String) { }
|
||||
}
|
||||
|
||||
let _ = V(value: { [Int]() }) // expected-error {{add () to forward '@autoclosure' parameter}} {{31-31=()}}
|
||||
let _ = V(other: { [Int]() }) // expected-error {{cannot convert value of type '[Int]' to closure result type 'String'}}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user