private void BuildParameterSymbols( InvocableSymbol containingSymbol, IEnumerable <IConstructorParameterSyntax> parameters, IEnumerable <DataType> types) { foreach (var(param, type) in parameters.Zip(types)) { switch (param) { default: throw ExhaustiveMatch.Failed(param); case INamedParameterSyntax namedParam: { var symbol = new VariableSymbol(containingSymbol, namedParam.Name, namedParam.DeclarationNumber.Result, namedParam.IsMutableBinding, type); namedParam.Symbol.Fulfill(symbol); symbolTree.Add(symbol); } break; case IFieldParameterSyntax _: // Referenced field already assigned break; } } }
private void BuildSelParameterSymbol( InvocableSymbol containingSymbol, ISelfParameterSyntax param, DataType type) { var symbol = new SelfParameterSymbol(containingSymbol, type); param.Symbol.Fulfill(symbol); symbolTree.Add(symbol); }
protected InvocableDeclaration( CodeFile file, TextSpan span, InvocableSymbol symbol, TextSpan nameSpan, FixedList <IConstructorParameter> parameters, IReachabilityAnnotations reachabilityAnnotations) : base(file, span, symbol, nameSpan) { Symbol = symbol; Parameters = parameters; ReachabilityAnnotations = reachabilityAnnotations; }
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()); }
public static void ReportAmbiguousInvocation(this ICollection <Diagnostic> diagnostics, SourceRange sourceRange, InvocableSymbol symbol1, InvocableSymbol symbol2, IReadOnlyList <TypeSymbol> argumentTypes) { diagnostics.Report(sourceRange, DiagnosticId.AmbiguousInvocation, symbol1, symbol2); }
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); } }