When typechecking the constraint inout $T1 < UnsafeMutablePointer<Void>, bind $T1 to Void as a last resort.

Revert stdlib changes in r25921.

<rdar://problem/19835413> Reference to value from array changed

Swift SVN r25939
This commit is contained in:
Chris Willmore
2015-03-10 18:54:36 +00:00
parent c0bf1f54ff
commit 44da3ceb8c
3 changed files with 22 additions and 7 deletions

View File

@@ -1355,8 +1355,23 @@ ConstraintSystem::matchTypes(Type type1, Type type2, TypeMatchKind kind,
// A constraint that binds any pointer to a void pointer is
// ineffective, since any pointer can be converted to a void pointer.
if (kind == TypeMatchKind::BindToPointerType &&
desugar2->isEqual(getASTContext().TheEmptyTupleType)) {
return SolutionKind::Unsolved;
desugar2->isEqual(getASTContext().TheEmptyTupleType) &&
(flags & TMF_GenerateConstraints)) {
// Create a disjunction where the favored branch doesn't constrain
// anything but the unfavored branch binds type1 to Void. type1 only
// gets bound to Void as a last resort.
Constraint *trivialConstraint = Constraint::create(*this,
ConstraintKind::Bind, typeVar1, typeVar1, DeclName(),
getConstraintLocator(locator));
trivialConstraint->setFavored();
Constraint *bindingConstraint = Constraint::create(*this,
ConstraintKind::Bind, typeVar1, type2, DeclName(),
getConstraintLocator(locator));
Constraint *constraints[] = { trivialConstraint, bindingConstraint };
addConstraint(
Constraint::createDisjunction(*this, constraints,
getConstraintLocator(locator)));
return SolutionKind::Solved;
}
assignFixedType(typeVar1, type2);