mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-11-28 15:52:12 +07:00
[java-dfa] Revise mutability: MUST_NOT_MODIFY
New level 'MUST_NOT_MODIFY' is introduced for parameters inside pure methods to signal that we should not modify these values, but we don't actually know whether they mutable or not (fixes IDEA-257286). Also, MUST_NOT_MODIFY is dropped inside nested closures, so we don't warn if parameter is modified there. GitOrigin-RevId: f095e72be772eef8324ef2246fb0b7262beae20d
This commit is contained in:
1 parent
9fd48d8c59
commit
49cd49dfa3
7 files changed
+65
-13
No files matched your search
+16
@@ -0,0 +1,16 @@
|
||||
// "Fix all 'Redundant usage of unmodifiable collection wrappers' problems in file" "false"
|
||||
|
||||
import java.util.*;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
|
||||
class Main {
|
||||
|
||||
@Contract(pure = true)
|
||||
public static <T> List<T> unmodifiableOrEmptyList(List<? extends T> original) {
|
||||
int size = original.size();
|
||||
if (size == 0) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return Collections.<caret>unmodifiableList(original);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user