Skip to content

Commit 5d86d75

Browse files
authored
Merge pull request #59814 from hborla/5.7-remove-existential-opening-option
[5.7][LangOptions] Remove the option to enable/disable implicit existential opening.
2 parents 57fe58a + 29d9cf6 commit 5d86d75

11 files changed

+15
-26
lines changed

include/swift/Basic/LangOptions.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -334,10 +334,6 @@ namespace swift {
334334
/// `func f() -> <T> T`.
335335
bool EnableExperimentalNamedOpaqueTypes = false;
336336

337-
/// Enable support for implicitly opening existential argument types
338-
/// in calls to generic functions.
339-
bool EnableOpenedExistentialTypes = false;
340-
341337
/// Enable experimental flow-sensitive concurrent captures.
342338
bool EnableExperimentalFlowSensitiveConcurrentCaptures = false;
343339

lib/Frontend/CompilerInvocation.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -456,11 +456,6 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
456456
Opts.EnableExperimentalNamedOpaqueTypes |=
457457
Args.hasArg(OPT_enable_experimental_named_opaque_types);
458458

459-
Opts.EnableOpenedExistentialTypes =
460-
Args.hasFlag(OPT_enable_experimental_opened_existential_types,
461-
OPT_disable_experimental_opened_existential_types,
462-
true);
463-
464459
Opts.EnableExperimentalVariadicGenerics |=
465460
Args.hasArg(OPT_enable_experimental_variadic_generics);
466461

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
@@ -486,6 +486,11 @@ TypeChecker::getTypeOfCompletionOperator(DeclContext *DC, Expr *LHS,
486486
// Build temporary expression to typecheck.
487487
// We allocate these expressions on the stack because we know they can't
488488
// escape and there isn't a better way to allocate scratch Expr nodes.
489+
490+
// Use a placeholder expr for the LHS argument to avoid sending
491+
// a pre-type-checked AST through the constraint system.
492+
OpaqueValueExpr argExpr(LHS->getSourceRange(), LHSTy,
493+
/*isPlaceholder=*/true);
489494
UnresolvedDeclRefExpr UDRE(DeclNameRef(opName), refKind, DeclNameLoc(Loc));
490495
auto *opExpr = TypeChecker::resolveDeclRefExpr(
491496
&UDRE, DC, /*replaceInvalidRefsWithErrors=*/true);
@@ -497,7 +502,7 @@ TypeChecker::getTypeOfCompletionOperator(DeclContext *DC, Expr *LHS,
497502
// (declref_expr name=<opName>)
498503
// (argument_list
499504
// (<LHS>)))
500-
auto *postfixExpr = PostfixUnaryExpr::create(ctx, opExpr, LHS);
505+
auto *postfixExpr = PostfixUnaryExpr::create(ctx, opExpr, &argExpr);
501506
return getTypeOfCompletionOperatorImpl(DC, postfixExpr, referencedDecl);
502507
}
503508

@@ -508,7 +513,7 @@ TypeChecker::getTypeOfCompletionOperator(DeclContext *DC, Expr *LHS,
508513
// (<LHS>)
509514
// (code_completion_expr)))
510515
CodeCompletionExpr dummyRHS(Loc);
511-
auto *binaryExpr = BinaryExpr::create(ctx, LHS, opExpr, &dummyRHS,
516+
auto *binaryExpr = BinaryExpr::create(ctx, &argExpr, opExpr, &dummyRHS,
512517
/*implicit*/ true);
513518
return getTypeOfCompletionOperatorImpl(DC, binaryExpr, referencedDecl);
514519
}

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: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
// RUN: %target-run-simple-swift(-I %S/Inputs -Xfrontend -enable-cxx-interop)
2-
// RUN: %target-run-simple-swift(-I %S/Inputs -Xfrontend -enable-cxx-interop -Xfrontend -enable-experimental-opened-existential-types)
32
//
43
// REQUIRES: executable_test
54

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)