mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
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:
@@ -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());
|
||||
|
||||
Reference in New Issue
Block a user