Skip to content

Commit e1c028b

Browse files
Merge pull request #4712 from swiftwasm/main
[pull] swiftwasm from main
2 parents e33bf82 + 3e53290 commit e1c028b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+628
-396
lines changed

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,17 @@ CHANGELOG
33

44
_**Note:** This is in reverse chronological order, so newer entries are added to the top._
55

6+
## Swift 5.8
7+
8+
* [SE-0362][]:
9+
10+
The compiler flag `-enable-upcoming-feature X` can now be used to enable a specific feature `X` that has been accepted by the evolution process, but whose introduction into the language is waiting for the next major version (e.g., version 6). The `X` is specified by any proposal that falls into this category:
11+
* `ConciseMagicFile` enables the new `#file` semantics in [SE-0274][].
12+
* `ForwardTrailingClosures` disables the "backward" scanning behavior of [SE-0286][].
13+
* `BareSlashRegexLiterals` enables the regex literal syntax of [SE-0352][].
14+
15+
Features can be detected in source code with `#if hasFeature(X)`.
16+
617
## Swift 5.7
718

819
* The Swift compiler no longer warns about redundant requirements in generic declarations. For example,
@@ -9459,6 +9470,7 @@ Swift 1.0
94599470
[SE-0267]: <https://github.com/apple/swift-evolution/blob/main/proposals/0267-where-on-contextually-generic.md>
94609471
[SE-0268]: <https://github.com/apple/swift-evolution/blob/main/proposals/0268-didset-semantics.md>
94619472
[SE-0269]: <https://github.com/apple/swift-evolution/blob/main/proposals/0269-implicit-self-explicit-capture.md>
9473+
[SE-0274]: <https://github.com/apple/swift-evolution/blob/main/proposals/0274-magic-file.md>
94629474
[SE-0276]: <https://github.com/apple/swift-evolution/blob/main/proposals/0276-multi-pattern-catch-clauses.md>
94639475
[SE-0279]: <https://github.com/apple/swift-evolution/blob/main/proposals/0279-multiple-trailing-closures.md>
94649476
[SE-0280]: <https://github.com/apple/swift-evolution/blob/main/proposals/0280-enum-cases-as-protocol-witnesses.md>
@@ -9509,6 +9521,7 @@ Swift 1.0
95099521
[SE-0355]: <https://github.com/apple/swift-evolution/blob/main/proposals/0355-regex-syntax-run-time-construction.md>
95109522
[SE-0357]: <https://github.com/apple/swift-evolution/blob/main/proposals/0357-regex-string-processing-algorithms.md>
95119523
[SE-0358]: <https://github.com/apple/swift-evolution/blob/main/proposals/0358-primary-associated-types-in-stdlib.md>
9524+
[SE-0362]: <https://github.com/apple/swift-evolution/blob/main/proposals/0362-piecemeal-future-features.md>
95129525

95139526
[SR-75]: <https://bugs.swift.org/browse/SR-75>
95149527
[SR-106]: <https://bugs.swift.org/browse/SR-106>

