Revert "Revert "A couple of 'throws' inference fix-ups:""

This reverts commit r27576.

(In some cases of catastrophic error recovery, ctor types may still be null during constraint solving, so it was wrong of me to assume otherwise.)

Swift SVN r27599
This commit is contained in:
Joe Pamer
2015-04-22 20:34:05 +00:00
parent b0497db5ec
commit 220c92a09b
3 changed files with 32 additions and 4 deletions

View File

@@ -2246,6 +2246,21 @@ ConstraintSystem::simplifyConstructionConstraint(Type valueType,
return SolutionKind::Error;
}
auto extInfo = FunctionType::ExtInfo();
// Check to see if the initializer's overload group throws.
for (auto ctor : ctors) {
if (ctor->getType() && ctor->getType()->getAs<AnyFunctionType>()) {
if (auto innerFnTy = ctor->getType()->getAs<AnyFunctionType>()->
getResult()->getAs<AnyFunctionType>()) {
if (innerFnTy->throws()) {
extInfo = extInfo.withThrows();
break;
}
}
}
}
auto &context = getASTContext();
auto name = context.Id_init;
@@ -2258,7 +2273,7 @@ ConstraintSystem::simplifyConstructionConstraint(Type valueType,
// variable T. T2 is the result type provided via the construction
// constraint itself.
addValueMemberConstraint(valueType, name,
FunctionType::get(tv, resultType),
FunctionType::get(tv, resultType, extInfo),
getConstraintLocator(
locator,
ConstraintLocator::ConstructorMember));