private static ResolveResults SearchInCompanionObjects(string name, IEnumerable<IRppExpr> args, Symbols.SymbolTable scope) { TypeSymbol obj = scope.LookupObject(name); if (obj == null) { return null; } var applyFunctions = obj.Type.Methods.Where(func => func.Name == "apply").ToList(); if (applyFunctions.Count == 0) { throw new Exception("Companion object doesn't have apply() with required signature"); } return new ResolveResults(applyFunctions[0]); }