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) {
800800 return true ;
801801}
802802
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+
803821// / A type expressing the result of classifying whether a call or function
804822// / throws or is async.
805823class Classification {
@@ -928,7 +946,7 @@ class Classification {
928946
929947 result.ThrowKind = conditionalKind;
930948 result.ThrowReason = reason;
931- result.ThrownError = thrownError;
949+ result.ThrownError = typeEraseOpenedArchetypes ( thrownError) ;
932950 return result;
933951 }
934952
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