File tree Expand file tree Collapse file tree 2 files changed +37
-1
lines changed Expand file tree Collapse file tree 2 files changed +37
-1
lines changed Original file line number Diff line number Diff line change @@ -800,6 +800,24 @@ static bool isRethrowingDueToAsyncSequence(DeclContext *rethrowsDC) {
800
800
return true ;
801
801
}
802
802
803
+ // / Type-erase the opened archetypes in the given type, if there is one.
804
+ static Type typeEraseOpenedArchetypes (Type type) {
805
+ if (!type || !type->hasOpenedExistential ())
806
+ return type;
807
+
808
+ const OpenedArchetypeType *root = nullptr ;
809
+ type.visit ([&](Type type) {
810
+ if (auto opened = dyn_cast<OpenedArchetypeType>(type.getPointer ())) {
811
+ root = opened->getRoot ();
812
+ }
813
+ });
814
+
815
+ if (!root)
816
+ return type;
817
+
818
+ return constraints::typeEraseOpenedArchetypesWithRoot (type, root);
819
+ }
820
+
803
821
// / A type expressing the result of classifying whether a call or function
804
822
// / throws or is async.
805
823
class Classification {
@@ -928,7 +946,7 @@ class Classification {
928
946
929
947
result.ThrowKind = conditionalKind;
930
948
result.ThrowReason = reason;
931
- result.ThrownError = thrownError;
949
+ result.ThrownError = typeEraseOpenedArchetypes ( thrownError) ;
932
950
return result;
933
951
}
934
952
Original file line number Diff line number Diff line change
1
+ // RUN: %target-swift-frontend -disable-availability-checking %s -emit-sil -o /dev/null -verify
2
+
3
+ // RUN: %target-swift-frontend -disable-availability-checking %s -dump-ast 2>&1 | %FileCheck %s
4
+
5
+ // REQUIRES: concurrency
6
+
7
+ extension Error {
8
+ func printMe( ) { }
9
+ }
10
+
11
+ func test( seq: any AsyncSequence ) async {
12
+ // CHECK: "error" interface type="any Error"
13
+ do {
14
+ for try await _ in seq { }
15
+ } catch {
16
+ error. printMe ( )
17
+ }
18
+ }
You can’t perform that action at this time.
0 commit comments