Skip to content

Commit 9196c9a

Browse files
committed
[FrontendOptions] Enable structural opaque result types and remove
the -enable-experimental-structural-opaque-types frontend flag.
1 parent 17f1cf9 commit 9196c9a

File tree

7 files changed

+4
-24
lines changed

7 files changed

+4
-24
lines changed

include/swift/AST/DiagnosticsSema.def

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1874,9 +1874,6 @@ WARNING(spi_attribute_on_import_of_public_module,none,
18741874
(DeclName, StringRef))
18751875

18761876
// Opaque return types
1877-
ERROR(structural_opaque_types_are_experimental,none,
1878-
"'opaque' types cannot be nested inside other types; "
1879-
"structural 'opaque' types are an experimental feature", ())
18801877
ERROR(opaque_type_invalid_constraint,none,
18811878
"an 'opaque' type must specify only 'Any', 'AnyObject', protocols, "
18821879
"and/or a base class", ())

include/swift/Basic/LangOptions.h

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

313-
/// Enable experimental support for structural opaque result types, e.g.
314-
/// `func f() -> (some P)?`.
315-
bool EnableExperimentalStructuralOpaqueTypes = false;
316-
317313
/// Enable experimental flow-sensitive concurrent captures.
318314
bool EnableExperimentalFlowSensitiveConcurrentCaptures = false;
319315

lib/Frontend/CompilerInvocation.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -438,9 +438,6 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
438438
Opts.EnableExperimentalNamedOpaqueTypes |=
439439
Args.hasArg(OPT_enable_experimental_named_opaque_types);
440440

441-
Opts.EnableExperimentalStructuralOpaqueTypes |=
442-
Args.hasArg(OPT_enable_experimental_structural_opaque_types);
443-
444441
Opts.EnableExperimentalDistributed |=
445442
Args.hasArg(OPT_enable_experimental_distributed);
446443

lib/Sema/TypeCheckGeneric.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -115,14 +115,6 @@ OpaqueResultTypeRequest::evaluate(Evaluator &evaluator,
115115
auto *dc = originatingDecl->getInnermostDeclContext();
116116
auto &ctx = dc->getASTContext();
117117

118-
// Support for structural opaque result types is hidden behind a compiler flag
119-
// until the proposal gets approved.
120-
if (!ctx.LangOpts.EnableExperimentalStructuralOpaqueTypes &&
121-
!isa<OpaqueReturnTypeRepr>(repr)) {
122-
ctx.Diags.diagnose(repr->getLoc(), diag::structural_opaque_types_are_experimental);
123-
return nullptr;
124-
}
125-
126118
// Protocol requirements can't have opaque return types.
127119
//
128120
// TODO: Maybe one day we could treat this as sugar for an associated type.

test/Constraints/result_builder_opaque_result_structural.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-structural-opaque-types -disable-availability-checking
1+
// RUN: %target-typecheck-verify-swift -disable-availability-checking
22

33
@resultBuilder
44
struct TupleBuilder {

test/type/opaque.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,8 @@ struct Test {
7676
let zingle = {() -> some P in 1 } // expected-error{{'some' types are only implemented}}
7777

7878

79-
// Support for structural opaque result types is hidden behind a compiler flag
80-
// until the proposal gets approved.
81-
func twoOpaqueTypes() -> (some P, some P) { return (1, 2) } // expected-error{{'opaque' types cannot be nested inside other types}}
82-
func asArrayElem() -> (some P)! { return [1] } // expected-error{{'opaque' types cannot be nested inside other types}}
79+
func twoOpaqueTypes() -> (some P, some P) { return (1, 2) } // expected-error{{'(some P, some P)' contains multiple 'opaque' types, but only one 'opaque' type is supported}}
80+
func asArrayElem() -> [some P] { return [1] }
8381

8482
// Invalid positions
8583

test/type/opaque_return_structural.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-structural-opaque-types -disable-availability-checking
1+
// RUN: %target-typecheck-verify-swift -disable-availability-checking
22

33
// Tests for experimental extensions to opaque return type support.
44

0 commit comments

Comments
 (0)