-
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.
Warn when calling synchronized on AnyVal
Co-Authored-By: James You <[email protected]> Co-Authored-By: diogocanut <[email protected]> Co-Authored-By: Nicolas Stucki <[email protected]>
- Loading branch information
1 parent
ed319e8
commit d38d6d4
Showing
7 changed files
with
69 additions
and
1 deletion.
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,30 @@ | ||
-- [E187] Potential Issue Error: tests/neg/17284.scala:4:6 ------------------------------------------------------------- | ||
4 | 451.synchronized {} // error | ||
| ^^^^^^^^^^^^^^^^ | ||
| Suspicious synchronized call on boxed class | ||
|--------------------------------------------------------------------------------------------------------------------- | ||
| Explanation (enabled by `-explain`) | ||
|- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||
| You called the synchronized method on a boxed primitive. This might not be what | ||
| you intended. | ||
--------------------------------------------------------------------------------------------------------------------- | ||
-- [E187] Potential Issue Error: tests/neg/17284.scala:8:4 ------------------------------------------------------------- | ||
8 | x.synchronized {} // error | ||
| ^^^^^^^^^^^^^^ | ||
| Suspicious synchronized call on boxed class | ||
|--------------------------------------------------------------------------------------------------------------------- | ||
| Explanation (enabled by `-explain`) | ||
|- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||
| You called the synchronized method on a boxed primitive. This might not be what | ||
| you intended. | ||
--------------------------------------------------------------------------------------------------------------------- | ||
-- [E187] Potential Issue Error: tests/neg/17284.scala:11:7 ------------------------------------------------------------ | ||
11 | true.synchronized {} // error | ||
| ^^^^^^^^^^^^^^^^^ | ||
| Suspicious synchronized call on boxed class | ||
|-------------------------------------------------------------------------------------------------------------------- | ||
| Explanation (enabled by `-explain`) | ||
|- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||
| You called the synchronized method on a boxed primitive. 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,14 @@ | ||
// scalac: -Werror -explain | ||
|
||
def test = | ||
451.synchronized {} // error | ||
|
||
def test2 = | ||
val x: Integer = 451 | ||
x.synchronized {} // error | ||
|
||
def test3 = | ||
true.synchronized {} // error | ||
|
||
def test4 = | ||
true.hashCode() // success |
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