mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Don't offer incorrect fixit for NSString? -> String? conversion.
Update the locator when matching optional types in parallel fashion. This causes the simplifyLocator() call to fail to simplify the locator completely, and avoids the bogus diagnostic. <rdar://problem/19836341> Incorrect fixit for NSString? to String? conversions Swift SVN r25596
This commit is contained in:
@@ -3684,7 +3684,9 @@ ConstraintSystem::simplifyRestrictedConstraint(ConversionRestrictionKind restric
|
|||||||
assert(generic2->getDecl()->classifyAsOptionalType());
|
assert(generic2->getDecl()->classifyAsOptionalType());
|
||||||
return matchTypes(generic1->getGenericArgs()[0],
|
return matchTypes(generic1->getGenericArgs()[0],
|
||||||
generic2->getGenericArgs()[0],
|
generic2->getGenericArgs()[0],
|
||||||
matchKind, subFlags, locator);
|
matchKind, subFlags,
|
||||||
|
locator.withPathElement(
|
||||||
|
LocatorPathElt::getGenericArgument(0)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// T <c U ===> T! <c U
|
// T <c U ===> T! <c U
|
||||||
@@ -3705,7 +3707,9 @@ ConstraintSystem::simplifyRestrictedConstraint(ConversionRestrictionKind restric
|
|||||||
Type valueType1 = boundGenericType1->getGenericArgs()[0];
|
Type valueType1 = boundGenericType1->getGenericArgs()[0];
|
||||||
increaseScore(SK_ForceUnchecked);
|
increaseScore(SK_ForceUnchecked);
|
||||||
return matchTypes(valueType1, type2,
|
return matchTypes(valueType1, type2,
|
||||||
matchKind, subFlags, locator);
|
matchKind, subFlags,
|
||||||
|
locator.withPathElement(
|
||||||
|
LocatorPathElt::getGenericArgument(0)));
|
||||||
}
|
}
|
||||||
|
|
||||||
case ConversionRestrictionKind::ClassMetatypeToAnyObject:
|
case ConversionRestrictionKind::ClassMetatypeToAnyObject:
|
||||||
|
|||||||
@@ -233,3 +233,10 @@ func rdar19831698() {
|
|||||||
var v73 = true + [] // expected-error{{binary operator '+' cannot be applied to operands of type 'Bool' and 'NSArray'}}
|
var v73 = true + [] // expected-error{{binary operator '+' cannot be applied to operands of type 'Bool' and 'NSArray'}}
|
||||||
var v75 = true + "str" // expected-error{{binary operator '+' cannot be applied to operands of type 'Bool' and 'String'}} expected-note{{}}
|
var v75 = true + "str" // expected-error{{binary operator '+' cannot be applied to operands of type 'Bool' and 'String'}} expected-note{{}}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// <rdar://problem/19836341> Incorrect fixit for NSString? to String? conversions
|
||||||
|
func rdar19836341(s: NSString?) {
|
||||||
|
let x: String? = s // expected-error{{'NSString?' is not convertible to 'String?'}}
|
||||||
|
// FIXME: there should be a fixit appending "as String?" to the line; for now
|
||||||
|
// it's sufficient that it doesn't suggest appending "as String"
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user