Skip to content

Commit 884c501

Browse files
Merge pull request swiftlang#85839 from swiftlang/jepa-release2
[6.3][NFC] "SwiftVersion" → "LanguageMode" in `DiagnosticEngine::warnUntilSwiftVersion`, etc.
2 parents 8d00ceb + 1e64183 commit 884c501

File tree

67 files changed

+402
-392
lines changed

Some content is hidden

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

67 files changed

+402
-392
lines changed

include/swift/AST/ASTContext.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1554,9 +1554,9 @@ class ASTContext final {
15541554
///
15551555
/// This is usually the check you want; for example, when introducing
15561556
/// a new language feature which is only visible in Swift 5, you would
1557-
/// check for isSwiftVersionAtLeast(5).
1558-
bool isSwiftVersionAtLeast(unsigned major, unsigned minor = 0) const {
1559-
return LangOpts.isSwiftVersionAtLeast(major, minor);
1557+
/// check for isLanguageModeAtLeast(5).
1558+
bool isLanguageModeAtLeast(unsigned major, unsigned minor = 0) const {
1559+
return LangOpts.isLanguageModeAtLeast(major, minor);
15601560
}
15611561

15621562
/// Check whether it's important to respect access control restrictions

include/swift/AST/DiagnosticEngine.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -388,8 +388,8 @@ namespace swift {
388388
///
389389
/// This helps stage in fixes for stricter diagnostics as warnings
390390
/// until the next major language version.
391-
InFlightDiagnostic &limitBehaviorUntilSwiftVersion(
392-
DiagnosticBehavior limit, unsigned majorVersion);
391+
InFlightDiagnostic &limitBehaviorUntilLanguageMode(DiagnosticBehavior limit,
392+
unsigned majorVersion);
393393

394394
/// Limits the diagnostic behavior to \c limit accordingly if
395395
/// preconcurrency applies. Otherwise, the behavior limit only applies
@@ -412,7 +412,7 @@ namespace swift {
412412
return limitBehavior(limit);
413413
}
414414

415-
return limitBehaviorUntilSwiftVersion(limit, languageMode);
415+
return limitBehaviorUntilLanguageMode(limit, languageMode);
416416
}
417417

418418
/// Limit the diagnostic behavior to warning until the next future
@@ -424,19 +424,19 @@ namespace swift {
424424
///
425425
/// This helps stage in fixes for stricter diagnostics as warnings
426426
/// until the next major language version.
427-
InFlightDiagnostic &warnUntilFutureSwiftVersion();
427+
InFlightDiagnostic &warnUntilFutureLanguageMode();
428428

429-
InFlightDiagnostic &warnUntilFutureSwiftVersionIf(bool shouldLimit) {
429+
InFlightDiagnostic &warnUntilFutureLanguageModeIf(bool shouldLimit) {
430430
if (!shouldLimit)
431431
return *this;
432-
return warnUntilFutureSwiftVersion();
432+
return warnUntilFutureLanguageMode();
433433
}
434434

435435
/// Limit the diagnostic behavior to warning until the specified version.
436436
///
437437
/// This helps stage in fixes for stricter diagnostics as warnings
438438
/// until the next major language version.
439-
InFlightDiagnostic &warnUntilSwiftVersion(unsigned majorVersion);
439+
InFlightDiagnostic &warnUntilLanguageMode(unsigned majorVersion);
440440

441441
/// Limit the diagnostic behavior to warning if the context is a
442442
/// swiftinterface.
@@ -453,10 +453,10 @@ namespace swift {
453453
///
454454
/// This helps stage in fixes for stricter diagnostics as warnings
455455
/// until the next major language version.
456-
InFlightDiagnostic &warnUntilSwiftVersionIf(bool shouldLimit,
456+
InFlightDiagnostic &warnUntilLanguageModeIf(bool shouldLimit,
457457
unsigned majorVersion) {
458458
if (!shouldLimit) return *this;
459-
return warnUntilSwiftVersion(majorVersion);
459+
return warnUntilLanguageMode(majorVersion);
460460
}
461461

462462
/// Wraps this diagnostic in another diagnostic. That is, \p wrapper will be
@@ -887,7 +887,7 @@ namespace swift {
887887
version::Version languageVersion;
888888

889889
/// The stats reporter used to keep track of Swift 6 errors
890-
/// diagnosed via \c warnUntilSwiftVersion(6).
890+
/// diagnosed via \c warnUntilLanguageMode(6).
891891
UnifiedStatsReporter *statsReporter = nullptr;
892892

893893
/// Whether we are actively pretty-printing a declaration as part of

include/swift/Basic/Feature.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ struct Feature {
8282

8383
/// Get the major language version in which this feature was introduced, or
8484
/// \c None if it does not have such a version.
85-
std::optional<unsigned> getLanguageVersion() const;
85+
std::optional<unsigned> getLanguageMode() const;
8686
};
8787

8888
#define LANGUAGE_FEATURE(FeatureName, SENumber, Description) \

include/swift/Basic/Features.def

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@
5050
// Swift compiler.
5151
//
5252
// OPTIONAL_LANGUAGE_FEATURE is the same as LANGUAGE_FEATURE, but describes
53-
// accepted features that can be enabled independently of language version and
54-
// are not scheduled to be enabled in some specific language version. Examples
53+
// accepted features that can be enabled independently of language mode and
54+
// are not scheduled to be enabled in some specific language mode. Examples
5555
// of optional language features include strict memory safety checking (SE-0458)
5656
// and Embedded Swift.
5757
//===----------------------------------------------------------------------===//
@@ -82,11 +82,11 @@
8282
defined(UPCOMING_FEATURE)
8383
# error ambiguous defines when including Features.def
8484
# elif defined(SUPPRESSIBLE_LANGUAGE_FEATURE)
85-
# define SUPPRESSIBLE_UPCOMING_FEATURE(FeatureName, SENumber, Version) \
85+
# define SUPPRESSIBLE_UPCOMING_FEATURE(FeatureName, SENumber, LanguageMode) \
8686
SUPPRESSIBLE_LANGUAGE_FEATURE(FeatureName, SENumber, #FeatureName)
8787
# else
88-
# define SUPPRESSIBLE_UPCOMING_FEATURE(FeatureName, SENumber, Version) \
89-
UPCOMING_FEATURE(FeatureName, SENumber, Version)
88+
# define SUPPRESSIBLE_UPCOMING_FEATURE(FeatureName, SENumber, LanguageMode) \
89+
UPCOMING_FEATURE(FeatureName, SENumber, LanguageMode)
9090
# endif
9191
#endif
9292

@@ -136,10 +136,10 @@
136136
// feature is disabled.
137137
#ifndef MIGRATABLE_UPCOMING_FEATURE
138138
#if defined(UPCOMING_FEATURE)
139-
#define MIGRATABLE_UPCOMING_FEATURE(FeatureName, SENumber, Version) \
140-
UPCOMING_FEATURE(FeatureName, SENumber, Version)
139+
#define MIGRATABLE_UPCOMING_FEATURE(FeatureName, SENumber, LanguageMode) \
140+
UPCOMING_FEATURE(FeatureName, SENumber, LanguageMode)
141141
#else
142-
#define MIGRATABLE_UPCOMING_FEATURE(FeatureName, SENumber, Version) \
142+
#define MIGRATABLE_UPCOMING_FEATURE(FeatureName, SENumber, LanguageMode) \
143143
LANGUAGE_FEATURE(FeatureName, SENumber, #FeatureName)
144144
#endif
145145
#endif
@@ -161,7 +161,7 @@
161161
#endif
162162

163163
#ifndef UPCOMING_FEATURE
164-
#define UPCOMING_FEATURE(FeatureName, SENumber, Version) \
164+
#define UPCOMING_FEATURE(FeatureName, SENumber, LanguageMode) \
165165
LANGUAGE_FEATURE(FeatureName, SENumber, #FeatureName)
166166
#endif
167167

include/swift/Basic/LangOptions.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -745,8 +745,8 @@ namespace swift {
745745
///
746746
/// This is usually the check you want; for example, when introducing
747747
/// a new language feature which is only visible in Swift 5, you would
748-
/// check for isSwiftVersionAtLeast(5).
749-
bool isSwiftVersionAtLeast(unsigned major, unsigned minor = 0) const {
748+
/// check for isLanguageModeAtLeast(5).
749+
bool isLanguageModeAtLeast(unsigned major, unsigned minor = 0) const {
750750
return EffectiveLanguageVersion.isVersionAtLeast(major, minor);
751751
}
752752

lib/AST/ASTContext.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4182,7 +4182,7 @@ AnyFunctionType::Param swift::computeSelfParam(AbstractFunctionDecl *AFD,
41824182
// NOTE: it's important that we check if it's a convenience init only after
41834183
// confirming it's not semantically final, or else there can be a request
41844184
// evaluator cycle to determine the init kind for actors, which are final.
4185-
if (Ctx.isSwiftVersionAtLeast(5)) {
4185+
if (Ctx.isLanguageModeAtLeast(5)) {
41864186
if (wantDynamicSelf)
41874187
if (auto *classDecl = selfTy->getClassOrBoundGenericClass())
41884188
if (!classDecl->isSemanticallyFinal() && CD->isConvenienceInit())

lib/AST/ASTVerifier.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2194,7 +2194,7 @@ class Verifier : public ASTWalker {
21942194
void verifyChecked(OptionalTryExpr *E) {
21952195
PrettyStackTraceExpr debugStack(Ctx, "verifying OptionalTryExpr", E);
21962196

2197-
if (Ctx.LangOpts.isSwiftVersionAtLeast(5)) {
2197+
if (Ctx.isLanguageModeAtLeast(5)) {
21982198
checkSameType(E->getType(), E->getSubExpr()->getType(),
21992199
"OptionalTryExpr and sub-expression");
22002200
}

lib/AST/Decl.cpp

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1231,9 +1231,8 @@ bool Decl::preconcurrency() const {
12311231

12321232
// Variables declared in top-level code are @_predatesConcurrency
12331233
if (const VarDecl *var = dyn_cast<VarDecl>(this)) {
1234-
const LangOptions &langOpts = getASTContext().LangOpts;
1235-
return !langOpts.isSwiftVersionAtLeast(6) && var->isTopLevelGlobal() &&
1236-
var->getDeclContext()->isAsyncContext();
1234+
return !getASTContext().isLanguageModeAtLeast(6) &&
1235+
var->isTopLevelGlobal() && var->getDeclContext()->isAsyncContext();
12371236
}
12381237

12391238
return false;
@@ -2835,7 +2834,7 @@ static bool isDefaultInitializable(const TypeRepr *typeRepr, ASTContext &ctx) {
28352834
return true;
28362835

28372836
// Also support the desugared 'Optional<T>' spelling.
2838-
if (!ctx.isSwiftVersionAtLeast(5)) {
2837+
if (!ctx.isLanguageModeAtLeast(5)) {
28392838
if (typeRepr->isSimpleUnqualifiedIdentifier(ctx.Id_Void)) {
28402839
return true;
28412840
}
@@ -3016,7 +3015,7 @@ static bool deferMatchesEnclosingAccess(const FuncDecl *defer) {
30163015
assert(defer->isDeferBody());
30173016

30183017
// In Swift 6+, then yes.
3019-
if (defer->getASTContext().isSwiftVersionAtLeast(6))
3018+
if (defer->getASTContext().isLanguageModeAtLeast(6))
30203019
return true;
30213020

30223021
// If the defer is part of a function that is a member of an actor or
@@ -3090,7 +3089,7 @@ static bool isDirectToStorageAccess(const DeclContext *UseDC,
30903089
// In Swift 5 and later, the access must also be a member access on 'self'.
30913090
if (!isAccessOnSelf &&
30923091
var->getDeclContext()->isTypeContext() &&
3093-
var->getASTContext().isSwiftVersionAtLeast(5))
3092+
var->getASTContext().isLanguageModeAtLeast(5))
30943093
return false;
30953094

30963095
// As a special case, 'read' and 'modify' coroutines with forced static
@@ -4058,7 +4057,7 @@ bool swift::conflicting(ASTContext &ctx,
40584057
// Prior to Swift 5, we permitted redeclarations of variables as different
40594058
// declarations if the variable was declared in an extension of a generic
40604059
// type. Make sure we maintain this behaviour in versions < 5.
4061-
if (!ctx.isSwiftVersionAtLeast(5)) {
4060+
if (!ctx.isLanguageModeAtLeast(5)) {
40624061
if ((sig1.IsVariable && sig1.InExtensionOfGenericType) ||
40634062
(sig2.IsVariable && sig2.InExtensionOfGenericType)) {
40644063
if (wouldConflictInSwift5)
@@ -4082,7 +4081,7 @@ bool swift::conflicting(ASTContext &ctx,
40824081
// Swift 5, a variable not in an extension of a generic type got a null
40834082
// overload type instead of a function type as it does now, so we really
40844083
// follow that behaviour and warn if there's going to be a conflict in future.
4085-
if (!ctx.isSwiftVersionAtLeast(5)) {
4084+
if (!ctx.isLanguageModeAtLeast(5)) {
40864085
auto swift4Sig1Type = sig1.IsVariable && !sig1.InExtensionOfGenericType
40874086
? CanType()
40884087
: sig1Type;
@@ -12207,8 +12206,8 @@ ActorIsolation swift::getActorIsolationOfContext(
1220712206
if (dcToUse->isAsyncContext() ||
1220812207
ctx.LangOpts.StrictConcurrencyLevel >= StrictConcurrency::Complete) {
1220912208
if (Type mainActor = ctx.getMainActorType())
12210-
return ActorIsolation::forGlobalActor(mainActor)
12211-
.withPreconcurrency(!ctx.isSwiftVersionAtLeast(6));
12209+
return ActorIsolation::forGlobalActor(mainActor).withPreconcurrency(
12210+
!ctx.isLanguageModeAtLeast(6));
1221212211
}
1221312212
}
1221412213

lib/AST/DiagnosticEngine.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -459,8 +459,8 @@ InFlightDiagnostic::limitBehavior(DiagnosticBehavior limit) {
459459
}
460460

461461
InFlightDiagnostic &
462-
InFlightDiagnostic::limitBehaviorUntilSwiftVersion(
463-
DiagnosticBehavior limit, unsigned majorVersion) {
462+
InFlightDiagnostic::limitBehaviorUntilLanguageMode(DiagnosticBehavior limit,
463+
unsigned majorVersion) {
464464
if (!Engine->languageVersion.isVersionAtLeast(majorVersion)) {
465465
// If the behavior limit is a warning or less, wrap the diagnostic
466466
// in a message that this will become an error in a later Swift
@@ -487,14 +487,14 @@ InFlightDiagnostic::limitBehaviorUntilSwiftVersion(
487487
return *this;
488488
}
489489

490-
InFlightDiagnostic &InFlightDiagnostic::warnUntilFutureSwiftVersion() {
490+
InFlightDiagnostic &InFlightDiagnostic::warnUntilFutureLanguageMode() {
491491
using namespace version;
492-
return warnUntilSwiftVersion(Version::getFutureMajorLanguageVersion());
492+
return warnUntilLanguageMode(Version::getFutureMajorLanguageVersion());
493493
}
494494

495495
InFlightDiagnostic &
496-
InFlightDiagnostic::warnUntilSwiftVersion(unsigned majorVersion) {
497-
return limitBehaviorUntilSwiftVersion(DiagnosticBehavior::Warning,
496+
InFlightDiagnostic::warnUntilLanguageMode(unsigned majorVersion) {
497+
return limitBehaviorUntilLanguageMode(DiagnosticBehavior::Warning,
498498
majorVersion);
499499
}
500500

lib/AST/NameLookup.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,7 @@ static void recordShadowedDeclsAfterTypeMatch(
610610
// This is due to the fact that in Swift 4, we only gave custom overload
611611
// types to properties in extensions of generic types, otherwise we
612612
// used the null type.
613-
if (!ctx.isSwiftVersionAtLeast(5) && isa<ValueDecl>(firstDecl)) {
613+
if (!ctx.isLanguageModeAtLeast(5) && isa<ValueDecl>(firstDecl)) {
614614
auto secondSig = cast<ValueDecl>(secondDecl)->getOverloadSignature();
615615
auto firstSig = cast<ValueDecl>(firstDecl)->getOverloadSignature();
616616
if (firstSig.IsVariable && secondSig.IsVariable)

0 commit comments

Comments
 (0)