Begin making locators non-optional for constraints.

One difficulty in generating reasonable diagnostic data for type check failures has been the fact that many constraints had been synthesized without regard for where they were rooted in the program source. The result of this was that even though we would store failure information for specific constraints, we wouldn't emit it for lack of a source location. By making location data a non-optional component of constraints, we can begin diagnosing type check errors closer to their point of failure.

Swift SVN r18751
This commit is contained in:
Joe Pamer
2014-06-09 17:49:46 +00:00
parent ef75f7283a
commit 1914df72f3
12 changed files with 98 additions and 52 deletions

View File

@@ -153,7 +153,8 @@ namespace {
auto tv = CS.createTypeVariable(CS.getConstraintLocator(expr),
TVO_PrefersSubtypeBinding);
CS.addConstraint(ConstraintKind::ConformsTo, tv,
protocol->getDeclaredType());
protocol->getDeclaredType(),
CS.getConstraintLocator(CS.rootExpr));
return tv;
}
@@ -175,7 +176,8 @@ namespace {
auto tv = CS.createTypeVariable(CS.getConstraintLocator(expr),
TVO_PrefersSubtypeBinding);
CS.addConstraint(ConstraintKind::ConformsTo, tv,
interpolationProto->getDeclaredType());
interpolationProto->getDeclaredType(),
CS.getConstraintLocator(CS.rootExpr));
// Each of the segments is passed as an argument to
// convertFromStringInterpolationSegment().
@@ -464,7 +466,8 @@ namespace {
// open type.
for (size_t i = 0, size = specializations.size(); i < size; ++i) {
CS.addConstraint(ConstraintKind::Equal,
typeVars[i], specializations[i].getType());
typeVars[i], specializations[i].getType(),
CS.getConstraintLocator(CS.rootExpr));
}
return baseTy;