No conversion is added for assignments of ‘null’. Since null is a subtype of every reference type, I think this should be a WideningReferenceConversion. It’s kinda hard to list all possible widening-reference-conversions, though that is what the strategy with that name is supposed to do… Needs some refactoring, I guess.

For example this doesn’t generate a conversion:
class Foo {{
String s = null;
s = null;
}}

(Additionally, since the conversion strategy fails, in the above example the assignment is also left without a Type attribute.)

This also means we can’t call methods with null arguments when relying on method invocation conversions:
class Foo {
void foo(Object o, Integer l) {
foo(null, 2);
}
}

Submitted on 29 March 2007 at 12:29

On 29 March 2007 at 14:44 Jira commented:

DRY-248, martin:

Hm, yes, indeed this thing needs refactoring. Unfortunately, there are more cases where all conversions or supertypes cannot be listed (see for example the hack of is-subtype, which has a special case for null). Maybe we need such a special case of widening reference conversions as well. We need to look into this in some more detail to figure out what the right solution is.

This is a major issues (null method invocations don’t work)

Log in to post comments