diff --git a/include/swift/Basic/LangOptions.h b/include/swift/Basic/LangOptions.h index b9c3d325c9e..383502b424a 100644 --- a/include/swift/Basic/LangOptions.h +++ b/include/swift/Basic/LangOptions.h @@ -317,10 +317,6 @@ namespace swift { /// Enable experimental concurrency model. bool EnableExperimentalConcurrency = false; - /// Enable support for implicitly opening existential argument types - /// in calls to generic functions. - bool EnableOpenedExistentialTypes = false; - /// Disable experimental ClangImporter diagnostics. bool DisableExperimentalClangImporterDiagnostics = false; diff --git a/lib/Frontend/CompilerInvocation.cpp b/lib/Frontend/CompilerInvocation.cpp index 9365569679d..4a67c194c48 100644 --- a/lib/Frontend/CompilerInvocation.cpp +++ b/lib/Frontend/CompilerInvocation.cpp @@ -450,11 +450,6 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args, Opts.EnableExperimentalConcurrency |= Args.hasArg(OPT_enable_experimental_concurrency); - Opts.EnableOpenedExistentialTypes = - Args.hasFlag(OPT_enable_experimental_opened_existential_types, - OPT_disable_experimental_opened_existential_types, - true); - Opts.EnableInferPublicSendable |= Args.hasFlag(OPT_enable_infer_public_concurrent_value, OPT_disable_infer_public_concurrent_value, diff --git a/lib/Sema/CSSimplify.cpp b/lib/Sema/CSSimplify.cpp index 4bea7bc32fd..508e7744496 100644 --- a/lib/Sema/CSSimplify.cpp +++ b/lib/Sema/CSSimplify.cpp @@ -1519,10 +1519,6 @@ shouldOpenExistentialCallArgument( if (isa_and_nonnull(callee->getClangDecl())) return None; - ASTContext &ctx = callee->getASTContext(); - if (!ctx.LangOpts.EnableOpenedExistentialTypes) - return None; - // The actual parameter type needs to involve a type variable, otherwise // type inference won't be possible. if (!paramTy->hasTypeVariable()) diff --git a/lib/Sema/TypeCheckCodeCompletion.cpp b/lib/Sema/TypeCheckCodeCompletion.cpp index 1f2bea7fd74..08b5e69cea0 100644 --- a/lib/Sema/TypeCheckCodeCompletion.cpp +++ b/lib/Sema/TypeCheckCodeCompletion.cpp @@ -482,6 +482,11 @@ TypeChecker::getTypeOfCompletionOperator(DeclContext *DC, Expr *LHS, // Build temporary expression to typecheck. // We allocate these expressions on the stack because we know they can't // escape and there isn't a better way to allocate scratch Expr nodes. + + // Use a placeholder expr for the LHS argument to avoid sending + // a pre-type-checked AST through the constraint system. + OpaqueValueExpr argExpr(LHS->getSourceRange(), LHSTy, + /*isPlaceholder=*/true); UnresolvedDeclRefExpr UDRE(DeclNameRef(opName), refKind, DeclNameLoc(Loc)); auto *opExpr = TypeChecker::resolveDeclRefExpr( &UDRE, DC, /*replaceInvalidRefsWithErrors=*/true); @@ -493,7 +498,7 @@ TypeChecker::getTypeOfCompletionOperator(DeclContext *DC, Expr *LHS, // (declref_expr name=) // (argument_list // ())) - auto *postfixExpr = PostfixUnaryExpr::create(ctx, opExpr, LHS); + auto *postfixExpr = PostfixUnaryExpr::create(ctx, opExpr, &argExpr); return getTypeOfCompletionOperatorImpl(DC, postfixExpr, referencedDecl); } @@ -504,7 +509,7 @@ TypeChecker::getTypeOfCompletionOperator(DeclContext *DC, Expr *LHS, // () // (code_completion_expr))) CodeCompletionExpr dummyRHS(Loc); - auto *binaryExpr = BinaryExpr::create(ctx, LHS, opExpr, &dummyRHS, + auto *binaryExpr = BinaryExpr::create(ctx, &argExpr, opExpr, &dummyRHS, /*implicit*/ true); return getTypeOfCompletionOperatorImpl(DC, binaryExpr, referencedDecl); } diff --git a/test/Constraints/openExistential.swift b/test/Constraints/openExistential.swift index a2af4bcd5dd..a50d1ef26da 100644 --- a/test/Constraints/openExistential.swift +++ b/test/Constraints/openExistential.swift @@ -1,5 +1,4 @@ // RUN: %target-typecheck-verify-swift -// RUN: %target-typecheck-verify-swift -enable-experimental-opened-existential-types protocol P { } diff --git a/test/Constraints/opened_existentials.swift b/test/Constraints/opened_existentials.swift index 41666eb03fb..3c238174043 100644 --- a/test/Constraints/opened_existentials.swift +++ b/test/Constraints/opened_existentials.swift @@ -1,4 +1,4 @@ -// RUN: %target-typecheck-verify-swift -enable-experimental-opened-existential-types +// RUN: %target-typecheck-verify-swift protocol Q { } diff --git a/test/Constraints/opened_existentials_suppression.swift b/test/Constraints/opened_existentials_suppression.swift index 518945f125a..5ccd3758134 100644 --- a/test/Constraints/opened_existentials_suppression.swift +++ b/test/Constraints/opened_existentials_suppression.swift @@ -1,4 +1,4 @@ -// RUN: %target-swift-frontend -enable-experimental-opened-existential-types -typecheck -dump-ast -parse-as-library %s | %FileCheck %s +// RUN: %target-swift-frontend -typecheck -dump-ast -parse-as-library %s | %FileCheck %s protocol P { } extension Optional: P where Wrapped: P { } diff --git a/test/Constraints/result_builder_availability.swift b/test/Constraints/result_builder_availability.swift index 62a8747dc35..7c765ad5aa9 100644 --- a/test/Constraints/result_builder_availability.swift +++ b/test/Constraints/result_builder_availability.swift @@ -1,5 +1,4 @@ // RUN: %target-typecheck-verify-swift -target %target-cpu-apple-macosx10.50 -// RUN: %target-typecheck-verify-swift -target %target-cpu-apple-macosx10.50 -enable-experimental-opened-existential-types // REQUIRES: OS=macosx diff --git a/test/Generics/existential_restrictions.swift b/test/Generics/existential_restrictions.swift index e07a32c4106..fd439be246d 100644 --- a/test/Generics/existential_restrictions.swift +++ b/test/Generics/existential_restrictions.swift @@ -1,4 +1,4 @@ -// RUN: %target-typecheck-verify-swift -enable-objc-interop -disable-experimental-opened-existential-types +// RUN: %target-typecheck-verify-swift -enable-objc-interop protocol P { } @objc protocol OP { } @@ -8,14 +8,14 @@ protocol CP : class { } static func createNewOne() -> SP } -func fP(_ t: T) { } +func fP(_ t: T?) { } // expected-note@-1 {{required by global function 'fP' where 'T' = 'any P'}} // expected-note@-2 {{required by global function 'fP' where 'T' = 'any OP & P'}} -func fOP(_ t: T) { } +func fOP(_ t: T?) { } // expected-note@-1 {{required by global function 'fOP' where 'T' = 'any OP & P'}} func fOPE(_ t: OP) { } -func fSP(_ t: T) { } -func fAO(_ t: T) { } +func fSP(_ t: T?) { } +func fAO(_ t: T?) { } // expected-note@-1 {{where 'T' = 'any P'}} // expected-note@-2 {{where 'T' = 'any CP'}} // expected-note@-3 {{where 'T' = 'any OP & P'}} diff --git a/test/Interop/Cxx/templates/function-template.swift b/test/Interop/Cxx/templates/function-template.swift index 8ee67a3691d..66056745f8d 100644 --- a/test/Interop/Cxx/templates/function-template.swift +++ b/test/Interop/Cxx/templates/function-template.swift @@ -1,6 +1,5 @@ // RUN: %target-run-simple-swift(-I %S/Inputs -Xfrontend -enable-experimental-cxx-interop) -// RUN: %target-run-simple-swift(-I %S/Inputs -Xfrontend -enable-experimental-cxx-interop -Xfrontend -enable-experimental-opened-existential-types) -// + // REQUIRES: executable_test import FunctionTemplates diff --git a/test/SILGen/opened_existentials.swift b/test/SILGen/opened_existentials.swift index cfcd9fef1ea..09924dcca59 100644 --- a/test/SILGen/opened_existentials.swift +++ b/test/SILGen/opened_existentials.swift @@ -1,4 +1,4 @@ -// RUN: %target-swift-emit-silgen -enable-experimental-opened-existential-types %s | %FileCheck %s +// RUN: %target-swift-emit-silgen %s | %FileCheck %s public protocol P { }