Not every T can be nil, so you are confusing the compiler. An internal error should not happen anyway, but what if you use the generics restrictions, like <T:class>?
You are making assumptions about the type of T and that is a programmer mistake.
Report the error, though, if it was not already reported.
(A class can be nil, but e.g. an integer can't)
You are basically half-way and you are aware of that issue.