예제 #1
0
 protected bool Equals(InvocableSymbol other)
 {
     return(base.Equals(other) &&
            _parameters.Count == other._parameters.Count &&
            _parameters.Zip(other._parameters, (x, y) => x.Equals(y)).All(x => x) &&
            ReturnType.Equals(other.ReturnType));
 }
예제 #2
0
 protected bool Equals(InvocableSymbol other)
 {
     return base.Equals(other)
            && _parameters.Count == other._parameters.Count
            && _parameters.Zip(other._parameters, (x, y) => x.Equals(y)).All(x => x)
            && ReturnType.Equals(other.ReturnType);
 }
예제 #3
0
        private ImmutableArray<BoundVariableDeclaration> BindParameters(ParameterListSyntax parameterList, Binder invocableBinder, InvocableSymbol invocableSymbol)
        {
            var boundParameters = new List<BoundVariableDeclaration>();
            foreach (var parameterSyntax in parameterList.Parameters)
            {
                var parameterValueType = Bind(parameterSyntax.Type, x => BindType(x, null));
                var parameterDirection = SyntaxFacts.GetParameterDirection(parameterSyntax.Modifiers);

                boundParameters.Add(invocableBinder.Bind(parameterSyntax.Declarator, x => invocableBinder.BindVariableDeclarator(x, parameterValueType.TypeSymbol, (d, t) =>
                    new SourceParameterSymbol(
                        parameterSyntax,
                        invocableSymbol,
                        t,
                        parameterDirection))));
            }

            invocableSymbol.ClearParameters();
            foreach (var parameter in invocableBinder.LocalSymbols.Values.SelectMany(x => x))
                invocableSymbol.AddParameter((ParameterSymbol) parameter);

            return boundParameters.ToImmutableArray();
        }
예제 #4
0
 public static void ReportAmbiguousInvocation(this ICollection<Diagnostic> diagnostics, TextSpan span, InvocableSymbol symbol1, InvocableSymbol symbol2, IReadOnlyList<TypeSymbol> argumentTypes)
 {
     if (argumentTypes.Count > 0)
     {
         var displayTypes = string.Join(@", ", argumentTypes.Select(t => t.ToDisplayName()));
         diagnostics.Report(span, DiagnosticId.AmbiguousInvocation, symbol1, symbol2, displayTypes);
     }
     else
     {
         var message = string.Format(CultureInfo.CurrentCulture, "Invocation is ambiguous between '{0}' and '{1}'.", symbol1, symbol2);
         var diagnostic = new Diagnostic(span, DiagnosticId.AmbiguousInvocation, message);
         diagnostics.Add(diagnostic);
     }
 }