You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
CS8634 The type 'object?' cannot be used as type parameter 'T' in the generic type or method 'TestClass.DoNothing<T>(T)'. Nullability of type argument 'object?' doesn't match 'class' constraint.
Even trying to be explicit, doesn't remove the error:
This might be a limitation on the DiagnosticSuppressors where we suppress the error generated for the cast, but we don't change the compiler's understanding of what could be null. We don't do a complete flow analysis on notNull
The only option that seems to work is by either using the null suppression operator: object notNull = possibleNull!;
or by doing the nullability conversion in a separate method:
Given the following constructed example:
Result in error:
Even trying to be explicit, doesn't remove the error:
This might be a limitation on the
DiagnosticSuppressors
where we suppress the error generated for the cast, but we don't change the compiler's understanding of what could be null. We don't do a complete flow analysis onnotNull
The only option that seems to work is by either using the null suppression operator:
object notNull = possibleNull!;
or by doing the nullability conversion in a separate method:
The text was updated successfully, but these errors were encountered: