File tree Expand file tree Collapse file tree 2 files changed +17
-0
lines changed
Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change 141439 | mutable.Set.empty[String].subtractOne("") // error
1515 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1616 | discarded non-Unit value of type scala.collection.mutable.Set[String]
17+ -- [E172] Potential Issue Error: tests/neg/warn-value-discard.scala:59:4 -----------------------------------------------
18+ 59 | mutable.Set.empty[String] += "" // error
19+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
20+ | discarded non-Unit value of type scala.collection.mutable.Set[String]
Original file line number Diff line number Diff line change @@ -51,3 +51,16 @@ class ValueDiscardTest:
5151 // - receiver is a local variable
5252 // --> No warning
5353 field.subtractOne(" " )
54+
55+ def assignmentOperator (): Unit =
56+ // - += returns this.type
57+ // - receiver is not a field or a local variable
58+ // --> Warning
59+ mutable.Set .empty[String ] += " " // error
60+
61+ def assignmentOperatorLocalVariable (): Unit =
62+ // - += returns this.type
63+ // - receiver is a local variable
64+ // --> No warning
65+ val s : mutable.Set [String ] = mutable.Set .empty[String ]
66+ s += " "
You can’t perform that action at this time.
0 commit comments