Skip to content

Commit 336da91

Browse files
committed
[Features] Add a dedicated experimental feature flag for tuple conformances.
1 parent 0ed4b33 commit 336da91

File tree

5 files changed

+23
-2
lines changed

5 files changed

+23
-2
lines changed

include/swift/AST/DiagnosticsCommon.def

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,13 @@ ERROR(macro_experimental,none,
228228
ERROR(ambiguous_macro_reference,none,
229229
"ambiguous reference to macro %0", (DeclName))
230230

231+
//------------------------------------------------------------------------------
232+
// MARK: tuple conformances
233+
//------------------------------------------------------------------------------
234+
ERROR(experimental_tuple_extension,none,
235+
"tuple extensions are experimental",
236+
())
237+
231238
//------------------------------------------------------------------------------
232239
// MARK: bridged diagnostics
233240
//------------------------------------------------------------------------------

include/swift/Basic/Features.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ EXPERIMENTAL_FEATURE(NamedOpaqueTypes, false)
114114
EXPERIMENTAL_FEATURE(FlowSensitiveConcurrencyCaptures, false)
115115
EXPERIMENTAL_FEATURE(FreestandingMacros, true)
116116
EXPERIMENTAL_FEATURE(CodeItemMacros, true)
117+
EXPERIMENTAL_FEATURE(TupleConformances, false)
117118

118119
// FIXME: MoveOnlyClasses is not intended to be in production,
119120
// but our tests currently rely on it, and we want to run those

lib/AST/ASTPrinter.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3208,6 +3208,10 @@ static bool usesFeatureVariadicGenerics(Decl *decl) {
32083208
return false;
32093209
}
32103210

3211+
static bool usesFeatureTupleConformances(Decl *decl) {
3212+
return false;
3213+
}
3214+
32113215
static bool usesFeatureLayoutPrespecialization(Decl *decl) {
32123216
auto &attrs = decl->getAttrs();
32133217
return std::any_of(attrs.begin(), attrs.end(), [](auto *attr) {

lib/AST/NameLookup.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2981,7 +2981,16 @@ ExtendedNominalRequest::evaluate(Evaluator &evaluator,
29812981

29822982
// If there is more than 1 element, we will emit a warning or an error
29832983
// elsewhere, so don't handle that case here.
2984-
return nominalTypes.empty() ? nullptr : nominalTypes[0];
2984+
if (nominalTypes.empty())
2985+
return nullptr;
2986+
2987+
// Diagnose experimental tuple extensions.
2988+
if (isa<BuiltinTupleDecl>(nominalTypes[0]) &&
2989+
!ctx.LangOpts.hasFeature(Feature::TupleConformances)) {
2990+
ext->diagnose(diag::experimental_tuple_extension);
2991+
}
2992+
2993+
return nominalTypes[0];
29852994
}
29862995

29872996
/// Whether there are only associated types in the set of declarations.

test/Generics/tuple-conformances.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-feature VariadicGenerics -parse-stdlib
1+
// RUN: %target-typecheck-verify-swift -enable-experimental-feature TupleConformances -parse-stdlib
22

33
// REQUIRES: asserts
44

0 commit comments

Comments
 (0)