package pck; class BaseMatcher { } class MyMatcher extends BaseMatcher { } class Expectations { public T with(T t) { System.out.println("T"); return null; } public T with(BaseMatcher m) { return null; } public static void main(String[] args) { MyMatcher t = new MyMatcher(); String w = new Expectations().with( t); } }