[PY-75831] library cache should work correctly for PsiFiles created specially for completion.

GitOrigin-RevId: 0633366b2caf18a11cb7fb9802351f5db24500fe
This commit is contained in:
Vladimir.Koshelev
2025-08-01 18:49:31 +02:00
committed by intellij-monorepo-bot
parent 57b05ad202
commit 1b662631cf

View File

@@ -52,7 +52,6 @@ public sealed class TypeEvalContext {
protected final Map<PyTypedElement, PyType> myEvaluated = createMap();
protected final Map<PyCallable, PyType> myEvaluatedReturn = createMap();
@ApiStatus.Internal
protected final Map<Pair<PyExpression, Object>, PyType> contextTypeCache = createMap();
/**
* AssumptionContext invariant requires that if type is in the map,
@@ -249,7 +248,12 @@ public sealed class TypeEvalContext {
}
private @NotNull TypeEvalContext getLibraryContext(@NotNull Project project) {
return project.getService(TypeEvalContextCache.class).getLibraryContext(new LibraryTypeEvalContext(getConstraints()));
TypeEvalConstraints constraints = new TypeEvalConstraints(myConstraints.myAllowDataFlow,
myConstraints.myAllowStubToAST,
myConstraints.myAllowCallContext,
// code completion will always have a new PsiFile, use original file instead
myConstraints.myOrigin != null ? myConstraints.myOrigin.getOriginalFile() : null);
return project.getService(TypeEvalContextCache.class).getLibraryContext(new LibraryTypeEvalContext(constraints));
}
/**