mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
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:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -387,3 +387,10 @@ extension ReducedError where T == MyError {
|
||||
throw MyError.fail
|
||||
}
|
||||
}
|
||||
|
||||
// https://github.com/swiftlang/swift/issues/74289
|
||||
struct LoadableGeneric<E>: Error {}
|
||||
|
||||
func throwsLoadableGeneric<E>(_: E) throws(LoadableGeneric<E>) {
|
||||
throw LoadableGeneric<E>()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user