From docs the main reason for [AllowNull]
attribute is to apply it to generics, where T?
syntax can't be used. But AllowNull
is not allowed to be specified on generic parameters.
void f<[AllowNull] T>() {} // error
Is there any way to make function like this?
[return: NotNull]
T<TT> HasNoNulls<T, [NotNull] TT>(T<TT?>? val)
UPDATE: I get it why this is not allowed. Because null analysis is tied to data flow it only allowed on variables. How to solve this nested generic problem?
, int>()`