Skip to content

Commit 0597b8d

Browse files
authored
Merge pull request #59740 from hborla/remove-existential-opening-option
[LangOptions] Remove the option to enable/disable implicit existential opening.
2 parents 3cf948b + 5901cd1 commit 0597b8d

11 files changed

+16
-27
lines changed

include/swift/Basic/LangOptions.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -317,10 +317,6 @@ namespace swift {
317317
/// Enable experimental concurrency model.
318318
bool EnableExperimentalConcurrency = false;
319319

320-
/// Enable support for implicitly opening existential argument types
321-
/// in calls to generic functions.
322-
bool EnableOpenedExistentialTypes = false;
323-
324320
/// Disable experimental ClangImporter diagnostics.
325321
bool DisableExperimentalClangImporterDiagnostics = false;
326322

lib/Frontend/CompilerInvocation.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -450,11 +450,6 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
450450
Opts.EnableExperimentalConcurrency |=
451451
Args.hasArg(OPT_enable_experimental_concurrency);
452452

453-
Opts.EnableOpenedExistentialTypes =
454-
Args.hasFlag(OPT_enable_experimental_opened_existential_types,
455-
OPT_disable_experimental_opened_existential_types,
456-
true);
457-
458453
Opts.EnableInferPublicSendable |=
459454
Args.hasFlag(OPT_enable_infer_public_concurrent_value,
460455
OPT_disable_infer_public_concurrent_value,

lib/Sema/CSSimplify.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1519,10 +1519,6 @@ shouldOpenExistentialCallArgument(
15191519
if (isa_and_nonnull<clang::FunctionTemplateDecl>(callee->getClangDecl()))
15201520
return None;
15211521

1522-
ASTContext &ctx = callee->getASTContext();
1523-
if (!ctx.LangOpts.EnableOpenedExistentialTypes)
1524-
return None;
1525-
15261522
// The actual parameter type needs to involve a type variable, otherwise
15271523
// type inference won't be possible.
15281524
if (!paramTy->hasTypeVariable())

lib/Sema/TypeCheckCodeCompletion.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,11 @@ TypeChecker::getTypeOfCompletionOperator(DeclContext *DC, Expr *LHS,
482482
// Build temporary expression to typecheck.
483483
// We allocate these expressions on the stack because we know they can't
484484
// escape and there isn't a better way to allocate scratch Expr nodes.
485+
486+
// Use a placeholder expr for the LHS argument to avoid sending
487+
// a pre-type-checked AST through the constraint system.
488+
OpaqueValueExpr argExpr(LHS->getSourceRange(), LHSTy,
489+
/*isPlaceholder=*/true);
485490
UnresolvedDeclRefExpr UDRE(DeclNameRef(opName), refKind, DeclNameLoc(Loc));
486491
auto *opExpr = TypeChecker::resolveDeclRefExpr(
487492
&UDRE, DC, /*replaceInvalidRefsWithErrors=*/true);
@@ -493,7 +498,7 @@ TypeChecker::getTypeOfCompletionOperator(DeclContext *DC, Expr *LHS,
493498
// (declref_expr name=<opName>)
494499
// (argument_list
495500
// (<LHS>)))
496-
auto *postfixExpr = PostfixUnaryExpr::create(ctx, opExpr, LHS);
501+
auto *postfixExpr = PostfixUnaryExpr::create(ctx, opExpr, &argExpr);
497502
return getTypeOfCompletionOperatorImpl(DC, postfixExpr, referencedDecl);
498503
}
499504

@@ -504,7 +509,7 @@ TypeChecker::getTypeOfCompletionOperator(DeclContext *DC, Expr *LHS,
504509
// (<LHS>)
505510
// (code_completion_expr)))
506511
CodeCompletionExpr dummyRHS(Loc);
507-
auto *binaryExpr = BinaryExpr::create(ctx, LHS, opExpr, &dummyRHS,
512+
auto *binaryExpr = BinaryExpr::create(ctx, &argExpr, opExpr, &dummyRHS,
508513
/*implicit*/ true);
509514
return getTypeOfCompletionOperatorImpl(DC, binaryExpr, referencedDecl);
510515
}

test/Constraints/openExistential.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
// RUN: %target-typecheck-verify-swift
2-
// RUN: %target-typecheck-verify-swift -enable-experimental-opened-existential-types
32

43
protocol P { }
54

test/Constraints/opened_existentials.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-typecheck-verify-swift -enable-experimental-opened-existential-types
1+
// RUN: %target-typecheck-verify-swift
22

33
protocol Q { }
44

test/Constraints/opened_existentials_suppression.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-swift-frontend -enable-experimental-opened-existential-types -typecheck -dump-ast -parse-as-library %s | %FileCheck %s
1+
// RUN: %target-swift-frontend -typecheck -dump-ast -parse-as-library %s | %FileCheck %s
22

33
protocol P { }
44
extension Optional: P where Wrapped: P { }

test/Constraints/result_builder_availability.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
// RUN: %target-typecheck-verify-swift -target %target-cpu-apple-macosx10.50
2-
// RUN: %target-typecheck-verify-swift -target %target-cpu-apple-macosx10.50 -enable-experimental-opened-existential-types
32

43
// REQUIRES: OS=macosx
54

test/Generics/existential_restrictions.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-typecheck-verify-swift -enable-objc-interop -disable-experimental-opened-existential-types
1+
// RUN: %target-typecheck-verify-swift -enable-objc-interop
22

33
protocol P { }
44
@objc protocol OP { }
@@ -8,14 +8,14 @@ protocol CP : class { }
88
static func createNewOne() -> SP
99
}
1010

11-
func fP<T : P>(_ t: T) { }
11+
func fP<T : P>(_ t: T?) { }
1212
// expected-note@-1 {{required by global function 'fP' where 'T' = 'any P'}}
1313
// expected-note@-2 {{required by global function 'fP' where 'T' = 'any OP & P'}}
14-
func fOP<T : OP>(_ t: T) { }
14+
func fOP<T : OP>(_ t: T?) { }
1515
// expected-note@-1 {{required by global function 'fOP' where 'T' = 'any OP & P'}}
1616
func fOPE(_ t: OP) { }
17-
func fSP<T : SP>(_ t: T) { }
18-
func fAO<T : AnyObject>(_ t: T) { }
17+
func fSP<T : SP>(_ t: T?) { }
18+
func fAO<T : AnyObject>(_ t: T?) { }
1919
// expected-note@-1 {{where 'T' = 'any P'}}
2020
// expected-note@-2 {{where 'T' = 'any CP'}}
2121
// expected-note@-3 {{where 'T' = 'any OP & P'}}

test/Interop/Cxx/templates/function-template.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// RUN: %target-run-simple-swift(-I %S/Inputs -Xfrontend -enable-experimental-cxx-interop)
2-
// RUN: %target-run-simple-swift(-I %S/Inputs -Xfrontend -enable-experimental-cxx-interop -Xfrontend -enable-experimental-opened-existential-types)
3-
//
2+
43
// REQUIRES: executable_test
54

65
import FunctionTemplates

test/SILGen/opened_existentials.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-swift-emit-silgen -enable-experimental-opened-existential-types %s | %FileCheck %s
1+
// RUN: %target-swift-emit-silgen %s | %FileCheck %s
22

33
public protocol P { }
44

0 commit comments

Comments
 (0)