Again with the no conversions. This time in the return statement:
class Foo {
long foo() {
return new Integer(1);
}
}

… is a legal Java program, but generates no conversions on the return argument. I couldn’t find this in the spec, but it seems this requires an AssignmentConversion, like dryad-amb-type-checker already tries to apply..?

Submitted on 29 March 2007 at 12:29

On 29 March 2007 at 14:32 Jira commented:

DRY-250, martin:

Right, the specification states: ( http://java.sun.com/docs/books/jls/third_edition/html/statements.html#14.17 )

“The Expression must denote a variable or value of some type T, or a compile-time error occurs. The type T must be assignable (§5.2) to the declared result type of the method, or a compile-time error occurs.”

So indeed it must be assignable. I think we need to annotate the return statement with the conversion, since we cannot annotate the expression itself (which might already have a conversion)

Log in to post comments