Skip to content

bumping master to Swift 5.0 #18853

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ set_property(CACHE SWIFT_ANALYZE_CODE_COVERAGE PROPERTY
# SWIFT_VERSION is deliberately /not/ cached so that an existing build directory
# can be reused when a new version of Swift comes out (assuming the user hasn't
# manually set it as part of their own CMake configuration).
set(SWIFT_VERSION "4.2")
set(SWIFT_VERSION "5.0")

set(SWIFT_VENDOR "" CACHE STRING
"The vendor name of the Swift compiler")
Expand Down
17 changes: 7 additions & 10 deletions lib/Basic/Version.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -317,28 +317,25 @@ Optional<Version> Version::getEffectiveLanguageVersion() const {
return None;
}

// FIXME: When we switch to Swift 5 by default, the "4" case should return
// a version newer than any released 4.x compiler, and the
// "5" case should start returning getCurrentLanguageVersion. We should
// also check for the presence of SWIFT_VERSION_PATCHLEVEL, and if that's
// set apply it to the "3" case, so that Swift 4.0.1 will automatically
// have a compatibility mode of 3.2.1.
switch (Components[0]) {
// FIXME: When switching to a new major version by default---say, Swift 4---
// the "3" case should return a version newer than any released 3.x compiler,
// and the "4" case should start returning getCurrentLanguageVersion. switch (Components[0]) {
case 3:
#ifdef SWIFT_VERSION_PATCHLEVEL
return Version{3, 4, SWIFT_VERSION_PATCHLEVEL};
#else
return Version{3, 4};
#endif
case 4:
static_assert(SWIFT_VERSION_MAJOR == 4,
"getCurrentLanguageVersion is no longer correct here");
// Version '4' on its own implies '4.1.50'.
if (size() == 1)
return Version{4, 1, 50};
return Version::getCurrentLanguageVersion();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line here's no longer going to be right. Maybe the whole section should be "If Version >= 4.2, return 4.2, else return 4.1.50".

case 5:
return Version{5, 0};
static_assert(SWIFT_VERSION_MAJOR == 5,
"getCurrentLanguageVersion is no longer correct here");

return Version::getCurrentLanguageVersion();
default:
return None;
}
Expand Down
12 changes: 12 additions & 0 deletions test/Driver/swift-version-default.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,18 @@ htn
#endif

#if swift(>=5)
aoeu // expected-error {{use of unresolved identifier}}
#else
htn
#endif

#if swift(>=5.1)
aoeu
#else
htn // expected-error {{use of unresolved identifier}}
#endif

#if swift(>=6)
aoeu
#else
htn // expected-error {{use of unresolved identifier}}
Expand Down
2 changes: 1 addition & 1 deletion test/SILOptimizer/cast_foldings.sil
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ bb0(%0 : $*AnyObject):
// CHECK: store [[TMP]] to %0 : $*Optional<AnyObject>
sil @testIOU : $@convention(thin) (@in Optional<AnyObject>) -> (@out Optional<AnyObject>) {
bb0(%0 : $*Optional<AnyObject>, %1: $*Optional<AnyObject>):
unconditional_checked_cast_addr ImplicitlyUnwrappedOptional<AnyObject> in %1 : $*Optional<AnyObject> to Optional<AnyObject> in %0 : $*Optional<AnyObject>
unconditional_checked_cast_addr Swift.ImplicitlyUnwrappedOptional<AnyObject> in %1 : $*Optional<AnyObject> to Optional<AnyObject> in %0 : $*Optional<AnyObject>
%2 = tuple ()
return %2 : $()
}
2 changes: 1 addition & 1 deletion utils/build_swift/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
CMAKE_GENERATOR = 'Ninja'

COMPILER_VENDOR = 'none'
SWIFT_USER_VISIBLE_VERSION = CompilerVersion('4.2')
SWIFT_USER_VISIBLE_VERSION = CompilerVersion('5.0')
CLANG_USER_VISIBLE_VERSION = CompilerVersion('6.0.0')
SWIFT_ANALYZE_CODE_COVERAGE = 'false'

Expand Down