private static PythonFunctionType GetOrCreateFunction(this IDocumentAnalysis analysis, string name) { // We DO want to replace class by function. Consider type() in builtins. // 'type()' in code is a function call, not a type class instantiation. if (!(analysis.GlobalScope.Variables[name]?.Value is PythonFunctionType f)) { f = PythonFunctionType.ForSpecialization(name, analysis.Document); f.AddOverload(new PythonFunctionOverload(name, analysis.Document, _ => LocationInfo.Empty)); analysis.GlobalScope.DeclareVariable(name, f, VariableSource.Declaration, LocationInfo.Empty); } return(f); }
private PythonFunctionType GetOrCreateFunction(string name) { var f = Analysis.GlobalScope.Variables[name]?.Value as PythonFunctionType; // We DO want to replace class by function. Consider type() in builtins. // 'type()' in code is a function call, not a type class instantiation. if (f == null) { f = PythonFunctionType.ForSpecialization(name, this); f.AddOverload(new PythonFunctionOverload(name, this, LocationInfo.Empty)); Analysis.GlobalScope.DeclareVariable(name, f, LocationInfo.Empty); } return(f); }