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

Description

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 Josh Smeaton (@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.

Activity

  1. MikhailArkhipov commented on Dec 10, 2018

    @MikhailArkhipov

    Looks like function somehow leaked into SetBases. MRO should technically only contain classes so the direct cast fails.

  2. added a commit that references this issue on Dec 10, 2018
    2a91f85
  3. added 2 commits that reference this issue on Feb 4, 2019
    bf0d3f6
    a5b6e5e
  4. added 5 commits that reference this issue on Feb 10, 2019
    d25e0dd
    037d248
    75e14ab
    0b458d6
    4afc1ef
  5. added 2 commits that reference this issue on Feb 18, 2019
    82f57d7
    7707351
  6. added 7 commits that reference this issue on Nov 1, 2019
    e534eae
    fe76c4c
    f3b34e3
    dbfc6e6
    050eb34
    a1b75b5
    210beec
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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