Skip to content

Commit 3f1491e

Browse files
authored
Merge pull request #78298 from slavapestov/remove-one-way-bind
Sema: Remove -experimental-one-way-closure-params
2 parents 1e9efd4 + bb55d9c commit 3f1491e

File tree

9 files changed

+7
-71
lines changed

9 files changed

+7
-71
lines changed

include/swift/Basic/Features.def

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,6 @@ EXPERIMENTAL_FEATURE(MoveOnlyTuples, true)
254254
EXPERIMENTAL_FEATURE(MoveOnlyPartialReinitialization, true)
255255
EXPERIMENTAL_FEATURE(ConsumeSelfInDeinit, true)
256256

257-
EXPERIMENTAL_FEATURE(OneWayClosureParameters, false)
258257
EXPERIMENTAL_FEATURE(LayoutPrespecialization, true)
259258

260259
EXPERIMENTAL_FEATURE(AccessLevelOnImport, true)

include/swift/Option/FrontendOptions.td

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1075,10 +1075,6 @@ def experimental_print_full_convention :
10751075
" arguments, regardless of whether they were written in the source."
10761076
" Also requires -use-clang-function-types to be enabled.">;
10771077

1078-
def experimental_one_way_closure_params :
1079-
Flag<["-"], "experimental-one-way-closure-params">,
1080-
HelpText<"Enable experimental support for one-way closure parameters">;
1081-
10821078
def force_public_linkage : Flag<["-"], "force-public-linkage">,
10831079
HelpText<"Force public linkage for private symbols. Used by LLDB.">;
10841080

