C# Class ICSharpCode.NRefactory.CSharp.Resolver.OverloadResolution

C# overload resolution (C# 4.0 spec: ยง7.5).
Show file Open project: 0xd4d/NRefactory Class Usage Examples

Public Methods

Method Description
AddCandidate ( IParameterizedMember member ) : OverloadResolutionErrors

Adds a candidate to overload resolution.

AddCandidate ( IParameterizedMember member, OverloadResolutionErrors additionalErrors ) : OverloadResolutionErrors

Adds a candidate to overload resolution.

AddMethodLists ( IList methodLists ) : void

Adds all candidates from the method lists. This method implements the logic that causes applicable methods in derived types to hide all methods in base types.

CreateResolveResult ( ResolveResult targetResolveResult, IList initializerStatements = null, IType returnTypeOverride = null ) : ICSharpCode.NRefactory.CSharp.Resolver.CSharpInvocationResolveResult

Creates a ResolveResult representing the result of overload resolution.

GetArgumentToParameterMap ( ) : IList

Gets an array that maps argument indices to parameter indices. For arguments that could not be mapped to any parameter, the value will be -1. parameterIndex = GetArgumentToParameterMap()[argumentIndex]

GetArgumentsWithConversions ( ) : IList

Returns the arguments for the method call in the order they were provided (not in the order of the parameters). Arguments are wrapped in a ConversionResolveResult if an implicit conversion is being applied to them when calling the method.

GetArgumentsWithConversionsAndNames ( ) : IList

Returns the arguments for the method call in the order they were provided (not in the order of the parameters). Arguments are wrapped in a ConversionResolveResult if an implicit conversion is being applied to them when calling the method. For arguments where an explicit argument name was provided, the argument will be wrapped in a NamedArgumentResolveResult.

GetBestCandidateWithSubstitutedTypeArguments ( ) : IParameterizedMember
IsApplicable ( OverloadResolutionErrors errors ) : bool

Returns whether a candidate with the given errors is still considered to be applicable.

OverloadResolution ( ICompilation compilation, ResolveResult arguments, string argumentNames = null, IType typeArguments = null, CSharpConversions conversions = null ) : System
ValidateConstraints ( ITypeParameter typeParameter, IType typeArgument, ICSharpCode.NRefactory.TypeSystem.TypeVisitor substitution = null ) : bool

Validates whether the given type argument satisfies the constraints for the given type parameter.

Private Methods

Method Description
BetterFunctionMember ( Candidate c1, Candidate c2 ) : int

Returns 1 if c1 is better than c2; 2 if c2 is better than c1; or 0 if neither is better.

CalculateCandidate ( Candidate candidate ) : bool

Calculates applicability etc. for the candidate.

CheckApplicability ( Candidate candidate ) : void
ConsiderIfNewCandidateIsBest ( Candidate candidate ) : void
GetArgumentsWithConversions ( ResolveResult targetResolveResult, IParameterizedMember bestCandidateForNamedArguments ) : IList
GetSubstitution ( Candidate candidate ) : TypeParameterSubstitution
LogCandidateAddingResult ( string text, IParameterizedMember method, OverloadResolutionErrors errors ) : void
MapCorrespondingParameters ( Candidate candidate ) : void
MoreSpecificFormalParameter ( IType t1, IType t2 ) : int
MoreSpecificFormalParameters ( Candidate c1, Candidate c2 ) : int
MoreSpecificFormalParameters ( IEnumerable t1, IEnumerable t2 ) : int
ResolveParameterTypes ( Candidate candidate, bool useSpecializedParameters ) : bool
RunTypeInference ( Candidate candidate ) : void
ValidateConstraints ( ITypeParameter typeParameter, IType typeArgument, ICSharpCode.NRefactory.TypeSystem.TypeVisitor substitution, CSharpConversions conversions ) : bool
ValidateMethodConstraints ( Candidate candidate ) : OverloadResolutionErrors

