import java.util.List; class Repro { // signatures from org.hamcrest, ExactlyOneOf is custom interface Matcher { } public static Matcher> hasItem(T item) { return null; } @SafeVarargs public static Matcher> contains(E... items) { return null; } class ExactlyOneOf implements Matcher { } @SafeVarargs public static ExactlyOneOf exactlyOneOf(Matcher... matchers) { return null; } void repro() { Matcher> matcher = exactlyOneOf( // not red or yellow hasItem("hello"), hasItem("world"), contains("a", "b") ); } }