Skip to content

Commit cdce937

Browse files
committed
Beginning changes to provide more info out about unresolved params, but even
changing is<UnresolvedType> to hasUnresolvedType turns out is enough to fix a radar.
1 parent a76d74b commit cdce937

File tree

2 files changed

+12
-15
lines changed

2 files changed

+12
-15
lines changed

lib/Sema/CalleeCandidateInfo.cpp

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -376,11 +376,6 @@ CalleeCandidateInfo::evaluateCloseness(UncurriedCandidate candidate,
376376
auto argType = getParamResultType(actualArgs[argNo]);
377377
auto rArgType = argType->getRValueType();
378378

379-
// If the argument has an unresolved type, then we're not actually
380-
// matching against it.
381-
if (rArgType->is<UnresolvedType>())
382-
continue;
383-
384379
// FIXME: Right now, a "matching" overload is one with a parameter whose
385380
// type is identical to the argument type, or substitutable via handling
386381
// of functions with primary archetypes in one or more parameters.
@@ -391,7 +386,7 @@ CalleeCandidateInfo::evaluateCloseness(UncurriedCandidate candidate,
391386
bool matched;
392387
if (paramType->hasUnresolvedType())
393388
matched = true;
394-
else if (rArgType->hasTypeVariable())
389+
else if (rArgType->hasTypeVariable() || rArgType->hasUnresolvedType())
395390
matched = false;
396391
else {
397392
auto matchType = paramType;
@@ -476,10 +471,14 @@ CalleeCandidateInfo::evaluateCloseness(UncurriedCandidate candidate,
476471
if (matched)
477472
continue;
478473

479-
if (archetypesMap.empty())
480-
mismatchesAreNearMisses &= argumentMismatchIsNearMiss(argType, paramType);
481-
482-
++mismatchingArgs;
474+
// If the real argument is unresolved, the candidate isn't a mismatch because
475+
// the type could be anything, but it's still useful to save the argument as
476+
// failureInfo.
477+
if (!rArgType->hasUnresolvedType()) {
478+
if (archetypesMap.empty())
479+
mismatchesAreNearMisses &= argumentMismatchIsNearMiss(argType, paramType);
480+
++mismatchingArgs;
481+
}
483482

484483
failureInfo.argumentNumber = argNo;
485484
failureInfo.parameterType = paramType;
@@ -489,7 +488,7 @@ CalleeCandidateInfo::evaluateCloseness(UncurriedCandidate candidate,
489488
}
490489

491490
if (mismatchingArgs == 0)
492-
return { CC_ExactMatch, {}};
491+
return { CC_ExactMatch, failureInfo};
493492

494493
// Check to see if the first argument expects an inout argument, but is not
495494
// an lvalue.

test/Constraints/diagnostics.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ func ***~(_: Int, _: String) { }
139139
i ***~ i // expected-error{{cannot convert value of type 'Int' to expected argument type 'String'}}
140140

141141
@available(*, unavailable, message: "call the 'map()' method on the sequence")
142-
public func myMap<C : Collection, T>(
142+
public func myMap<C : Collection, T>( // expected-note {{'myMap' has been explicitly marked unavailable here}}
143143
_ source: C, _ transform: (C.Iterator.Element) -> T
144144
) -> [T] {
145145
fatalError("unavailable function can't be called")
@@ -151,10 +151,8 @@ public func myMap<T, U>(_ x: T?, _ f: (T) -> U) -> U? {
151151
}
152152

153153
// <rdar://problem/20142523>
154-
// FIXME: poor diagnostic, to be fixed in 20142462. For now, we just want to
155-
// make sure that it doesn't crash.
156154
func rdar20142523() {
157-
myMap(0..<10, { x in // expected-error{{ambiguous reference to member '..<'}}
155+
myMap(0..<10, { x in // expected-error{{'myMap' is unavailable: call the 'map()' method on the sequence}}
158156
()
159157
return x
160158
})

0 commit comments

Comments
 (0)