mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Add upcoming feature ImplicitOpenExistentials for SE-0352
To maintain source compatibility, SE-0352 does not open existentials with "self-conforming" type, such as `any Error` or existentials based on `@objc` protocols. The proposal specified that this behavior would change in Swift 6. Implement that behavior change, which can be enabled prior to Swift 6 with the upcoming feature `ImplicitOpenExistentials` (as documented in SE-0362). Fixes #70873 / rdar://120902975.
This commit is contained in:
@@ -1578,10 +1578,13 @@ shouldOpenExistentialCallArgument(ValueDecl *callee, unsigned paramIdx,
|
||||
return std::nullopt;
|
||||
|
||||
// If the existential argument conforms to all of protocol requirements on
|
||||
// the formal parameter's type, don't open.
|
||||
// the formal parameter's type, don't open unless ImplicitOpenExistentials is
|
||||
// enabled.
|
||||
|
||||
// If all of the conformance requirements on the formal parameter's type
|
||||
// are self-conforming, don't open.
|
||||
{
|
||||
ASTContext &ctx = argTy->getASTContext();
|
||||
if (!ctx.LangOpts.hasFeature(Feature::ImplicitOpenExistentials)) {
|
||||
Type existentialObjectType;
|
||||
if (auto existentialMetaTy = argTy->getAs<ExistentialMetatypeType>())
|
||||
existentialObjectType = existentialMetaTy->getInstanceType();
|
||||
|
||||
Reference in New Issue
Block a user