mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-13 15:52:01 +07:00
PY-84356 Fix TypeEvalContext.inOrigin()
(cherry picked from commit f7d40505057b883cf87d96a481129c4347060c0b) GitOrigin-RevId: e94c1c3f7b06075a342b70133db10d316f1efdfe
This commit is contained in:
committed by
intellij-monorepo-bot
parent
eee23c525c
commit
9fa1facd3d
@@ -54,7 +54,7 @@ public sealed class TypeEvalContext {
|
||||
protected final Map<Pair<PyExpression, Object>, PyType> contextTypeCache = CollectionFactory.createConcurrentSoftValueMap();
|
||||
|
||||
private TypeEvalContext(boolean allowDataFlow, boolean allowStubToAST, boolean allowCallContext, @Nullable PsiFile origin) {
|
||||
myConstraints = new TypeEvalConstraints(allowDataFlow, allowStubToAST, allowCallContext, origin);
|
||||
this(new TypeEvalConstraints(allowDataFlow, allowStubToAST, allowCallContext, origin));
|
||||
}
|
||||
|
||||
private TypeEvalContext(@NotNull TypeEvalConstraints constraints) {
|
||||
@@ -353,7 +353,14 @@ public sealed class TypeEvalContext {
|
||||
}
|
||||
|
||||
private boolean inOrigin(@NotNull PsiElement element) {
|
||||
return myConstraints.myOrigin == element.getContainingFile() || myConstraints.myOrigin == getContextFile(element);
|
||||
return isSameVirtualFile(myConstraints.myOrigin, element.getContainingFile()) ||
|
||||
isSameVirtualFile(myConstraints.myOrigin, getContextFile(element));
|
||||
}
|
||||
|
||||
private static boolean isSameVirtualFile(@Nullable PsiFile file1, @Nullable PsiFile file2) {
|
||||
if (file1 == null) return false;
|
||||
if (file2 == null) return false;
|
||||
return file1.getViewProvider().getVirtualFile().equals(file2.getViewProvider().getVirtualFile());
|
||||
}
|
||||
|
||||
private static PsiFile getContextFile(@NotNull PsiElement element) {
|
||||
@@ -466,7 +473,7 @@ public sealed class TypeEvalContext {
|
||||
}
|
||||
}
|
||||
TypeEvalConstraints constraints = getConstraints();
|
||||
return constraints.myOrigin != null && file != constraints.myOrigin && (file instanceof PyFile) &&
|
||||
return constraints.myOrigin != null && !isSameVirtualFile(file, constraints.myOrigin) && (file instanceof PyFile) &&
|
||||
!constraints.myAllowDataFlow && !constraints.myAllowStubToAST && !constraints.myAllowCallContext;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user