Do not penalize optional-to-optional conversions when processing the associated value-to-optional conversions. Doing so can result in incorrect ambiguity errors when applying optional-typed arguments to function overload sets with optional and non-optional parameter types. (Hitlisted: rdar://problem/18028526)

Swift SVN r21264
This commit is contained in:
Joe Pamer
2014-08-18 22:30:07 +00:00
parent 22ea43e1bb
commit 1bdf86437f
2 changed files with 10 additions and 1 deletions

View File

@@ -3401,7 +3401,13 @@ ConstraintSystem::simplifyRestrictedConstraint(ConversionRestrictionKind restric
// T $< U ===> T $< U?
case ConversionRestrictionKind::ValueToOptional: {
addContextualScore();
increaseScore(SK_ValueToOptional);
// Do not penalize the conversion if it's really optional-to-optional.
if (!(type1->getAnyOptionalObjectType() &&
type2->getAnyOptionalObjectType())) {
increaseScore(SK_ValueToOptional);
}
assert(matchKind >= TypeMatchKind::Subtype);
auto generic2 = type2->castTo<BoundGenericType>();
assert(generic2->getDecl()->classifyAsOptionalType());