Skip to content

Commit dcc43ec

Browse files
committed
Adjust to return compatibility version in Swift 3 mode.
1 parent b7b9245 commit dcc43ec

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

lib/Basic/Version.cpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -312,19 +312,23 @@ Optional<Version> Version::getEffectiveLanguageVersion() const {
312312
return None;
313313
}
314314

315-
// FIXME: When we switch to Swift 4 by default, the "3" case should return
316-
// a version newer than any released 3.x compiler (probably "3.2"), and the
317-
// "4" case should start returning getCurrentLanguageVersion. We should
315+
// FIXME: When we switch to Swift 5 by default, the "4" case should return
316+
// a version newer than any released 4.x compiler, and the
317+
// "5" case should start returning getCurrentLanguageVersion. We should
318318
// also check for the presence of SWIFT_VERSION_PATCHLEVEL, and if that's
319319
// set apply it to the "3" case, so that Swift 4.0.1 will automatically
320320
// have a compatibility mode of 3.2.1.
321321
switch (Components[0]) {
322322
case 3:
323-
static_assert(SWIFT_VERSION_MAJOR == 3,
323+
#ifdef SWIFT_VERSION_PATCHLEVEL
324+
return Version{3, 2, SWIFT_VERSION_PATCHLEVEL};
325+
#else
326+
return Version{3, 2};
327+
#endif
328+
case 4:
329+
static_assert(SWIFT_VERSION_MAJOR == 4,
324330
"getCurrentLanguageVersion is no longer correct here");
325331
return Version::getCurrentLanguageVersion();
326-
case 4:
327-
return Version{4, 0};
328332
default:
329333
return None;
330334
}

0 commit comments

Comments
 (0)