Skip to content

Commit 3fb446d

Browse files
authored
Merge pull request #69585 from DougGregor/typed-throws-canonicalization-fix
Improve canonicalization of generic types with thrown errors
2 parents fd09c47 + b6c4b36 commit 3fb446d

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

lib/AST/Type.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4168,15 +4168,20 @@ ClangTypeInfo AnyFunctionType::getCanonicalClangTypeInfo() const {
41684168
ASTExtInfo
41694169
AnyFunctionType::getCanonicalExtInfo(bool useClangFunctionType) const {
41704170
assert(hasExtInfo());
4171+
4172+
CanGenericSignature genericSig;
4173+
if (auto *genericFnTy = dyn_cast<GenericFunctionType>(this))
4174+
genericSig = genericFnTy->getGenericSignature().getCanonicalSignature();
4175+
41714176
Type globalActor = getGlobalActor();
41724177
if (globalActor)
4173-
globalActor = globalActor->getCanonicalType();
4178+
globalActor = globalActor->getReducedType(genericSig);
41744179

41754180
// When there is an explicitly-specified thrown error, canonicalize it's type.
41764181
auto bits = Bits.AnyFunctionType.ExtInfoBits;
41774182
Type thrownError = getThrownError();
41784183
if (thrownError) {
4179-
thrownError = thrownError->getCanonicalType();
4184+
thrownError = thrownError->getReducedType(genericSig);
41804185

41814186
// - If the thrown error is `any Error`, the function throws and we
41824187
// drop the thrown error.

0 commit comments

Comments
 (0)