4 ms·
something like final Foo foo; try { foo = bar(baz); Integer a = null; int b = a; } catch ... (though that's less the assignment,
by dzaima 4y ago
something like
final Foo foo;
try {
foo = bar(baz);
Integer a = null;
int b = a;
} catch ...
(though that's less the assignment, more implicit behavior; point being, you've got quite the restrictive environment after "foo =")
- vbezhenar 4y agoAccepting that kind of code probably is too much to ask. But accepting original example should be do-able with pretty simple AST pattern matching.
- dzaima 4y agoRight. Not saying that it'd be hard to support the original code, but more that it's just an extremely weird case to have. As in, I'd say that adding "foo = try { bar(baz) } catch (SomeException ex) { SOME_DEFAULT }", even though that requires adding the ability for blocks to "return" a value, would be a more sensible change to aid the problem at hand. Were the original to be allowed, it be the first case where adding a System.out.println(); statement into code {}s results in an error. (ok, second case, the first being adding it before a super()/this() in a constructor. But hey look what post we're on!)