File tree 2 files changed +17
-0
lines changed 2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change 14
14
39 | mutable.Set.empty[String].subtractOne("") // error
15
15
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
16
16
| 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:
51
51
// - receiver is a local variable
52
52
// --> No warning
53
53
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