Interesting decision about the design

Recently Neela reported down one interesting issue.

Consider a class class1 with following two methods:

public void test(String str)

public void test(String[] str)

Now if user creates object of class1 (say object1) on OTB and then selects method test(String) from the context sensitive menu and enters parameter as 'null' what should we do. In normal cases call like object1.test(null) is going to give compiling error as the call is ambiguous between method test(String) and test(String[]).

But we had two problems to think of.

1. User has specifically selected method and wants method test(String) to be executed with parameter null.

2. From debugger perspective it is just a call like debugger its just a call as test(null)

Hence we should somehow execute method test(String) or should fail the method with the error as ambigous call.

If we would have allowed successful execution of method it would mean to user that method test(String) when passed parameter as null would succeed and he/she would expect the same behaviour when he adds a code like object1.test(null); into the main method. But thats not true. So surely this was going to mislead and confuse user. Hence finally we decided to throw error as ambigous method call. With this now user knows that invocation of test(String) method with null parameter is not correct. (Though user can pass variable str of type String which is null)