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

Invalid cast from BuiltinFunctionInfo to BuiltinClassInfo in GetBuiltinType #470

Closed
@jakebailey

Description

@jakebailey

From #391:

[Error - 5:37:55 PM] System.InvalidCastException: Unable to cast object of type 'Microsoft.PythonTools.Analysis.Values.BuiltinFunctionInfo' to type 'Microsoft.PythonTools.Analysis.Values.BuiltinClassInfo'.
   at Microsoft.PythonTools.Analysis.PythonAnalyzer.GetBuiltinType(IPythonType type)
   at System.Linq.Enumerable.WhereSelectListIterator`2.MoveNext()
   at System.Collections.Generic.List`1.AddEnumerable(IEnumerable`1 enumerable)
   at System.Collections.Generic.List`1.InsertRange(Int32 index, IEnumerable`1 collection)
   at Microsoft.PythonTools.Analysis.Values.Mro..ctor(IEnumerable`1 values)
   at Microsoft.PythonTools.Analysis.Values.BuiltinClassInfo.get_Mro()
   at Microsoft.PythonTools.Analysis.Values.Mro.Recompute()
   at Microsoft.PythonTools.Analysis.Values.ClassInfo.SetBases(IEnumerable`1 bases)
   at Microsoft.PythonTools.Analysis.ClassAnalysisUnit.AnalyzeWorker(DDG ddg, CancellationToken cancel)
   at Microsoft.PythonTools.Analysis.Analyzer.DDG.Analyze(Deque`1 queue, CancellationToken cancel, Action`1 reportQueueSize, Int32 reportQueueInterval)
   at Microsoft.PythonTools.Analysis.PythonAnalyzer.AnalyzeQueuedEntries(CancellationToken cancel)
   at Microsoft.PythonTools.Intellisense.AnalysisQueue.GroupAnalysis.Analyze(CancellationToken cancel)
   at Microsoft.PythonTools.Intellisense.AnalysisQueue.HandleAnalyzable(IAnalyzable item, AnalysisPriority priority, CancellationToken cancellationToken)
   at Microsoft.PythonTools.Intellisense.AnalysisQueue.ConsumerLoop()

#439 changed a bunch of the MRO stuff, and that PR's timing lines up with when @jarshwah saw this.

It seems to me like either:

  • We now add more things to the MRO, which the (older) GetBuiltinType method needs to better handle.
  • The check in GetBuiltinType is correct, and the new code adds things it shouldn't to the MRO.

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions