diff --git a/python/src/com/jetbrains/python/codeInsight/stdlib/PyStdlibCanonicalPathProvider.java b/python/src/com/jetbrains/python/codeInsight/stdlib/PyStdlibCanonicalPathProvider.java index 7ea5d66d6498..55bf2713fe84 100644 --- a/python/src/com/jetbrains/python/codeInsight/stdlib/PyStdlibCanonicalPathProvider.java +++ b/python/src/com/jetbrains/python/codeInsight/stdlib/PyStdlibCanonicalPathProvider.java @@ -36,7 +36,7 @@ public class PyStdlibCanonicalPathProvider implements PyCanonicalPathProvider { public static QualifiedName restoreStdlibCanonicalPath(QualifiedName qName) { if (qName.getComponentCount() > 0) { - final List components = qName.getComponents(); + final List components = new ArrayList<>(qName.getComponents()); final String head = components.get(0); if (head.equals("_abcoll") || head.equals("_collections") || head.equals("_collections_abc")) { components.set(0, "collections"); diff --git a/python/src/com/jetbrains/python/psi/resolve/PythonPathCache.java b/python/src/com/jetbrains/python/psi/resolve/PythonPathCache.java index fe55f0b65aa5..e6ac00179580 100644 --- a/python/src/com/jetbrains/python/psi/resolve/PythonPathCache.java +++ b/python/src/com/jetbrains/python/psi/resolve/PythonPathCache.java @@ -24,6 +24,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import java.util.Map; @@ -53,7 +54,7 @@ public abstract class PythonPathCache { // At least one element is invalid return null; } - return elements; + return elements != null ? Collections.unmodifiableList(elements) : null; } public void put(QualifiedName qualifiedName, List results) { @@ -67,7 +68,8 @@ public abstract class PythonPathCache { if (vFile == null) { return null; } - return myQNameCache.get(vFile.getUrl()); + final List names = myQNameCache.get(vFile.getUrl()); + return names != null ? Collections.unmodifiableList(names) : null; } public void putNames(VirtualFile vFile, List qNames) {