Skip to content

Instantly share code, notes, and snippets.

@lWeRl
Last active May 12, 2018 10:42
Show Gist options
  • Save lWeRl/265fdaf062b9707de462b8dd3c03aa69 to your computer and use it in GitHub Desktop.
Save lWeRl/265fdaf062b9707de462b8dd3c03aa69 to your computer and use it in GitHub Desktop.
GenericHell
import java.util.Collection;
import java.util.Collections;
public class GenHell {
class Model {}
class BillingReserve<T extends Model> {
BillingReserve(Collection<Long> ids) {
}
}
<T extends Model> void makeHell(Collection<T> col) {
Collection<Long> one = Collections.singleton(1L);
new BillingReserve(col); //compile WTF
new BillingReserve<>(col); //non-compile
new BillingReserve<>(one); //compile
new BillingReserve<Model>(col); //non-compile
new BillingReserve<Model>(one); //compile model not needed
new BillingReserve<T>(col); //non-compile
new BillingReserve<T>(one); //compile
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment