-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Generalize warnings for top-level calls to Any or AnyRef methods (#20312
) 751cc2f is a more direct way to fix #17493 than #20301. 7a9102a further generalizes `checkAnyRefMethodCall`, as suggested by @odersky.
- Loading branch information
Showing
5 changed files
with
48 additions
and
15 deletions.
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
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,11 @@ | ||
-- [E181] Potential Issue Warning: tests/warn/i17493.scala:4:10 -------------------------------------------------------- | ||
4 | def g = synchronized { println("hello, world") } // warn | ||
| ^^^^^^^^^^^^ | ||
| Suspicious top-level unqualified call to synchronized | ||
|--------------------------------------------------------------------------------------------------------------------- | ||
| Explanation (enabled by `-explain`) | ||
|- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||
| Top-level unqualified calls to AnyRef or Any methods such as synchronized are | ||
| resolved to calls on Predef or on imported methods. This might not be what | ||
| you intended. | ||
--------------------------------------------------------------------------------------------------------------------- |
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,5 @@ | ||
//> using options -explain | ||
class A(val s: String) extends AnyVal { | ||
// def f = eq("hello, world") // no warning for now because `eq` is inlined | ||
def g = synchronized { println("hello, world") } // warn | ||
} |