Skip to content
This repository was archived by the owner on Apr 14, 2022. It is now read-only.

Commit 2a91f85

Browse files
author
Mikhail Arkhipov
authored
Fix #470 (#478)
1 parent 865933c commit 2a91f85

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/Analysis/Engine/Impl/PythonAnalyzer.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -596,10 +596,11 @@ internal AnalysisValue GetCached(object key, Func<AnalysisValue> maker) {
596596

597597
internal BuiltinInstanceInfo GetInstance(IPythonType type) => GetBuiltinType(type).Instance;
598598

599-
internal BuiltinClassInfo GetBuiltinType(IPythonType type) =>
600-
(BuiltinClassInfo)GetCached(type,
601-
() => MakeBuiltinType(type)
602-
) ?? ClassInfos[BuiltinTypeId.Object];
599+
internal BuiltinClassInfo GetBuiltinType(IPythonType type)
600+
// Cached value may or may not be a class info. Previous calls to GetAnalysisValueFromObjects
601+
// may have cached a different object for the type. For example, IPythonFunction would cache
602+
// BuiltinFunctionInfo and not BuiltinClassInfo. Therefore, don't use direct cast.
603+
=> GetCached(type, () => MakeBuiltinType(type)) as BuiltinClassInfo ?? MakeBuiltinType(type);
603604

604605
private BuiltinClassInfo MakeBuiltinType(IPythonType type) {
605606
switch (type.TypeId) {

0 commit comments

Comments
 (0)