Fix static compilation in some cases of unchecked generics