mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Fixed PIEAE caused by PyBuiltinCache.getStdlibType() (EA-37595)
This commit is contained in:
@@ -318,8 +318,7 @@ public class PyBuiltinCache {
|
||||
synchronized (myStdlibTypeCache) {
|
||||
final Ref<PyType> ref = myStdlibTypeCache.get(key);
|
||||
if (ref != null) {
|
||||
final PyType pyType = ref.get();
|
||||
if (pyType instanceof PyClassType && !((PyClassType)pyType).isValid()) {
|
||||
if (!isValid(ref.get())) {
|
||||
myStdlibTypeCache.clear();
|
||||
return null;
|
||||
}
|
||||
@@ -328,6 +327,31 @@ public class PyBuiltinCache {
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isValid(@Nullable PyType type) {
|
||||
if (type instanceof PyCollectionType) {
|
||||
final PyType elementType = ((PyCollectionType)type).getElementType(TypeEvalContext.fastStubOnly(null));
|
||||
if (!isValid(elementType)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (type instanceof PyClassType) {
|
||||
return ((PyClassType)type).isValid();
|
||||
}
|
||||
else if (type instanceof PyUnionType) {
|
||||
for (PyType member : ((PyUnionType)type).getMembers()) {
|
||||
if (!isValid(member)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else if (type instanceof PyFunctionType) {
|
||||
return ((PyFunctionType)type).getFunction().isValid();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void storeStdlibType(@NotNull String key, @Nullable PyType result) {
|
||||
synchronized (myStdlibTypeCache) {
|
||||
myStdlibTypeCache.put(key, new Ref<PyType>(result));
|
||||
|
||||
Reference in New Issue
Block a user