include/swift/Sema/Constraint.h

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -155,12 +155,6 @@ enum class ConstraintKind : char {
155155
/// type). At that point, this constraint will be treated like an `Equal`
156156
/// constraint.
157157
OneWayEqual,
158-
/// The second type is the type of a function parameter, and the first type
159-
/// is the type of a reference to that function parameter within the body.
160-
/// Once the second type has been fully determined (and mapped down to a
161-
/// concrete type), this constraint will be treated like a 'BindParam'
162-
/// constraint.
163-
OneWayBindParam,
164158
/// If there is no contextual info e.g. `_ = { 42 }` default first type
165159
/// to a second type. This is effectively a `Defaultable` constraint
166160
/// which one significant difference:
@@ -687,7 +681,6 @@ class Constraint final : public llvm::ilist_node<Constraint>,
687681
case ConstraintKind::BindOverload:
688682
case ConstraintKind::OptionalObject:
689683
case ConstraintKind::OneWayEqual:
690-
case ConstraintKind::OneWayBindParam:
691684
case ConstraintKind::FallbackType:
692685
case ConstraintKind::UnresolvedMemberChainBase:
693686
case ConstraintKind::PackElementOf:
@@ -835,8 +828,7 @@ class Constraint final : public llvm::ilist_node<Constraint>,
835828

836829
/// Whether this is a one-way constraint.
837830
bool isOneWayConstraint() const {
838-
return Kind == ConstraintKind::OneWayEqual ||
839-
Kind == ConstraintKind::OneWayBindParam;
831+
return Kind == ConstraintKind::OneWayEqual;
840832
}
841833

842834
/// Retrieve the overload choice for an overload-binding constraint.

lib/AST/FeatureSet.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ UNINTERESTING_FEATURE(OldOwnershipOperatorSpellings)
8888
UNINTERESTING_FEATURE(MoveOnlyEnumDeinits)
8989
UNINTERESTING_FEATURE(MoveOnlyTuples)
9090
UNINTERESTING_FEATURE(MoveOnlyPartialReinitialization)
91-
UNINTERESTING_FEATURE(OneWayClosureParameters)
9291
UNINTERESTING_FEATURE(LayoutPrespecialization)
9392
UNINTERESTING_FEATURE(AccessLevelOnImport)
9493
UNINTERESTING_FEATURE(AllowNonResilientAccessInPackage)

lib/Frontend/CompilerInvocation.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -863,8 +863,6 @@ static bool ParseEnabledFeatureArgs(LangOptions &Opts, ArgList &Args,
863863
Opts.enableFeature(Feature::NoImplicitCopy);
864864
Opts.enableFeature(Feature::OldOwnershipOperatorSpellings);
865865
}
866-
if (Args.hasArg(OPT_experimental_one_way_closure_params))
867-
Opts.enableFeature(Feature::OneWayClosureParameters);
868866
if (Args.hasArg(OPT_enable_experimental_forward_mode_differentiation))
869867
Opts.enableFeature(Feature::ForwardModeDifferentiation);
870868
if (Args.hasArg(OPT_enable_experimental_additive_arithmetic_derivation))

lib/Sema/CSBindings.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1950,8 +1950,7 @@ void PotentialBindings::infer(ConstraintSystem &CS,
19501950
break;
19511951
}
19521952

1953-
case ConstraintKind::OneWayEqual:
1954-
case ConstraintKind::OneWayBindParam: {
1953+
case ConstraintKind::OneWayEqual:{
19551954
// Don't produce any bindings if this type variable is on the left-hand
19561955
// side of a one-way binding.
19571956
auto firstType = constraint->getFirstType();

lib/Sema/CSSimplify.cpp

Lines changed: 5 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -2181,7 +2181,6 @@ ConstraintSystem::matchTupleTypes(TupleType *tuple1, TupleType *tuple2,
21812181
case ConstraintKind::ValueWitness:
21822182
case ConstraintKind::BridgingConversion:
21832183
case ConstraintKind::OneWayEqual:
2184-
case ConstraintKind::OneWayBindParam:
21852184
case ConstraintKind::FallbackType:
21862185
case ConstraintKind::UnresolvedMemberChainBase:
21872186
case ConstraintKind::PropertyWrapper:
@@ -2553,7 +2552,6 @@ static bool matchFunctionRepresentations(FunctionType::ExtInfo einfo1,
25532552
case ConstraintKind::ValueMember:
25542553
case ConstraintKind::ValueWitness:
25552554
case ConstraintKind::OneWayEqual:
2556-
case ConstraintKind::OneWayBindParam:
25572555
case ConstraintKind::FallbackType:
25582556
case ConstraintKind::UnresolvedMemberChainBase:
25592557
case ConstraintKind::PropertyWrapper:
@@ -3198,7 +3196,6 @@ ConstraintSystem::matchFunctionTypes(FunctionType *func1, FunctionType *func2,
31983196
case ConstraintKind::ValueWitness:
31993197
case ConstraintKind::BridgingConversion:
32003198
case ConstraintKind::OneWayEqual:
3201-
case ConstraintKind::OneWayBindParam:
32023199
case ConstraintKind::FallbackType:
32033200
case ConstraintKind::UnresolvedMemberChainBase:
32043201
case ConstraintKind::PropertyWrapper:
@@ -7134,7 +7131,6 @@ ConstraintSystem::matchTypes(Type type1, Type type2, ConstraintKind kind,
71347131
case ConstraintKind::ValueMember:
71357132
case ConstraintKind::ValueWitness:
71367133
case ConstraintKind::OneWayEqual:
7137-
case ConstraintKind::OneWayBindParam:
71387134
case ConstraintKind::FallbackType:
71397135
case ConstraintKind::UnresolvedMemberChainBase:
71407136
case ConstraintKind::PropertyWrapper:
@@ -11594,14 +11590,9 @@ ConstraintSystem::simplifyOneWayConstraint(
1159411590

1159511591
// Translate this constraint into an equality or bind-parameter constraint,
1159611592
// as appropriate.
11597-
if (kind == ConstraintKind::OneWayEqual) {
11598-
return matchTypes(first, secondSimplified, ConstraintKind::Equal, flags,
11599-
locator);
11600-
}
11601-
11602-
assert(kind == ConstraintKind::OneWayBindParam);
11603-
return matchTypes(
11604-
secondSimplified, first, ConstraintKind::BindParam, flags, locator);
11593+
ASSERT(kind == ConstraintKind::OneWayEqual);
11594+
return matchTypes(first, secondSimplified, ConstraintKind::Equal, flags,
11595+
locator);
1160511596
}
1160611597

1160711598
ConstraintSystem::SolutionKind
@@ -11844,12 +11835,6 @@ bool ConstraintSystem::resolveClosure(TypeVariableType *typeVar,
1184411835
// Determine whether a result builder will be applied.
1184511836
auto resultBuilderType = getOpenedResultBuilderTypeFor(*this, locator);
1184611837

11847-
// Determine whether to introduce one-way constraints between the parameter's
11848-
// type as seen in the body of the closure and the external parameter
11849-
// type.
11850-
bool oneWayConstraints =
11851-
getASTContext().LangOpts.hasFeature(Feature::OneWayClosureParameters);
11852-
1185311838
auto *paramList = closure->getParameters();
1185411839
SmallVector<AnyFunctionType::Param, 4> parameters;
1185511840
bool hasIsolatedParam = false;
@@ -11942,19 +11927,6 @@ bool ConstraintSystem::resolveClosure(TypeVariableType *typeVar,
1194211927
// - `Int...` -> `[Int]`,
1194311928
// - `inout Int` -> `@lvalue Int`.
1194411929
internalType = param.getParameterType();
11945-
11946-
// When there are type variables in the type and we have enabled
11947-
// one-way constraints, create a fresh type variable to handle the
11948-
// binding.
11949-
if (oneWayConstraints && internalType->hasTypeVariable()) {
11950-
auto *paramLoc =
11951-
getConstraintLocator(closure, LocatorPathElt::TupleElement(i));
11952-
auto *typeVar = createTypeVariable(paramLoc, TVO_CanBindToLValue |
11953-
TVO_CanBindToNoEscape);
11954-
addConstraint(
11955-
ConstraintKind::OneWayBindParam, typeVar, internalType, paramLoc);
11956-
internalType = typeVar;
11957-
}
1195811930
} else {
1195911931
auto *paramLoc =
1196011932
getConstraintLocator(closure, LocatorPathElt::TupleElement(i));
@@ -11986,13 +11958,8 @@ bool ConstraintSystem::resolveClosure(TypeVariableType *typeVar,
1198611958
addConstraint(ConstraintKind::Bind, externalType, paramTy, paramLoc);
1198711959
}
1198811960

11989-
if (oneWayConstraints) {
11990-
addConstraint(
11991-
ConstraintKind::OneWayBindParam, typeVar, externalType, paramLoc);
11992-
} else {
11993-
addConstraint(
11994-
ConstraintKind::BindParam, externalType, typeVar, paramLoc);
11995-
}
11961+
addConstraint(
11962+
ConstraintKind::BindParam, externalType, typeVar, paramLoc);
1199611963
}
1199711964

1199811965
hasIsolatedParam |= param.isIsolated();
@@ -15760,7 +15727,6 @@ ConstraintSystem::addConstraintImpl(ConstraintKind kind, Type first,
1576015727
return simplifyPropertyWrapperConstraint(first, second, subflags, locator);
1576115728

1576215729
case ConstraintKind::OneWayEqual:
15763-
case ConstraintKind::OneWayBindParam:
1576415730
return simplifyOneWayConstraint(kind, first, second, subflags, locator);
1576515731

1576615732
case ConstraintKind::UnresolvedMemberChainBase:
@@ -16341,7 +16307,6 @@ ConstraintSystem::simplifyConstraint(const Constraint &constraint) {
1634116307
return SolutionKind::Unsolved;
1634216308

1634316309
case ConstraintKind::OneWayEqual:
16344-
case ConstraintKind::OneWayBindParam:
1634516310
return simplifyOneWayConstraint(
1634616311
constraint.getKind(), constraint.getFirstType(),
1634716312
constraint.getSecondType(),

lib/Sema/Constraint.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ Constraint::Constraint(ConstraintKind Kind, Type First, Type Second,
7575
case ConstraintKind::OpenedExistentialOf:
7676
case ConstraintKind::OptionalObject:
7777
case ConstraintKind::OneWayEqual:
78-
case ConstraintKind::OneWayBindParam:
7978
case ConstraintKind::UnresolvedMemberChainBase:
8079
case ConstraintKind::PropertyWrapper:
8180
case ConstraintKind::BindTupleOfFunctionParams:
@@ -164,7 +163,6 @@ Constraint::Constraint(ConstraintKind Kind, Type First, Type Second, Type Third,
164163
case ConstraintKind::Disjunction:
165164
case ConstraintKind::Conjunction:
166165
case ConstraintKind::OneWayEqual:
167-
case ConstraintKind::OneWayBindParam:
168166
case ConstraintKind::FallbackType:
169167
case ConstraintKind::UnresolvedMemberChainBase:
170168
case ConstraintKind::PropertyWrapper:
@@ -398,7 +396,6 @@ void Constraint::print(llvm::raw_ostream &Out, SourceManager *sm,
398396
case ConstraintKind::EscapableFunctionOf: Out << " @escaping type of "; break;
399397
case ConstraintKind::OpenedExistentialOf: Out << " opened archetype of "; break;
400398
case ConstraintKind::OneWayEqual: Out << " one-way bind to "; break;
401-
case ConstraintKind::OneWayBindParam: Out << " one-way bind param to "; break;
402399
case ConstraintKind::FallbackType:
403400
Out << " can fallback to ";
404401
break;
@@ -679,7 +676,6 @@ gatherReferencedTypeVars(Constraint *constraint,
679676
case ConstraintKind::LiteralConformsTo:
680677
case ConstraintKind::TransitivelyConformsTo:
681678
case ConstraintKind::OneWayEqual:
682-
case ConstraintKind::OneWayBindParam:
683679
case ConstraintKind::FallbackType:
684680
case ConstraintKind::UnresolvedMemberChainBase:
685681
case ConstraintKind::PropertyWrapper:

test/Constraints/one_way_closure_params.swift

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)