SILGen: Fix crash when thrown error type is loadable and has a type parameter

Fixes https://github.com/swiftlang/swift/issues/74289.
Fixes rdar://problem/146677409.
This commit is contained in:
Slava Pestov
2025-04-29 10:48:20 -04:00
parent e3d8e356cb
commit 89ab18ce39
2 changed files with 10 additions and 1 deletions

View File

@@ -83,10 +83,12 @@ void SILGenFunction::prepareEpilog(
void SILGenFunction::prepareRethrowEpilog(
DeclContext *dc, AbstractionPattern origErrorType, Type errorType,
CleanupLocation cleanupLoc) {
ASSERT(!errorType->hasPrimaryArchetype());
SILBasicBlock *rethrowBB = createBasicBlock(FunctionSection::Postmatter);
if (!IndirectErrorResult) {
SILType loweredErrorType = getLoweredType(origErrorType, errorType);
auto errorTypeInContext = dc->mapTypeIntoContext(errorType);
SILType loweredErrorType = getLoweredType(origErrorType, errorTypeInContext);
rethrowBB->createPhiArgument(loweredErrorType, OwnershipKind::Owned);
}