Better restriction check for generic types