public static MethodSymbol Create(MethodSymbol method)
        {
            Debug.Assert(method.IsExtensionMethod && method.MethodKind != MethodKind.ReducedExtension);

            // The reduced form is always created from the unconstructed method symbol.
            var constructedFrom = method.ConstructedFrom;
            var reducedMethod = new ReducedExtensionMethodSymbol(constructedFrom);

            if (constructedFrom == method)
            {
                return reducedMethod;
            }

            // If the given method is a constructed method, the same type arguments
            // are applied to construct the result from the reduced form.
            Debug.Assert(!method.TypeArguments.IsEmpty);
            return reducedMethod.Construct(method.TypeArguments);
        }
Exemplo n.º 2
0
 /// <summary>
 /// If this is an extension method, returns a reduced extension method
 /// symbol representing the method. Otherwise, returns null.
 /// </summary>
 public MethodSymbol ReduceExtensionMethod()
 {
     return((this.IsExtensionMethod && this.MethodKind != MethodKind.ReducedExtension) ? ReducedExtensionMethodSymbol.Create(this) : null);
 }
 public ReducedExtensionMethodParameterSymbol(ReducedExtensionMethodSymbol containingMethod, ParameterSymbol underlyingParameter) :
     base(underlyingParameter)
 {
     Debug.Assert(underlyingParameter.Ordinal > 0);
     _containingMethod = containingMethod;
 }
 public ReducedExtensionMethodParameterSymbol(ReducedExtensionMethodSymbol containingMethod, ParameterSymbol underlyingParameter) :
     base(underlyingParameter)
 {
     Debug.Assert(underlyingParameter.Ordinal > 0);
     this.containingMethod = containingMethod;
 }