Skip to content
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

update tools-version to 5.0 & fix latest warnings #704

Merged
merged 1 commit into from Dec 14, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion Package.swift
@@ -1,4 +1,4 @@
// swift-tools-version:4.2
// swift-tools-version:5.0
//===----------------------------------------------------------------------===//
//
// This source file is part of the SwiftNIO open source project
Expand Down
8 changes: 4 additions & 4 deletions Sources/NIO/ByteBuffer-core.swift
Expand Up @@ -238,10 +238,10 @@ public struct ByteBuffer {
public typealias _Index = UInt32
public typealias _Capacity = UInt32

@usableFromInline private(set) var _storage: _Storage
@usableFromInline private(set) var _readerIndex: _Index = 0
@usableFromInline private(set) var _writerIndex: _Index = 0
@usableFromInline private(set) var _slice: Slice
Copy link
Contributor

Choose a reason for hiding this comment

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

Why did all of these go away?

Copy link
Member Author

Choose a reason for hiding this comment

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

@Lukasa they don't make sense: private + @usableFromInline doesn't work. They should all be private but we need them underscored. If you don't change it, new Swift 5 will warn.

@usableFromInline var _storage: _Storage
@usableFromInline var _readerIndex: _Index = 0
@usableFromInline var _writerIndex: _Index = 0
@usableFromInline var _slice: Slice

// MARK: Internal _Storage for CoW
@usableFromInline final class _Storage {
Expand Down
4 changes: 2 additions & 2 deletions Sources/NIO/HappyEyeballs.swift
Expand Up @@ -27,7 +27,7 @@

private extension Array where Element == EventLoopFuture<Channel> {
mutating func remove(element: Element) {
guard let channelIndex = index(where: { $0 === element }) else {
guard let channelIndex = self.firstIndex(where: { $0 === element }) else {
return
}

Expand Down Expand Up @@ -553,7 +553,7 @@ internal class HappyEyeballsConnector {
// The connection attempt failed. If we're in the complete state then there's nothing
// to do. Otherwise, notify the state machine of the failure.
if case .complete = self.state {
assert(self.pendingConnections.index { $0 === channelFuture } == nil, "failed but was still in pending connections")
assert(self.pendingConnections.firstIndex { $0 === channelFuture } == nil, "failed but was still in pending connections")
} else {
self.error.connectionErrors.append(SingleConnectionFailure(target: target, error: err))
self.pendingConnections.remove(element: channelFuture)
Expand Down
2 changes: 1 addition & 1 deletion Sources/NIO/Heap.swift
Expand Up @@ -130,7 +130,7 @@ internal struct Heap<T: Comparable> {

@discardableResult
public mutating func remove(value: T) -> Bool {
if let idx = self.storage.index(of: value) {
if let idx = self.storage.firstIndex(of: value) {
self.remove(index: idx)
return true
} else {
Expand Down
2 changes: 1 addition & 1 deletion Tests/NIOHTTP1Tests/HTTPUpgradeTests.swift
Expand Up @@ -151,7 +151,7 @@ internal func assertResponseIs(response: String, expectedResponseLine: String, e

// For each header, find it in the actual response headers and remove it.
for expectedHeader in expectedResponseHeaders {
guard let index = lines.index(of: expectedHeader) else {
guard let index = lines.firstIndex(of: expectedHeader) else {
XCTFail("Could not find header \"\(expectedHeader)\"")
return
}
Expand Down
14 changes: 7 additions & 7 deletions Tests/NIOTests/ChannelPipelineTest.swift
Expand Up @@ -124,19 +124,19 @@ class ChannelPipelineTest: XCTestCase {

func testConnectingDoesntCallBind() throws {
let channel = EmbeddedChannel()
defer {
XCTAssertFalse(try channel.finish())
}
var ipv4SocketAddress = sockaddr_in()
ipv4SocketAddress.sin_port = (12345 as in_port_t).bigEndian
let sa = SocketAddress(ipv4SocketAddress, host: "foobar.com")

_ = try channel.pipeline.add(handler: NoBindAllowed()).wait()
_ = try channel.pipeline.add(handler: TestChannelOutboundHandler<ByteBuffer, ByteBuffer> { data in
XCTAssertNoThrow(try channel.pipeline.add(handler: NoBindAllowed()).wait())
XCTAssertNoThrow(try channel.pipeline.add(handler: TestChannelOutboundHandler<ByteBuffer, ByteBuffer> { data in
data
}).wait()
}).wait())

_ = try channel.connect(to: sa).wait()
defer {
XCTAssertFalse(try channel.finish())
}
XCTAssertNoThrow(try channel.connect(to: sa).wait())
}

private final class TestChannelOutboundHandler<In, Out>: ChannelOutboundHandler {
Expand Down
2 changes: 1 addition & 1 deletion Tests/NIOTests/HappyEyeballsTest.swift
Expand Up @@ -1114,7 +1114,7 @@ public class HappyEyeballsTest : XCTestCase {
ourChannelFutures[2].fail(error: DummyError())

// Verify that the first channel is the one listed as connected.
XCTAssertTrue((try? ourChannelFutures.first!.futureResult.wait()) === (try? channelFuture.wait()))
XCTAssertTrue((try ourChannelFutures.first!.futureResult.wait()) === (try channelFuture.wait()))
}

func testChannelCreationFails() throws {
Expand Down
2 changes: 1 addition & 1 deletion Tests/NIOWebSocketTests/EndToEndTests.swift
Expand Up @@ -81,7 +81,7 @@ private func assertResponseIs(response: String, expectedResponseLine: String, ex

// For each header, find it in the actual response headers and remove it.
for expectedHeader in expectedResponseHeaders {
guard let index = lines.index(of: expectedHeader) else {
guard let index = lines.firstIndex(of: expectedHeader) else {
XCTFail("Could not find header \"\(expectedHeader)\"")
return
}
Expand Down