You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/topics/unused-return-value-checker.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -51,7 +51,7 @@ It has the following modes:
51
51
52
52
*`disable` disables the unused return value checker. (Default)
53
53
*`check` enables the checker, and reports warnings for ignored results from [marked functions](#mark-functions-to-check-ignored-results).
54
-
*`full` enables the checker, and treats all functions in your project as [marked](#mark-functions-to-check-ignored-results) and reports warnings for ignored results.
54
+
*`full` enables the checker, treats all functions in your project as [marked](#mark-functions-to-check-ignored-results), and reports warnings for ignored results.
55
55
56
56
> All marked functions are propagated as such, and ignored results are reported if the checker is enabled in projects that use your code as a dependency.
57
57
>
@@ -129,7 +129,7 @@ fun someFunction(): Int = ...
129
129
130
130
## Suppress reports for ignored results
131
131
132
-
You can suppress reports on specific functions by marking them with the [`@IgnorableReturnValue`](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-ignorable-return-value/) annotation.
132
+
You can suppress reports on specific functions by annotating them with [`@IgnorableReturnValue`](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-ignorable-return-value/).
133
133
Annotate functions where ignoring the result is common and expected, such as `MutableList.add`:
134
134
135
135
```kotlin
@@ -139,7 +139,7 @@ fun <T> MutableList<T>.addAndIgnoreResult(element: T): Boolean {
139
139
}
140
140
```
141
141
142
-
You can suppress a warning without marking the function itself.
142
+
You can suppress a warning without annotating the function itself.
143
143
To do this, assign the result to a special unnamed variable with an underscore syntax (`_`):
144
144
145
145
```kotlin
@@ -161,7 +161,7 @@ fun main() {
161
161
When you override a function, the override inherits the reporting rules defined by the annotations on the base declaration.
162
162
This also applies when the base declaration is part of the Kotlin standard library or of other library dependencies, so the checker reports ignored results for overrides of functions like `Any.hashCode()`.
163
163
164
-
Additionally, you can't override a class or interface marked with `@IgnorableReturnValue` with one that [requires its return values to be used](#mark-functions-to-check-ignored-results).
164
+
Additionally, you can't override a function marked with `@IgnorableReturnValue` with one that [requires its return value to be used](#mark-functions-to-check-ignored-results).
165
165
However, you can mark an override with `@IgnorableReturnValue` in a class or interface annotated with `@MustUseReturnValues` when its result can be safely ignored:
0 commit comments