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