Community
Participate
Working Groups
The following test fails that is not intuitive: class TestDispatch { def dispatch method(int value) { "int" } def dispatch method(Object value) { "Object" } @Test def void test() { assertEquals("int", method(1)) // Fails: expected:<[in]t> but was:<[Objec]t> } } The generated code is: public String method(final Object value) { if (value instanceof Integer) { return _method((Integer)value); // 1 } else if (value != null) { return _method(value); // 2 } else { throw new IllegalArgumentException("Unhandled parameter types: " + Arrays.<Object>asList(value).toString()); } } The problem is that at runtime both 1 and 2 dispatches to method(Object), method(int) is never called. This may be a fundamental problem with primitive parameters in dispatch methods: maybe primitives should not be allowed at all, or should be dispatched always statically...
At least a warning would be nice.