Method Details

AddCandidate() public method

Adds a candidate to overload resolution.
public AddCandidate ( IParameterizedMember member ) : OverloadResolutionErrors
member IParameterizedMember The candidate member to add.
return OverloadResolutionErrors

AddCandidate() public method

Adds a candidate to overload resolution.
public AddCandidate ( IParameterizedMember member, OverloadResolutionErrors additionalErrors ) : OverloadResolutionErrors
member IParameterizedMember The candidate member to add.
additionalErrors OverloadResolutionErrors Additional errors that apply to the candidate. /// This is used to represent errors during member lookup (e.g. OverloadResolutionErrors.Inaccessible) /// in overload resolution.
return OverloadResolutionErrors

AddMethodLists() public method

Adds all candidates from the method lists. This method implements the logic that causes applicable methods in derived types to hide all methods in base types.
public AddMethodLists ( IList methodLists ) : void
methodLists IList The methods, grouped by declaring type. Base types must come first in the list.
return void

CreateResolveResult() public method

Creates a ResolveResult representing the result of overload resolution.
public CreateResolveResult ( ResolveResult targetResolveResult, IList initializerStatements = null, IType returnTypeOverride = null ) : ICSharpCode.NRefactory.CSharp.Resolver.CSharpInvocationResolveResult
targetResolveResult ResolveResult /// The target expression of the call. May be null for static methods/constructors. ///
initializerStatements IList /// Statements for Objects/Collections initializer. /// /// /// If not null, use this instead of the ReturnType of the member as the type of the created resolve result. ///
returnTypeOverride IType
return ICSharpCode.NRefactory.CSharp.Resolver.CSharpInvocationResolveResult

GetArgumentToParameterMap() public method

Gets an array that maps argument indices to parameter indices. For arguments that could not be mapped to any parameter, the value will be -1. parameterIndex = GetArgumentToParameterMap()[argumentIndex]
public GetArgumentToParameterMap ( ) : IList
return IList

GetArgumentsWithConversions() public method

Returns the arguments for the method call in the order they were provided (not in the order of the parameters). Arguments are wrapped in a ConversionResolveResult if an implicit conversion is being applied to them when calling the method.
public GetArgumentsWithConversions ( ) : IList
return IList

GetArgumentsWithConversionsAndNames() public method

Returns the arguments for the method call in the order they were provided (not in the order of the parameters). Arguments are wrapped in a ConversionResolveResult if an implicit conversion is being applied to them when calling the method. For arguments where an explicit argument name was provided, the argument will be wrapped in a NamedArgumentResolveResult.
public GetArgumentsWithConversionsAndNames ( ) : IList
return IList

GetBestCandidateWithSubstitutedTypeArguments() public method

public GetBestCandidateWithSubstitutedTypeArguments ( ) : IParameterizedMember
return IParameterizedMember

IsApplicable() public static method

Returns whether a candidate with the given errors is still considered to be applicable.
public static IsApplicable ( OverloadResolutionErrors errors ) : bool
errors OverloadResolutionErrors
return bool

OverloadResolution() public method

public OverloadResolution ( ICompilation compilation, ResolveResult arguments, string argumentNames = null, IType typeArguments = null, CSharpConversions conversions = null ) : System
compilation ICompilation
arguments ResolveResult
argumentNames string
typeArguments IType
conversions CSharpConversions
return System

ValidateConstraints() public static method

Validates whether the given type argument satisfies the constraints for the given type parameter.
public static ValidateConstraints ( ITypeParameter typeParameter, IType typeArgument, ICSharpCode.NRefactory.TypeSystem.TypeVisitor substitution = null ) : bool
typeParameter ITypeParameter The type parameter.
typeArgument IType The type argument.
substitution ICSharpCode.NRefactory.TypeSystem.TypeVisitor 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). /// May be null if no substitution should be used.
return bool