public OverloadResolution(ICompilation compilation, ResolveResult[] arguments, string[] argumentNames = null, IType[] typeArguments = null, Conversions conversions = null) { if (compilation == null) { throw new ArgumentNullException("compilation"); } if (arguments == null) { throw new ArgumentNullException("arguments"); } if (argumentNames == null) { argumentNames = new string[arguments.Length]; } else if (argumentNames.Length != arguments.Length) { throw new ArgumentException("argumentsNames.Length must be equal to arguments.Length"); } this.compilation = compilation; this.arguments = arguments; this.argumentNames = argumentNames; // keep explicitlyGivenTypeArguments==null when no type arguments were specified if (typeArguments != null && typeArguments.Length > 0) { this.explicitlyGivenTypeArguments = typeArguments; } this.conversions = conversions ?? Conversions.Get(compilation); this.AllowExpandingParams = true; }
public IEnumerable <IEnumerable <IMethod> > GetEligibleExtensionMethods(bool substituteInferredTypes) { var result = new List <List <IMethod> >(); foreach (var methodGroup in GetExtensionMethods()) { var outputGroup = new List <IMethod>(); foreach (var method in methodGroup) { IType[] inferredTypes; if (CSharpResolver.IsEligibleExtensionMethod( method.Compilation, Conversions.Get(method.Compilation), this.TargetType, method, true, out inferredTypes)) { if (substituteInferredTypes && inferredTypes != null) { outputGroup.Add(new SpecializedMethod(method.DeclaringType, method, inferredTypes)); } else { outputGroup.Add(method); } } } if (outputGroup.Count > 0) { result.Add(outputGroup); } } return(result); }
public TypeInference(ITypeResolveContext context, Conversions conversions = null) { if (context == null) { throw new ArgumentNullException("context"); } this.context = context; this.conversions = conversions ?? Conversions.Get(context); }
public TypeInference(ICompilation compilation) { if (compilation == null) { throw new ArgumentNullException("compilation"); } this.compilation = compilation; this.conversions = Conversions.Get(compilation); }
/// <summary> /// Validates whether the given type argument satisfies the constraints for the given type parameter. /// </summary> /// <param name="typeParameter">The type parameter.</param> /// <param name="typeArgument">The type argument.</param> /// <param name="substitution">The substitution that defines how type parameters are replaced with type arguments. /// The substitution is used to check constraints that depend on other type parameters (or recursively on the same type parameter).</param> /// <returns>True if the constraints are satisfied; false otherwise.</returns> public static bool ValidateConstraints(ITypeParameter typeParameter, IType typeArgument, TypeVisitor substitution) { if (typeParameter == null) { throw new ArgumentNullException("typeParameter"); } if (typeParameter.Owner == null) { throw new ArgumentNullException("typeParameter.Owner"); } if (typeArgument == null) { throw new ArgumentNullException("typeArgument"); } return(ValidateConstraints(typeParameter, typeArgument, substitution, Conversions.Get(typeParameter.Owner.Compilation))); }