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

fix Swift 5 warnings (mostly redundant modifiers) #642

Merged
merged 2 commits into from
Nov 1, 2018

Conversation

weissi
Copy link
Member

@weissi weissi commented Oct 30, 2018

Motivation:

Swift 5 complains on redundant modifiers. For example declaring a
public func inside of a public extension is now a warning. I don't
agree with this but I dislike warnings even more, so...

Modifications:

remove all redundant modifiers that the compiler now warns about such as

swift-nio/Sources/NIOPriorityQueue/PriorityQueue.swift:90:5: warning: 'public' modifier is redundant for property declared in a public extension

Result:

no warnings in Swift 5

@weissi weissi requested a review from Lukasa October 30, 2018 04:43
@weissi weissi changed the title fix Swift 5 warnings (mostly redundant modifiers fix Swift 5 warnings (mostly redundant modifiers) Oct 30, 2018
@weissi weissi added the semver/patch No public API change. label Oct 30, 2018
@weissi
Copy link
Member Author

weissi commented Oct 30, 2018

spurious fail

Fatal error: Posix wrapper adds more than 20% overhead (with wrapper: 0.8413540124893188, without: 0.6541939973831177

@weissi
Copy link
Member Author

weissi commented Oct 30, 2018

@swift-nio-bot test this please

@ianpartridge
Copy link
Contributor

Ugh I hate this warning too. What does it achieve beyond forcing people to put the access modifier doc page in their bookmarks?

Copy link
Contributor

@Lukasa Lukasa left a comment

Choose a reason for hiding this comment

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

Basically looks good, but it'd be nice to fix up some indentation briefly.

@@ -54,7 +54,7 @@ public extension ChannelPipeline {
/// complete.
/// - returns: An `EventLoopFuture` that will fire when the pipeline is configured.
@available(*, deprecated, message: "Please use configureHTTPServerPipeline")
public func addHTTPServerHandlersWithUpgrader(first: Bool = false,
func addHTTPServerHandlersWithUpgrader(first: Bool = false,
upgraders: [HTTPProtocolUpgrader],
_ upgradeCompletionHandler: @escaping (ChannelHandlerContext) -> Void) -> EventLoopFuture<Void> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Mind fixing up the indentation?

Copy link
Member Author

Choose a reason for hiding this comment

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

good catch, thanks!

@@ -93,7 +93,7 @@ public extension ChannelPipeline {
/// failure to parse the HTTP request) by sending 400 errors. Defaults to `false` for
/// backward-compatibility reasons.
/// - returns: An `EventLoopFuture` that will fire when the pipeline is configured.
public func configureHTTPServerPipeline(first: Bool = false,
func configureHTTPServerPipeline(first: Bool = false,
withPipeliningAssistance pipelining: Bool = true,
withServerUpgrade upgrade: HTTPUpgradeConfiguration? = nil,
withErrorHandling errorHandling: Bool = false) -> EventLoopFuture<Void> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Indentation here too please.

Copy link
Member Author

Choose a reason for hiding this comment

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

all done, thanks!

@Lukasa Lukasa added this to the 1.11.0 milestone Oct 30, 2018
Motivation:

Swift 5 complains on redundant modifiers. For example declaring a
`public func` inside of a `public extension` is now a warning. I don't
agree with this but I dislike warnings even more, so...

Modifications:

remove all redundant modifiers that the compiler now warns about such as

    swift-nio/Sources/NIOPriorityQueue/PriorityQueue.swift:90:5: warning: 'public' modifier is redundant for property declared in a public extension

Result:

no warnings in Swift 5
@Lukasa
Copy link
Contributor

Lukasa commented Oct 30, 2018

Seems like you hit a spurious failure again.

@weissi
Copy link
Member Author

weissi commented Oct 30, 2018

@swift-nio-bot test this please

defer {
// fr2's underlying fd must be closed by us.
XCTAssertNoThrow(try fh2.close())
}

XCTAssertEqual(Array("01234".utf8), fr1Bytes)
Copy link
Member

Choose a reason for hiding this comment

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

@weissi any reason why this was moved ?

Copy link
Member Author

Choose a reason for hiding this comment

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

@normanmaurer yes, previously it didn't actually do anything in case of an error thrown. defers are only executed on errors if the defer is syntactically before the error thrown. So generally cleanup-defers need to go straight after the resource creation.

The previous one raised a warning in Swift 5

@Lukasa
Copy link
Contributor

Lukasa commented Oct 31, 2018

@swift-nio-bot test this please

2 similar comments
@weissi
Copy link
Member Author

weissi commented Nov 1, 2018

@swift-nio-bot test this please

@Lukasa
Copy link
Contributor

Lukasa commented Nov 1, 2018

@swift-nio-bot test this please

@Lukasa Lukasa merged commit 26bee21 into apple:master Nov 1, 2018
@weissi weissi deleted the jw-swift5-warnings branch November 1, 2018 17:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver/patch No public API change.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants