private OverloadResolutionResult <FunctionSymbolSignature> LookupFunction(SyntaxToken name, ImmutableArray <Type> argumentTypes) { var signatures = from f in LookupSymbols <FunctionSymbol>(name) where name.Matches(f.Name) select new FunctionSymbolSignature(f); return(OverloadResolution.Perform(signatures, argumentTypes)); }
private OverloadResolutionResult <MethodSymbolSignature> LookupMethod(Type type, SyntaxToken name, ImmutableArray <Type> argumentTypes) { if (name == null) { throw new ArgumentNullException(nameof(name)); } var signatures = from m in LookupMethod(type, name) select new MethodSymbolSignature(m); return(OverloadResolution.Perform(signatures, argumentTypes)); }
internal static OverloadResolutionResult <UnaryOperatorSignature> Resolve(UnaryOperatorKind kind, Type type) { var builtInSignatures = GetBuiltInSignatures(kind); // If the type is built-in, we can simply perform the overload resolution // against the built-in signatures only. if (TypeBuiltIn(type)) { return(OverloadResolution.Perform(builtInSignatures, type)); } // Otherwise, we need to consider user defined signatures. // // NOTE: We generally want to perform an overload resolution against the unified // set of both, built-in signatures as well as user defined signatures. // However, if the type provides an operator that is applicable, we want to // to hide the built-in operators. In other words, in those cases the user // defined operators shadows the built-in operators. // Please note that we don't ask whether the overload resolution found a // best match -- we just check if it has an applicable operator. This makes // sure that any any ambiguity errors will not include built-in operators // in the output. var userDefinedSignatures = GetUserDefinedSignatures(kind, type); if (userDefinedSignatures.Any()) { var userDefinedResult = OverloadResolution.Perform(userDefinedSignatures, type); if (userDefinedResult.Candidates.Any(c => c.IsApplicable)) { return(userDefinedResult); } } var signatures = builtInSignatures.Concat(userDefinedSignatures); return(OverloadResolution.Perform(signatures, type)); }