include/swift/AST/Decl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
#include "swift/AST/TypeAlignments.h"
3636
#include "swift/AST/TypeWalker.h"
3737
#include "swift/AST/Types.h"
38-
#include "swift/AST/Witness.h"
3938
#include "swift/Basic/ArrayRefView.h"
4039
#include "swift/Basic/Compiler.h"
4140
#include "swift/Basic/Debug.h"
@@ -105,6 +104,7 @@ namespace swift {
105104
class ValueDecl;
106105
class VarDecl;
107106
class OpaqueReturnTypeRepr;
107+
class Witness;
108108

109109
namespace ast_scope {
110110
class AbstractPatternEntryScope;

include/swift/AST/DiagnosticsFrontend.def

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ ERROR(error_experimental_feature_not_available, none,
4040
"experimental feature '%0' cannot be enabled in a production compiler",
4141
(StringRef))
4242

43+
ERROR(error_upcoming_feature_on_by_default, none,
44+
"upcoming feature '%0' is already enabled as of Swift version %1",
45+
(StringRef, unsigned))
46+
4347
ERROR(error_unknown_library_level, none,
4448
"unknown library level '%0', "
4549
"expected one of 'api', 'spi' or 'other'", (StringRef))

include/swift/AST/DiagnosticsParse.def

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,8 @@ ERROR(expected_lparen_initializer,PointsToFirstBadToken,
422422
"expected '(' for initializer parameters", ())
423423
ERROR(initializer_has_name,PointsToFirstBadToken,
424424
"initializers cannot have a name", ())
425+
ERROR(initializer_result_type,PointsToFirstBadToken,
426+
"initializers cannot have a result type", ())
425427

426428
// Destructor
427429
ERROR(destructor_decl_outside_class,none,

include/swift/AST/RequirementEnvironment.h

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ namespace swift {
3535
/// environment are the type parameters of the conformance context
3636
/// (\c conformanceDC) with another (deeper) level of type parameters for
3737
/// generic requirements. See the \c Witness class for more information about
38-
/// this synthetic environment.
38+
/// the witness thunk signature.
3939
class RequirementEnvironment {
4040
/// A generic signature that combines the generic parameters of the
4141
/// concrete conforming type with the generic parameters of the
@@ -52,7 +52,7 @@ class RequirementEnvironment {
5252
/// <Self : P, T>
5353
/// <A, B, T>
5454
///
55-
/// The synthetic signature in this case is just the witness signature.
55+
/// The witness thunk signature in this case is just the witness signature.
5656
///
5757
/// It may be that the witness is more generic than the requirement,
5858
/// for example:
@@ -65,22 +65,21 @@ class RequirementEnvironment {
6565
/// <Self : P>
6666
/// <A, B, T>
6767
///
68-
/// The synthetic signature is just:
68+
/// The witness thunk signature is just:
6969
///
7070
/// <A, B>
7171
///
72-
/// The witness thunk emitted by SILGen uses the synthetic signature.
72+
/// The witness thunk emitted by SILGen uses the witness thunk signature.
7373
/// Therefore one invariant we preserve is that the witness thunk is
7474
/// ABI compatible with the requirement's function type.
75-
GenericSignature syntheticSignature = GenericSignature();
76-
GenericEnvironment *syntheticEnvironment = nullptr;
75+
GenericSignature witnessThunkSig = GenericSignature();
7776

7877
/// The generic signature of the protocol requirement member.
7978
GenericSignature reqSig = GenericSignature();
8079

8180
/// A substitution map mapping the requirement signature to the
82-
/// generic parameters of the synthetic signature.
83-
SubstitutionMap reqToSyntheticEnvMap;
81+
/// generic parameters of the witness thunk signature.
82+
SubstitutionMap reqToWitnessThunkSigMap;
8483

8584
public:
8685
/// Create a new environment for matching the given requirement within a
@@ -102,20 +101,20 @@ class RequirementEnvironment {
102101
ClassDecl *covariantSelf,
103102
ProtocolConformance *conformance);
104103

105-
/// Retrieve the synthetic generic environment.
106-
GenericEnvironment *getSyntheticEnvironment() const {
107-
return syntheticEnvironment;
108-
}
109-
110104
/// Retrieve the generic signature of the requirement.
111105
GenericSignature getRequirementSignature() const {
112106
return reqSig;
113107
}
114108

109+
/// Retrieve the generic signature of the witness thunk.
110+
GenericSignature getWitnessThunkSignature() const {
111+
return witnessThunkSig;
112+
}
113+
115114
/// Retrieve the substitution map that maps the interface types of the
116-
/// requirement to the interface types of the synthetic environment.
117-
SubstitutionMap getRequirementToSyntheticMap() const {
118-
return reqToSyntheticEnvMap;
115+
/// requirement to the interface types of the witness thunk signature.
116+
SubstitutionMap getRequirementToWitnessThunkSubs() const {
117+
return reqToWitnessThunkSigMap;
119118
}
120119
};
121120

include/swift/AST/Witness.h

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ class ValueDecl;
7272
/// The witness for \c R.foo(x:) is \c X<U, V>.foo(x:), but the generic
7373
/// functions that describe the generic requirement in \c R and the generic
7474
/// method in \c X have very different signatures. To handle this case, the
75-
/// \c Witness class produces a "synthetic" environment that pulls together
75+
/// \c Witness class produces a witness thunk signature that pulls together
7676
/// all of the information needed to map from the requirement to the witness.
7777
/// It is a generic environment that combines the constraints of the
7878
/// requirement with the constraints from the context of the protocol
@@ -81,19 +81,19 @@ class ValueDecl;
8181
/// environment are those of the context of the protocol conformance (\c U
8282
/// and \c V, in the example above) and the innermost generic parameters are
8383
/// those of the generic requirement (\c T, in the example above). The
84-
/// \c Witness class contains this synthetic environment (both its generic
84+
/// \c Witness class contains this witness thunk signature (both its generic
8585
/// signature and a generic environment providing archetypes), a substitution
8686
/// map that allows one to map the interface types of the requirement into
87-
/// the interface types of the synthetic domain, and the set of substitutions
88-
/// required to use the witness from the synthetic domain (e.g., how one would
87+
/// the interface types of the witness thunk domain, and the set of substitutions
88+
/// required to use the witness from the witness thunk domain (e.g., how one would
8989
/// call the witness from the witness thunk).
9090
class Witness {
9191
struct StoredWitness {
9292
/// The witness declaration, along with the substitutions needed to use
93-
/// the witness declaration from the synthetic environment.
93+
/// the witness declaration from the witness thunk signature.
9494
ConcreteDeclRef declRef;
95-
GenericEnvironment *syntheticEnvironment;
96-
SubstitutionMap reqToSyntheticEnvSubs;
95+
GenericSignature witnessThunkSig;
96+
SubstitutionMap reqToWitnessThunkSigSubs;
9797
/// The derivative generic signature, when the requirement is a derivative
9898
/// function.
9999
GenericSignature derivativeGenSig;
@@ -124,7 +124,7 @@ class Witness {
124124

125125
/// Create a witness for the given requirement.
126126
///
127-
/// Deserialized witnesses do not have a synthetic environment.
127+
/// Deserialized witnesses do not have a witness thunk signature.
128128
static Witness forDeserialized(ValueDecl *decl,
129129
SubstitutionMap substitutions,
130130
Optional<ActorIsolation> enterIsolation) {
@@ -139,12 +139,12 @@ class Witness {
139139
/// \param decl The declaration for the witness.
140140
///
141141
/// \param substitutions The substitutions required to use the witness from
142-
/// the synthetic environment.
142+
/// the witness thunk signature.
143143
///
144-
/// \param syntheticEnv The synthetic environment.
144+
/// \param witnessThunkSig The witness thunk signature.
145145
///
146-
/// \param reqToSyntheticEnvSubs The mapping from the interface types of the
147-
/// requirement into the interface types of the synthetic environment.
146+
/// \param reqToWitnessThunkSigSubs The mapping from the interface types of the
147+
/// requirement into the interface types of the witness thunk signature.
148148
///
149149
/// \param derivativeGenSig The derivative generic signature, when the
150150
/// requirement is a derivative function.
@@ -153,13 +153,13 @@ class Witness {
153153
/// need to hop to before calling the witness.
154154
Witness(ValueDecl *decl,
155155
SubstitutionMap substitutions,
156-
GenericEnvironment *syntheticEnv,
157-
SubstitutionMap reqToSyntheticEnvSubs,
156+
GenericSignature witnessThunkSig,
157+
SubstitutionMap reqToWitnessThunkSigSubs,
158158
GenericSignature derivativeGenSig,
159159
Optional<ActorIsolation> enterIsolation);
160160

161161
/// Retrieve the witness declaration reference, which includes the
162-
/// substitutions needed to use the witness from the synthetic environment
162+
/// substitutions needed to use the witness from the witness thunk signature
163163
/// (if any).
164164
ConcreteDeclRef getDeclRef() const {
165165
if (auto stored = storage.dyn_cast<StoredWitness *>())
@@ -175,26 +175,23 @@ class Witness {
175175
explicit operator bool() const { return !storage.isNull(); }
176176

177177
/// Retrieve the substitutions required to use this witness from the
178-
/// synthetic environment.
179-
///
180-
/// The substitutions are substitutions for the witness, providing interface
181-
/// types from the synthetic environment.
178+
/// witness thunk signature.
182179
SubstitutionMap getSubstitutions() const {
183180
return getDeclRef().getSubstitutions();
184181
}
185182

186-
/// Retrieve the synthetic generic environment.
187-
GenericEnvironment *getSyntheticEnvironment() const {
183+
/// Retrieve the witness thunk generic signature.
184+
GenericSignature getWitnessThunkSignature() const {
188185
if (auto *storedWitness = storage.dyn_cast<StoredWitness *>())
189-
return storedWitness->syntheticEnvironment;
186+
return storedWitness->witnessThunkSig;
190187
return nullptr;
191188
}
192189

193190
/// Retrieve the substitution map that maps the interface types of the
194-
/// requirement to the interface types of the synthetic environment.
195-
SubstitutionMap getRequirementToSyntheticSubs() const {
191+
/// requirement to the interface types of the witness thunk signature.
192+
SubstitutionMap getRequirementToWitnessThunkSubs() const {
196193
if (auto *storedWitness = storage.dyn_cast<StoredWitness *>())
197-
return storedWitness->reqToSyntheticEnvSubs;
194+
return storedWitness->reqToWitnessThunkSigSubs;
198195
return {};
199196
}
200197

include/swift/Basic/Feature.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ inline bool featureImpliesFeature(Feature feature, Feature implied) {
5353
}
5454

5555
/// Get the feature corresponding to this "future" feature, if there is one.
56-
llvm::Optional<Feature> getFutureFeature(llvm::StringRef name);
56+
llvm::Optional<Feature> getUpcomingFeature(llvm::StringRef name);
5757

5858
/// Get the feature corresponding to this "experimental" feature, if there is
5959
/// one.

include/swift/Basic/Features.def

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@
4848
LANGUAGE_FEATURE(FeatureName, SENumber, Description, Option)
4949
#endif
5050

51-
#ifndef FUTURE_FEATURE
52-
# define FUTURE_FEATURE(FeatureName, SENumber, Version) \
51+
#ifndef UPCOMING_FEATURE
52+
# define UPCOMING_FEATURE(FeatureName, SENumber, Version) \
5353
LANGUAGE_FEATURE(FeatureName, SENumber, #FeatureName, \
5454
langOpts.hasFeature(#FeatureName))
5555
#endif
@@ -90,9 +90,9 @@ SUPPRESSIBLE_LANGUAGE_FEATURE(PrimaryAssociatedTypes2, 346, "Primary associated
9090
SUPPRESSIBLE_LANGUAGE_FEATURE(UnavailableFromAsync, 0, "@_unavailableFromAsync", true)
9191
SUPPRESSIBLE_LANGUAGE_FEATURE(NoAsyncAvailability, 340, "@available(*, noasync)", true)
9292

93-
FUTURE_FEATURE(ConciseMagicFile, 274, 6)
94-
FUTURE_FEATURE(ForwardTrailingClosures, 286, 6)
95-
FUTURE_FEATURE(BareSlashRegexLiterals, 354, 6)
93+
UPCOMING_FEATURE(ConciseMagicFile, 274, 6)
94+
UPCOMING_FEATURE(ForwardTrailingClosures, 286, 6)
95+
UPCOMING_FEATURE(BareSlashRegexLiterals, 354, 6)
9696

9797
EXPERIMENTAL_FEATURE(StaticAssert)
9898
EXPERIMENTAL_FEATURE(VariadicGenerics)
@@ -118,6 +118,6 @@ EXPERIMENTAL_FEATURE(AdditiveArithmeticDerivedConformances)
118118
EXPERIMENTAL_FEATURE(SendableCompletionHandlers)
119119

120120
#undef EXPERIMENTAL_FEATURE
121-
#undef FUTURE_FEATURE
121+
#undef UPCOMING_FEATURE
122122
#undef SUPPRESSIBLE_LANGUAGE_FEATURE
123123
#undef LANGUAGE_FEATURE

include/swift/Basic/LangOptions.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include "llvm/ADT/SmallString.h"
2929
#include "llvm/ADT/SmallSet.h"
3030
#include "llvm/ADT/SmallVector.h"
31+
#include "llvm/ADT/SmallSet.h"
3132
#include "llvm/ADT/StringRef.h"
3233
#include "llvm/ADT/Triple.h"
3334
#include "llvm/Support/Regex.h"

include/swift/Option/Options.td

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -696,6 +696,11 @@ def enable_experimental_feature :
696696
Flags<[FrontendOption]>,
697697
HelpText<"Enable an experimental feature">;
698698

699+
def enable_upcoming_feature : Separate<["-"], "enable-upcoming-feature">,
700+
Flags<[FrontendOption]>,
701+
HelpText<"Enable a feature that will be introduced in an upcoming language "
702+
"version">;
703+
699704
def Rpass_EQ : Joined<["-"], "Rpass=">,
700705
Flags<[FrontendOption]>,
701706
HelpText<"Report performed transformations by optimization passes whose "

0 commit comments

Comments
 (0)