"Using 'class' constraint with nullable references:"

static T? ReturnInput<T>(T? t) where T : class => t;

var x = ReturnInput<string>(null); // Compiles absolutely fine, T is 'string' and therefore the parameter type is 'string?'
var y = ReturnInput<int?>(null); // Does not compile: 'int?' is not a reference type (it's an alias for Nullable<T>)
var z = ReturnInput((object?) null); // Compiles absolutely fine, T is inferred to be 'object'


Code snippet taken from "Complete C# Quick Reference - C# 8".