mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Parameterized Existential Types Are Enabled By Default
See https://forums.swift.org/t/accepted-se-0353-constrained-existential-types/57560
This commit is contained in:
@@ -326,10 +326,6 @@ namespace swift {
|
||||
/// in calls to generic functions.
|
||||
bool EnableOpenedExistentialTypes = false;
|
||||
|
||||
/// Enable support for parameterized protocol types in existential
|
||||
/// position.
|
||||
bool EnableParameterizedExistentialTypes = false;
|
||||
|
||||
/// Enable experimental flow-sensitive concurrent captures.
|
||||
bool EnableExperimentalFlowSensitiveConcurrentCaptures = false;
|
||||
|
||||
|
||||
@@ -543,10 +543,6 @@ def enable_explicit_existential_types :
|
||||
Flag<["-"], "enable-explicit-existential-types">,
|
||||
HelpText<"Enable experimental support for explicit existential types">;
|
||||
|
||||
def enable_parameterized_existential_types :
|
||||
Flag<["-"], "enable-parameterized-existential-types">,
|
||||
HelpText<"Enable experimental support for parameterized existential types">;
|
||||
|
||||
def enable_experimental_opened_existential_types :
|
||||
Flag<["-"], "enable-experimental-opened-existential-types">,
|
||||
HelpText<"Enable experimental support for implicitly opened existentials">;
|
||||
|
||||
@@ -456,9 +456,6 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
|
||||
Opts.EnableExperimentalNamedOpaqueTypes |=
|
||||
Args.hasArg(OPT_enable_experimental_named_opaque_types);
|
||||
|
||||
Opts.EnableParameterizedExistentialTypes |=
|
||||
Args.hasArg(OPT_enable_parameterized_existential_types);
|
||||
|
||||
Opts.EnableOpenedExistentialTypes =
|
||||
Args.hasFlag(OPT_enable_experimental_opened_existential_types,
|
||||
OPT_disable_experimental_opened_existential_types,
|
||||
|
||||
@@ -632,7 +632,7 @@ static Type applyGenericArguments(Type type, TypeResolution resolution,
|
||||
// Build ParameterizedProtocolType if the protocol has a primary associated
|
||||
// type and we're in a supported context (for now just generic requirements,
|
||||
// inheritance clause, extension binding).
|
||||
if (!resolution.getOptions().isParameterizedProtocolSupported(ctx.LangOpts)) {
|
||||
if (!resolution.getOptions().isParameterizedProtocolSupported()) {
|
||||
diags.diagnose(loc, diag::parameterized_protocol_not_supported);
|
||||
return ErrorType::get(ctx);
|
||||
}
|
||||
|
||||
@@ -284,18 +284,14 @@ public:
|
||||
}
|
||||
|
||||
/// Whether parameterized protocol types are supported in this context.
|
||||
///
|
||||
/// FIXME: Remove LangOptions parameter once EnableParameterizedExistentialTypes
|
||||
/// staging flag is gone.
|
||||
bool isParameterizedProtocolSupported(const LangOptions &opts) const {
|
||||
bool isParameterizedProtocolSupported() const {
|
||||
switch (context) {
|
||||
case Context::Inherited:
|
||||
case Context::ExtensionBinding:
|
||||
case Context::GenericRequirement:
|
||||
return true;
|
||||
case Context::ExistentialConstraint:
|
||||
case Context::MetatypeBase:
|
||||
return opts.EnableParameterizedExistentialTypes;
|
||||
return true;
|
||||
case Context::None:
|
||||
case Context::TypeAliasDecl:
|
||||
case Context::GenericTypeAliasDecl:
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// RUN: %target-typecheck-verify-swift -enable-parameterized-existential-types -disable-availability-checking
|
||||
// RUN: %target-typecheck-verify-swift -disable-availability-checking
|
||||
//
|
||||
// FIXME: Merge this file with existential_metatypes.swift once -enable-parameterized-existential-types becomes the default
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// RUN: %target-swift-frontend -emit-ir %s -swift-version 5 -disable-availability-checking -enable-parameterized-existential-types | %IRGenFileCheck %s
|
||||
// RUN: %target-swift-frontend -emit-ir %s -swift-version 5 -disable-availability-checking | %IRGenFileCheck %s
|
||||
|
||||
// CHECK-LABEL: @"$sl26existential_shape_metadata2Q0_pyxXPXGMq" = linkonce_odr hidden constant
|
||||
// CHECK-SAME: { i32 {{.*}}sub ([[INT]] ptrtoint (i8** @{{[0-9]+}} to [[INT]])
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// RUN: %target-run-simple-swift(-Xfrontend -enable-parameterized-existential-types -Xfrontend -disable-availability-checking)
|
||||
// RUN: %target-run-simple-swift(-Xfrontend -disable-availability-checking)
|
||||
// REQUIRES: executable_test
|
||||
|
||||
// This test requires the new existential shape metadata accessors which are
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// RUN: %target-swift-remoteast-test -enable-parameterized-existential-types -disable-availability-checking %s | %FileCheck %s
|
||||
// RUN: %target-swift-remoteast-test -disable-availability-checking %s | %FileCheck %s
|
||||
|
||||
// REQUIRES: swift-remoteast-test
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// RUN: %target-swift-emit-silgen -module-name parameterized -enable-parameterized-existential-types -disable-availability-checking %s | %FileCheck %s
|
||||
// RUN: %target-swift-emit-silgen -module-name parameterized -disable-availability-checking %s | %FileCheck %s
|
||||
|
||||
protocol P<T, U, V> {
|
||||
associatedtype T
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// RUN: %target-swift-frontend %s -emit-sil -enable-parameterized-existential-types -disable-availability-checking -O -o - | %FileCheck %s
|
||||
// RUN: %target-swift-frontend %s -emit-sil -disable-availability-checking -O -o - | %FileCheck %s
|
||||
|
||||
public protocol P<T> {
|
||||
associatedtype T
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
// RUN: %target-typecheck-verify-swift -target %target-cpu-apple-macosx10.50 -disable-objc-attr-requires-foundation-module -enable-parameterized-existential-types
|
||||
// RUN: not %target-swift-frontend -target %target-cpu-apple-macosx10.50 -disable-objc-attr-requires-foundation-module -enable-parameterized-existential-types -typecheck %s 2>&1 | %FileCheck %s '--implicit-check-not=<unknown>:0'
|
||||
// RUN: %target-typecheck-verify-swift -target %target-cpu-apple-macosx10.50 -disable-objc-attr-requires-foundation-module
|
||||
// RUN: not %target-swift-frontend -target %target-cpu-apple-macosx10.50 -disable-objc-attr-requires-foundation-module -typecheck %s 2>&1 | %FileCheck %s '--implicit-check-not=<unknown>:0'
|
||||
|
||||
// Make sure we do not emit availability errors or warnings when -disable-availability-checking is passed
|
||||
// RUN: not %target-swift-frontend -target %target-cpu-apple-macosx10.50 -typecheck -disable-objc-attr-requires-foundation-module -enable-parameterized-existential-types -disable-availability-checking %s 2>&1 | %FileCheck %s '--implicit-check-not=error:'
|
||||
// RUN: not %target-swift-frontend -target %target-cpu-apple-macosx10.50 -typecheck -disable-objc-attr-requires-foundation-module -disable-availability-checking %s 2>&1 | %FileCheck %s '--implicit-check-not=error:'
|
||||
|
||||
// REQUIRES: OS=macosx
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// RUN: %empty-directory(%t)
|
||||
// RUN: %target-swift-frontend -enable-parameterized-existential-types -emit-module %S/Inputs/parameterized_protocol_other.swift -emit-module-path %t/parameterized_protocol_other.swiftmodule
|
||||
// RUN: %target-typecheck-verify-swift -enable-parameterized-existential-types -I%t
|
||||
// RUN: %target-swift-frontend -emit-module %S/Inputs/parameterized_protocol_other.swift -emit-module-path %t/parameterized_protocol_other.swiftmodule
|
||||
// RUN: %target-typecheck-verify-swift -I%t
|
||||
|
||||
import parameterized_protocol_other
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// RUN: %target-swift-frontend -enable-parameterized-existential-types -disable-availability-checking -typecheck -verify %s
|
||||
// RUN: %target-swift-frontend -disable-availability-checking -typecheck -verify %s
|
||||
|
||||
// I do not like nested some type params,
|
||||
// I do not like them Σam-i-am
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// RUN: %target-typecheck-verify-swift -disable-availability-checking -enable-parameterized-existential-types
|
||||
// RUN: %target-typecheck-verify-swift -disable-availability-checking
|
||||
|
||||
protocol Sequence<Element> {
|
||||
associatedtype Element
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// RUN: not %target-swift-frontend -disable-availability-checking -emit-ir -enable-parameterized-existential-types %s
|
||||
// RUN: not %target-swift-frontend -disable-availability-checking -emit-ir %s
|
||||
|
||||
protocol P<X, Y> {
|
||||
associatedtype X : P
|
||||
|
||||
Reference in New Issue
Block a user