Forgive me if this was already suggested, but assuming [] will always produce a list, couldn't the compile-time checking be enabled for a static cast? Set<Integer> = (Set<>)[1, 2, 3]; // OK Set<Integer> = (Set<>)[1, 2, 1]; // Error Paul