Skip to content

Commit 20b72a1

Browse files
authored
Merge pull request #71219 from DougGregor/abstraction-pattern-typed-throws-bad-assert
[Abstraction pattern] Eliminate unnecessary assertion for typed throws
2 parents f777d1d + f610dcf commit 20b72a1

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

lib/SIL/IR/AbstractionPattern.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1270,11 +1270,6 @@ AbstractionPattern::getFunctionThrownErrorType(
12701270
if (!substErrorType)
12711271
return llvm::None;
12721272

1273-
if (!(*substErrorType)->isEqual(ctx.getErrorExistentialType())) {
1274-
llvm::errs() << "unsupported reabstraction\n";
1275-
abort();
1276-
}
1277-
12781273
return std::make_pair(AbstractionPattern(*substErrorType),
12791274
(*substErrorType)->getCanonicalType());
12801275
}

test/IRGen/typed_throws.swift

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
// XFAIL: CPU=arm64e
88
// REQUIRES: PTRSIZE=64
99

10-
enum MyBigError: Error {
10+
public enum MyBigError: Error {
1111
case epicFail
1212
}
1313

@@ -22,6 +22,10 @@ func createsP() {
2222
requiresP(X.self)
2323
}
2424

25+
// This is for TypeH.method
26+
// CHECK-NOMANGLE: @"$s12typed_throws5TypeHV6methodySSSiAA10MyBigErrorOYKcvpMV" =
27+
28+
2529
// CHECK-LABEL: define {{.*}}hidden swiftcc ptr @"$s12typed_throws13buildMetatypeypXpyF"()
2630
func buildMetatype() -> Any.Type {
2731
typealias Fn = (Int) throws(MyBigError) -> Void
@@ -78,3 +82,8 @@ func callee() throws (S) {
7882
func testit() throws (S) {
7983
try callee()
8084
}
85+
86+
// Used to crash in abstract pattern creation.
87+
public struct TypeH {
88+
public var method: (Int) throws(MyBigError) -> String
89+
}

0 commit comments

Comments
 (0)