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

Commit 645da64

Browse files
committed
when __new__ is called, and return type can't be determined, assume it creates an instance of the class, passed as the first parameter
1 parent 3045ee3 commit 645da64

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/Analysis/Engine/Impl/Values/FunctionInfo.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
using System.Diagnostics;
2020
using System.Linq;
2121
using Microsoft.PythonTools.Analysis.Analyzer;
22+
using Microsoft.PythonTools.Analysis.AnalysisSetDetails;
2223
using Microsoft.PythonTools.Analysis.Infrastructure;
2324
using Microsoft.PythonTools.Interpreter;
2425
using Microsoft.PythonTools.Parsing;
@@ -146,6 +147,11 @@ public override IAnalysisSet Call(Node node, AnalysisUnit unit, IAnalysisSet[] a
146147
CallSite = node
147148
};
148149

150+
// TODO: this should find cls parameter properly
151+
if (res.Count == 0 && args.Length > 0 && Name == "__new__" && args[0] is ClassInfo cls) {
152+
res = new AnalysisSetOneObject(cls.Instance);
153+
}
154+
149155
var r = res.Resolve(unit, context, out _);
150156
return r;
151157
}

0 commit comments

Comments
 (0)