Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

The unsoundness is more straightforward than that: https://news.ycombinator.com/item?id=13051659

By passing `null`, the compiler doesn't notice that the type constraints are irrational, leading to a violation - to satisfy them, it'd need an Integer superclass which is a subclass of String.

Arguably that's fine, since the null can't be used to do anything - it's perfectly "safe" to insert a `String x = null;` into a `new ArrayList<Integer>().add(x)` for instance, since it's just a null. But writing that code gives you a compiler error since it isn't allowed by the type system - writing the same thing via generics should too, but instead it fails at runtime.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: