-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Add the -Wall
option that enables all warnings
#20545
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
-- [E198] Unused Symbol Warning: tests/warn/i18559a.scala:4:28 --------------------------------------------------------- | ||
4 | import collection.mutable.Set // warn | ||
| ^^^ | ||
| unused import | ||
-- [E198] Unused Symbol Warning: tests/warn/i18559a.scala:8:8 ---------------------------------------------------------- | ||
8 | val x = 1 // warn | ||
| ^ | ||
| unused local definition | ||
-- [E198] Unused Symbol Warning: tests/warn/i18559a.scala:11:26 -------------------------------------------------------- | ||
11 | import SomeGivenImports.given // warn | ||
| ^^^^^ | ||
| unused import |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
//> using options -Wall | ||
// This test checks that -Wall turns on -Wunused:all if -Wunused is not set | ||
object FooImportUnused: | ||
import collection.mutable.Set // warn | ||
|
||
object FooUnusedLocal: | ||
def test(): Unit = | ||
val x = 1 // warn | ||
|
||
object FooGivenUnused: | ||
import SomeGivenImports.given // warn | ||
|
||
object SomeGivenImports: | ||
given Int = 0 | ||
given String = "foo" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
-- Warning: tests/warn/i18559b.scala:8:6 ------------------------------------------------------------------------------- | ||
8 | val localFile: String = s"${url.##}.tmp" // warn | ||
| ^ | ||
| Access non-initialized value localFile. Calling trace: | ||
| ├── class RemoteFile(url: String) extends AbstractFile: [ i18559b.scala:7 ] | ||
| │ ^ | ||
| ├── abstract class AbstractFile: [ i18559b.scala:3 ] | ||
| │ ^ | ||
| ├── val extension: String = name.substring(4) [ i18559b.scala:5 ] | ||
| │ ^^^^ | ||
| └── def name: String = localFile [ i18559b.scala:9 ] | ||
| ^^^^^^^^^ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
//> using options -Wall | ||
// This test checks that -Wall turns on -Wsafe-init | ||
abstract class AbstractFile: | ||
def name: String | ||
val extension: String = name.substring(4) | ||
|
||
class RemoteFile(url: String) extends AbstractFile: | ||
val localFile: String = s"${url.##}.tmp" // warn | ||
def name: String = localFile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
-- [E198] Unused Symbol Warning: tests/warn/i18559c.scala:8:8 ---------------------------------------------------------- | ||
8 | val x = 1 // warn | ||
| ^ | ||
| unused local definition |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
//> using options -Wall -Wunused:locals | ||
// This test checks that -Wall leaves -Wunused:... untouched if it is already set | ||
object FooImportUnused: | ||
import collection.mutable.Set // not warn | ||
|
||
object FooUnusedLocal: | ||
def test(): Unit = | ||
val x = 1 // warn | ||
|
||
object FooGivenUnused: | ||
import SomeGivenImports.given // not warn | ||
|
||
object SomeGivenImports: | ||
given Int = 0 | ||
given String = "foo" |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel
overrideWithWall
and all the warning settings are over-engineered. I think a better solution is to create an object which reads all warning settings properly and stores in ctx.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for the suggestion! I'd appreciate some clarification: does the proposed solution mean that we create another object that takes
Wall
into consideration when reading all warning settings and store that object in the context (that object could be similar toWunusedHas
)? Then at all use sites of these warning settings we read from that object instead?