/// <summary> /// Derive error info from a type symbol. /// </summary> internal bool DeriveUseSiteDiagnosticFromType(ref DiagnosticInfo result, TypeSymbol type) { DiagnosticInfo info = type.GetUseSiteDiagnostic(); if (info != null) { if (info.HasErrorCode(InternalErrorCode.ERR_BogusType)) { switch (this.Kind.Switch()) { case LanguageSymbolKind.Name: case LanguageSymbolKind.Operation: case LanguageSymbolKind.Property: info = new LanguageDiagnosticInfo(InternalErrorCode.ERR_BindToBogus, this); break; } } } return(MergeUseSiteDiagnostics(ref result, info)); }
/// <summary> /// Merges given diagnostic to the existing result diagnostic. /// </summary> internal bool MergeUseSiteDiagnostics(ref DiagnosticInfo result, DiagnosticInfo info) { if (info == null) { return(false); } if (info.Severity == DiagnosticSeverity.Error && (info.HasErrorCode(HighestPriorityUseSiteError) || HighestPriorityUseSiteError == null)) { // this error is final, no other error can override it: result = info; return(true); } if (result == null || result.Severity == DiagnosticSeverity.Warning && info.Severity == DiagnosticSeverity.Error) { // there could be an error of higher-priority result = info; return(false); } // we have a second low-pri error, continue looking for a higher priority one return(false); }