Skip to content

Commit d23adf4

Browse files
authored
Merge pull request #80273 from slavapestov/fix-issue-80020
IRGen: Fix assertion failure with typed throws
2 parents 1c395e2 + ad181b9 commit d23adf4

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

lib/IRGen/IRGenSIL.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -4040,8 +4040,9 @@ void IRGenSILFunction::visitFullApplySite(FullApplySite site) {
40404040
Builder.emitBlock(typedErrorLoadBB);
40414041

40424042
auto &errorTI = cast<LoadableTypeInfo>(IGM.getTypeInfo(errorType));
4043-
auto silResultTy = CurSILFn->mapTypeIntoContext(
4044-
substConv.getSILResultType(IGM.getMaximalTypeExpansionContext()));
4043+
auto silResultTy =
4044+
substConv.getSILResultType(IGM.getMaximalTypeExpansionContext());
4045+
ASSERT(!silResultTy.hasTypeParameter());
40454046
auto &resultTI = cast<LoadableTypeInfo>(IGM.getTypeInfo(silResultTy));
40464047

40474048
auto &resultSchema = resultTI.nativeReturnValueSchema(IGM);

test/IRGen/typed_throws_generic.swift

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// RUN: %target-swift-frontend -primary-file %s -emit-irgen
2+
3+
// https://github.com/swiftlang/swift/issues/80020
4+
//
5+
// We used to assert if you had a loadable return type that contained
6+
// a generic parameter.
7+
8+
public enum MyError: Error {
9+
case error
10+
}
11+
12+
public struct G<T> {} // Note: G<T> is loadable
13+
14+
public func f<T>(t: T) throws(MyError) -> G<T> {
15+
return G<T>()
16+
}
17+
18+
public func g<U>(u: U?) throws(MyError) -> G<U?> {
19+
return try f(t: u)
20+
}

0 commit comments

Comments
 (0)