Skip to content

[stdlib] Build the standard library as Swift 5 #18121

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

Merged
merged 6 commits into from
Jul 25, 2018
Merged
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
4 changes: 2 additions & 2 deletions cmake/modules/SwiftSource.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,9 @@ function(_compile_swift_files
"-Xfrontend" "${GROUP_INFO_JSON_FILE}")
endif()

# Force swift 4 compatibility mode for Standard Library.
# Force swift 5 mode for Standard Library.
if (SWIFTFILE_IS_STDLIB)
list(APPEND swift_flags "-swift-version" "4")
list(APPEND swift_flags "-swift-version" "5")
endif()

# Force swift 4 compatibility mode for overlays.
Expand Down
5 changes: 4 additions & 1 deletion stdlib/public/core/Array.swift
Original file line number Diff line number Diff line change
Expand Up @@ -962,7 +962,10 @@ extension Array: RangeReplaceableCollection, ArrayProtocol {
@inlinable
public // @testable
var _owner: AnyObject? {
return _buffer.owner
@inline(__always)
get {
return _buffer.owner
}
}

/// If the elements are stored contiguously, a pointer to the first
Expand Down
18 changes: 3 additions & 15 deletions stdlib/public/core/Codable.swift.gyb
Original file line number Diff line number Diff line change
Expand Up @@ -1116,7 +1116,6 @@ public struct CodingUserInfoKey : RawRepresentable, Equatable, Hashable {
/// An error that occurs during the encoding of a value.
public enum EncodingError : Error {
/// The context in which the error occurred.
@_fixed_layout // FIXME(sil-serialize-all)
public struct Context {
/// The path of coding keys taken to get to the point of the failing encode
/// call.
Expand All @@ -1137,7 +1136,6 @@ public enum EncodingError : Error {
/// debugging purposes.
/// - parameter underlyingError: The underlying error which caused this
/// error, if any.
@inlinable // FIXME(sil-serialize-all)
public init(
codingPath: [CodingKey],
debugDescription: String,
Expand All @@ -1163,19 +1161,16 @@ public enum EncodingError : Error {
// access CustomNSError (which is defined in Foundation) from here, we can
// use the "hidden" entry points.

@inlinable // FIXME(sil-serialize-all)
public var _domain: String {
return "NSCocoaErrorDomain"
}

@inlinable // FIXME(sil-serialize-all)
public var _code: Int {
switch self {
case .invalidValue(_, _): return 4866
case .invalidValue: return 4866
}
}

@inlinable // FIXME(sil-serialize-all)
public var _userInfo: AnyObject? {
// The error dictionary must be returned as an AnyObject. We can do this
// only on platforms with bridging, unfortunately.
Expand Down Expand Up @@ -1204,7 +1199,6 @@ public enum EncodingError : Error {
/// An error that occurs during the decoding of a value.
public enum DecodingError : Error {
/// The context in which the error occurred.
@_fixed_layout // FIXME(sil-serialize-all)
public struct Context {
/// The path of coding keys taken to get to the point of the failing decode
/// call.
Expand All @@ -1225,7 +1219,6 @@ public enum DecodingError : Error {
/// debugging purposes.
/// - parameter underlyingError: The underlying error which caused this
/// error, if any.
@inlinable // FIXME(sil-serialize-all)
public init(
codingPath: [CodingKey],
debugDescription: String,
Expand Down Expand Up @@ -1270,22 +1263,17 @@ public enum DecodingError : Error {
// access CustomNSError (which is defined in Foundation) from here, we can
// use the "hidden" entry points.

@inlinable // FIXME(sil-serialize-all)
public var _domain: String {
return "NSCocoaErrorDomain"
}

@inlinable // FIXME(sil-serialize-all)
public var _code: Int {
switch self {
case .keyNotFound(_, _): fallthrough
case .valueNotFound(_, _): return 4865
case .typeMismatch(_, _): fallthrough
case .dataCorrupted(_): return 4864
case .keyNotFound, .valueNotFound: return 4865
case .typeMismatch, .dataCorrupted: return 4864
}
}

@inlinable // FIXME(sil-serialize-all)
public var _userInfo: AnyObject? {
// The error dictionary must be returned as an AnyObject. We can do this
// only on platforms with bridging, unfortunately.
Expand Down
1 change: 1 addition & 0 deletions stdlib/public/core/Dictionary.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4347,6 +4347,7 @@ extension Dictionary.Index {
#if _runtime(_ObjC)
@usableFromInline
final internal class _CocoaDictionaryIterator: IteratorProtocol {
@usableFromInline
internal typealias Element = (AnyObject, AnyObject)

// Cocoa Dictionary iterator has to be a class, otherwise we cannot
Expand Down
11 changes: 11 additions & 0 deletions stdlib/public/core/FloatingPointTypes.swift.gyb
Original file line number Diff line number Diff line change
Expand Up @@ -1017,8 +1017,19 @@ extension ${Self}: BinaryFloatingPoint {
_value = Builtin.int_ceil_FPIEEE${bits}(_value)
case .down:
_value = Builtin.int_floor_FPIEEE${bits}(_value)
@unknown default:
self._roundSlowPath(rule)
}
}

// Slow path for new cases that might have been inlined into an old
// ABI-stable version of round(_:) called from a newer version. If this is
// the case, this non-inlinable function will call into the _newer_ version
// which _will_ support this rounding rule.
@usableFromInline
internal mutating func _roundSlowPath(_ rule: FloatingPointRoundingRule) {
self.round(rule)
}

/// Replaces this value with its additive inverse.
///
Expand Down
8 changes: 4 additions & 4 deletions stdlib/public/core/MigrationSupport.swift
Original file line number Diff line number Diff line change
Expand Up @@ -688,13 +688,13 @@ extension String.UTF8View {
}
}

@available(swift,deprecated: 5.0, renamed: "Unicode.UTF8")
// @available(swift,deprecated: 5.0, renamed: "Unicode.UTF8")
public typealias UTF8 = Unicode.UTF8
@available(swift, deprecated: 5.0, renamed: "Unicode.UTF16")
// @available(swift, deprecated: 5.0, renamed: "Unicode.UTF16")
public typealias UTF16 = Unicode.UTF16
@available(swift, deprecated: 5.0, renamed: "Unicode.UTF32")
// @available(swift, deprecated: 5.0, renamed: "Unicode.UTF32")
public typealias UTF32 = Unicode.UTF32
@available(swift, obsoleted: 5.0, renamed: "Unicode.Scalar")
// @available(swift, deprecated: 5.0, renamed: "Unicode.Scalar")
public typealias UnicodeScalar = Unicode.Scalar


Expand Down
1 change: 1 addition & 0 deletions stdlib/public/core/Set.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3562,6 +3562,7 @@ extension Set.Index {
#if _runtime(_ObjC)
@usableFromInline
final internal class _CocoaSetIterator: IteratorProtocol {
@usableFromInline
internal typealias Element = AnyObject

// Cocoa Set iterator has to be a class, otherwise we cannot
Expand Down
1 change: 0 additions & 1 deletion stdlib/public/core/String.swift
Original file line number Diff line number Diff line change
Expand Up @@ -744,7 +744,6 @@ extension String {
}

@inlinable
@usableFromInline
static func _fromWellFormedUTF16CodeUnits<C : RandomAccessCollection>(
_ input: C, repair: Bool = false
) -> String where C.Element == UTF16.CodeUnit {
Expand Down