mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[SILGen] Correctly determine the thrown error type for closures
When a closure throws a generic error type, we were retrieving the substituted error type (involving archetypes) when we needed to be working with the interface type. Fixes rdar://124484012.
This commit is contained in:
@@ -1340,7 +1340,6 @@ AbstractionPattern::getFunctionThrownErrorType(
|
||||
if (!optOrigErrorType)
|
||||
return std::nullopt;
|
||||
|
||||
auto &ctx = substFnInterfaceType->getASTContext();
|
||||
auto substErrorType = substFnInterfaceType->getEffectiveThrownErrorType();
|
||||
|
||||
if (isTypeParameterOrOpaqueArchetype()) {
|
||||
@@ -1352,16 +1351,21 @@ AbstractionPattern::getFunctionThrownErrorType(
|
||||
}
|
||||
|
||||
if (!substErrorType) {
|
||||
if (optOrigErrorType->getType()->hasTypeParameter())
|
||||
substErrorType = ctx.getNeverType();
|
||||
else
|
||||
substErrorType = optOrigErrorType->getType();
|
||||
substErrorType = optOrigErrorType->getEffectiveThrownErrorType();
|
||||
}
|
||||
|
||||
return std::make_pair(*optOrigErrorType,
|
||||
(*substErrorType)->getCanonicalType());
|
||||
}
|
||||
|
||||
CanType AbstractionPattern::getEffectiveThrownErrorType() const {
|
||||
CanType type = getType();
|
||||
if (type->hasTypeParameter())
|
||||
return type->getASTContext().getNeverType()->getCanonicalType();
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
AbstractionPattern
|
||||
AbstractionPattern::getObjCMethodAsyncCompletionHandlerType(
|
||||
CanType swiftCompletionHandlerType) const {
|
||||
|
||||
Reference in New Issue
Block a user