[Sema] Fix issue 65330 Unhelpful error when missing contextually required as bridging conversion to AnyObject in structural position. Minor formatting change in previous test case

This commit is contained in:
jreference
2023-04-30 10:19:02 +08:00
parent 2338b4cce3
commit 2cf01a18de
5 changed files with 89 additions and 20 deletions

View File

@@ -1934,18 +1934,10 @@ bool AllowNonClassTypeToConvertToAnyObject::diagnose(const Solution &solution,
bool asNote) const {
auto *locator = getLocator();
if (locator->isForContextualType()) {
ContextualFailure failure(solution, getFromType(), getToType(), locator);
return failure.diagnose(asNote);
}
NonClassTypeToAnyObjectConversionFailure failure(solution, getFromType(),
getToType(), locator);
if (locator->isLastElement<LocatorPathElt::ApplyArgToParam>()) {
ArgumentMismatchFailure failure(solution, getFromType(), getToType(),
locator);
return failure.diagnose(asNote);
}
return false;
return failure.diagnose(asNote);
}
AllowNonClassTypeToConvertToAnyObject *