protected override DiagnosticInfo?ResolveInfo() { if (_possiblyNullableTypeSymbol.IsNullableType()) { return(_possiblyNullableTypeSymbol.Type.OriginalDefinition.GetUseSiteInfo().DiagnosticInfo); } return(Binder.GetNullableUnconstrainedTypeParameterDiagnosticIfNecessary(_languageVersion, _possiblyNullableTypeSymbol)); }
protected override DiagnosticInfo ResolveInfo() { if (_possiblyNullableTypeSymbol.IsNullableType()) { return(_possiblyNullableTypeSymbol.Type.OriginalDefinition.GetUseSiteDiagnostic()); } else if (_possiblyNullableTypeSymbol.Type.IsTypeParameterDisallowingAnnotation()) { return(new CSDiagnosticInfo(ErrorCode.ERR_NullableUnconstrainedTypeParameter)); } return(null); }
private bool ShouldAddNullableAnnotation(TypeWithAnnotations typeOpt) { if (!typeOpt.HasType) { return(false); } else if (format.MiscellaneousOptions.IncludesOption(SymbolDisplayMiscellaneousOptions.IncludeNullableReferenceTypeModifier) && !typeOpt.IsNullableType() && !typeOpt.Type.IsValueType && typeOpt.NullableAnnotation.IsAnnotated()) { return(true); } else if (format.CompilerInternalOptions.IncludesOption(SymbolDisplayCompilerInternalOptions.IncludeNonNullableTypeModifier) && !typeOpt.Type.IsValueType && typeOpt.NullableAnnotation.IsNotAnnotated() && !typeOpt.Type.IsTypeParameterDisallowingAnnotation()) { return(true); } return(false); }