-
Notifications
You must be signed in to change notification settings - Fork 28.5k
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
Resolve sbt warnings during build #1069
Conversation
Merged build triggered. |
Merged build started. |
Merged build finished. All automated tests passed. |
All automated tests passed. |
The changes you are removing were put in place to resolve warnings from Scala 2.10. IIRC the code does not even compile without these in Scala 2.11. What is this resolving? |
@srowen If we use @pwendell #1032 remove duplicate |
Yes, but then what warnings is this resolving? I understand one compiler flag is shorter than imports. I also understand that these language features are considered errors in Scala 2.11, instead of warnings. It seems like they are kind of discouraged or at least something that has to be explicitly enabled by the developer. Rather than globally reverse this, it seemed better (although more verbose) to only enable them where needed, and then perhaps consider later whether the code should be using these constructs. It also means you don't require special compiler flags to get the source to compile. |
It resolves the following warning, which occurs in different (but easy-to-reach) contexts depending on whether you are running with the [WARNING] your/source/File.scala:42: warning: postfix operator foo should be enabled
[WARNING] by making the implicit value scala.language.postfixOps visible.
[WARNING] This can be achieved by adding the import clause 'import scala.language.postfixOps'
[WARNING] or by setting the compiler option -language:postfixOps.
[WARNING] See the Scala docs for value scala.language.postfixOps for a discussion
[WARNING] why the feature should be explicitly enabled. (aforementioned scaladoc) Like other features in SIP-18, postfix operators (spec 6.1.2) are modularized. This SO answer gives a hint at why : in some cases, it adds some parser ambiguity which is not always obvious to resolve without some experience with the issue. The choice of whether to add the flag globally or piecewise is mostly a maintainability issue : if people editing the code base are expected to be able to handle the potential parser errors fired when editing with this option turned on, it may make more sense to leave it on globally. |
Yes, I understand that, but these warnings are already suppressed with imports, and the advertised change here is to resolve warnings. It just exchanges mechanisms for suppressing the warning/error. I myself think it's best to not enable it globally. |
Fair enough. I just meant to provide context. Note that this commit has already added postfixOps to the |
I'm more concerned with consistency than anything. We shouldn't do it both ways, and I don't think that compiler arg should have been added. A compiler flag is not a bad solution per se though. Whatever the majority opinion is on which way to handle this, let's make sure it's consistent, via this or another PR. |
Can one of you give me a tl;dr on the verdict about this one? :) |
@rxin It looks like Scala is requiring developers to be more explicit about intention to use these features; these warnings become errors in Scala 2.11 actually. So my opinion is that use of the feature should not be enabled globally with a compiler flag, but enabled per compilation unit with an import. The latter is the currently how the codebase works. Since this PR just swaps the latter for former, I personally would argue that this not be merged. Actually, an earlier PR also add the compiler flag though. I think it should be removed and any extra warnings fixed. If there is any support for that, and no objections, I can raise a PR for that. |
Thanks for summarizing that. I agree that we should not have a global flag that just disables certain warnings, since that could hide potential problems in the future. |
@srowen If so, I close the PR and I will submit a new PR meets you said. |
@witgo Go ahead. Right now I actually don't see any warnings appear when the compiler flag is removed, so it looks like all other warnings are suppressed locally already. So it can just be removed. |
No description provided.