Skip to content

Commit 454019a

Browse files
authored
Merge pull request #62070 from hborla/any-with-implicit-some
[Sema] Fix an issue with existential return types when implicit some is enabled.
2 parents c711e7b + ee04cea commit 454019a

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

lib/AST/Decl.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3079,8 +3079,11 @@ TypeRepr *ValueDecl::getOpaqueResultTypeRepr() const {
30793079

30803080
if (returnRepr && returnRepr->hasOpaque()) {
30813081
return returnRepr;
3082-
} else if (returnRepr && ctx.LangOpts.hasFeature(Feature::ImplicitSome) && returnRepr->isProtocol(dc)) {
3083-
return returnRepr;
3082+
} else if (returnRepr && ctx.LangOpts.hasFeature(Feature::ImplicitSome)) {
3083+
auto opaqueReprs = collectOpaqueReturnTypeReprs(returnRepr,
3084+
getASTContext(),
3085+
getDeclContext());
3086+
return opaqueReprs.empty() ? nullptr : returnRepr;
30843087
} else {
30853088
return nullptr;
30863089
}

test/type/implicit_some/opaque_return.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,4 +112,6 @@ protocol P {
112112

113113
struct S: P {
114114
var value: P { self }
115+
116+
var asExistential: any P { self }
115117
}

0 commit comments

Comments
 (0)