File tree Expand file tree Collapse file tree 3 files changed +15
-6
lines changed Expand file tree Collapse file tree 3 files changed +15
-6
lines changed Original file line number Diff line number Diff line change @@ -880,8 +880,8 @@ class ASTContext final {
880
880
// / This is usually the check you want; for example, when introducing
881
881
// / a new language feature which is only visible in Swift 5, you would
882
882
// / check for isSwiftVersionAtLeast(5).
883
- bool isSwiftVersionAtLeast (unsigned major) const {
884
- return LangOpts.isSwiftVersionAtLeast (major);
883
+ bool isSwiftVersionAtLeast (unsigned major, unsigned minor = 0 ) const {
884
+ return LangOpts.isSwiftVersionAtLeast (major, minor );
885
885
}
886
886
887
887
private:
Original file line number Diff line number Diff line change @@ -342,8 +342,8 @@ namespace swift {
342
342
// / This is usually the check you want; for example, when introducing
343
343
// / a new language feature which is only visible in Swift 5, you would
344
344
// / check for isSwiftVersionAtLeast(5).
345
- bool isSwiftVersionAtLeast (unsigned major) const {
346
- return EffectiveLanguageVersion.isVersionAtLeast (major);
345
+ bool isSwiftVersionAtLeast (unsigned major, unsigned minor = 0 ) const {
346
+ return EffectiveLanguageVersion.isVersionAtLeast (major, minor );
347
347
}
348
348
349
349
// / Returns true if the given platform condition argument represents
Original file line number Diff line number Diff line change @@ -112,8 +112,17 @@ class Version {
112
112
113
113
// / Whether this version is greater than or equal to the given major version
114
114
// / number.
115
- bool isVersionAtLeast (unsigned major) const {
116
- return !empty () && Components[0 ] >= major;
115
+ bool isVersionAtLeast (unsigned major, unsigned minor = 0 ) const {
116
+ switch (size ()) {
117
+ case 0 :
118
+ return false ;
119
+ case 1 :
120
+ return ((Components[0 ] == major && 0 == minor) ||
121
+ (Components[0 ] > major));
122
+ default :
123
+ return ((Components[0 ] == major && Components[1 ] >= minor) ||
124
+ (Components[0 ] > major));
125
+ }
117
126
}
118
127
119
128
// / Return this Version struct with minor and sub-minor components stripped
You can’t perform that action at this time.
0 commit comments