internal void Bind(Symbol symbol, SourceFileSymbol file) { Debug.Assert(symbol != null); if (_type == null) { var type = (NamedTypeSymbol)symbol.DeclaringCompilation.GetTypeFromTypeRef(_tref); if (type.IsErrorTypeOrNull() || type.SpecialType == SpecialType.System_Object) { symbol.DeclaringCompilation.DeclarationDiagnostics.Add( Location.Create(file.SyntaxTree, _tref.Span.ToTextSpan()), Errors.ErrorCode.ERR_TypeNameCannotBeResolved, _tref.ToString()); type = new MissingMetadataTypeSymbol(_tref.ToString(), 0, false); } // bind arguments if (!TryResolveCtor(type, symbol.DeclaringCompilation, out _ctor, out _ctorArgs) && type.IsValidType()) { symbol.DeclaringCompilation.DeclarationDiagnostics.Add( Location.Create(file.SyntaxTree, _tref.Span.ToTextSpan()), Errors.ErrorCode.ERR_NoMatchingOverload, type.Name + "..ctor"); } // bind named parameters if (type.IsErrorTypeOrNull() || _properties.IsDefaultOrEmpty) { _namedArgs = ImmutableArray <KeyValuePair <string, TypedConstant> > .Empty; } else { var namedArgs = new KeyValuePair <string, TypedConstant> [_properties.Length]; for (int i = 0; i < namedArgs.Length; i++) { var prop = _properties[i]; var member = (Symbol)type.LookupMember <PropertySymbol>(prop.Key.Value) ?? (Symbol)type.LookupMember <FieldSymbol>(prop.Key.Value); if (member != null && TryBindTypedConstant(member.GetTypeOrReturnType(), prop.Value, symbol.DeclaringCompilation, out var arg)) { namedArgs[i] = new KeyValuePair <string, TypedConstant>(prop.Key.Value, arg); } else { throw new InvalidOperationException(); } } _namedArgs = namedArgs.AsImmutable(); } // _type = type; } }