Skip to content

Commit b2ddbe4

Browse files
authored
Merge pull request swiftlang#74511 from hborla/6.0-reduced-error-type
[6.0][SILGen] Compute the reduced thrown error type when emitting a function prolog and epilog.
2 parents ad8b4b0 + 4b62682 commit b2ddbe4

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

lib/SILGen/SILGenEpilog.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ void SILGenFunction::prepareEpilog(
6565

6666
if (errorType) {
6767
auto genericSig = DC->getGenericSignatureOfContext();
68+
errorType = (*errorType)->getReducedType(genericSig);
6869
AbstractionPattern origErrorType = TypeContext
6970
? *TypeContext->OrigType.getFunctionThrownErrorType()
7071
: AbstractionPattern(genericSig.getCanonicalSignature(),

lib/SILGen/SILGenProlog.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1548,6 +1548,8 @@ uint16_t SILGenFunction::emitBasicProlog(
15481548
// Create the indirect result parameters.
15491549
auto genericSig = DC->getGenericSignatureOfContext();
15501550
resultType = resultType->getReducedType(genericSig);
1551+
if (errorType)
1552+
errorType = (*errorType)->getReducedType(genericSig);
15511553

15521554
std::optional<AbstractionPattern> origClosureType;
15531555
if (TypeContext) origClosureType = TypeContext->OrigType;

test/SILGen/typed_throws_generic.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,3 +378,12 @@ struct GSF2<F: Error, T>: P2 {
378378
struct GSA<T>: P2 {
379379
typealias Failure = any Error
380380
}
381+
382+
struct ReducedError<T: Error> {}
383+
384+
extension ReducedError where T == MyError {
385+
// CHECK-LABEL: sil hidden [ossa] @$s20typed_throws_generic12ReducedErrorVA2A02MyE0ORszrlE05throwfE0yyAEYKF : $@convention(method) (ReducedError<MyError>) -> @error MyError {
386+
func throwMyError() throws(T) {
387+
throw MyError.fail
388+
}
389+
}

0 commit comments

Comments
 (0)