Sema: Better fix for banning the '() -> T' => '() -> ()?' implicit conversion

Previously we would check TMF_UnwrappingOptional flag, which does not
stick with the constraint, so it would not always persist. Now, add a
new OptionalPayload locator element, which is more correct.

Fixes <rdar://problem/30429709>.
This commit is contained in:
Slava Pestov
2017-02-13 16:46:42 -08:00
parent c5b74af5ae
commit e9c255bfca
4 changed files with 18 additions and 1 deletions

View File

@@ -3874,7 +3874,8 @@ ConstraintSystem::simplifyRestrictedConstraintImpl(
if (generic2->getDecl()->classifyAsOptionalType()) {
return matchTypes(type1, generic2->getGenericArgs()[0],
matchKind, (subflags | TMF_UnwrappingOptional),
locator);
locator.withPathElement(
ConstraintLocator::OptionalPayload));
}
}