Skip to content

Commit bf0d3f6

Browse files
Mikhail ArkhipovAlexanderSher
Mikhail Arkhipov
authored andcommitted
1 parent 4d7e953 commit bf0d3f6

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
@@ -586,10 +586,11 @@ internal AnalysisValue GetCached(object key, Func<AnalysisValue> maker) {
586586

587587
internal BuiltinInstanceInfo GetInstance(IPythonType type) => GetBuiltinType(type).Instance;
588588

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

594595
private BuiltinClassInfo MakeBuiltinType(IPythonType type) {
595596
switch (type.TypeId) {

0 commit comments

Comments
 (0)