[BLUEJ-558] Codepad inconsistently complains about code
I entered this code into the codepad:
{noformat} java.util.Optional.ofNullable(null).isPresent() {noformat}
It told me it expected a semi-colon. This gave same error:
{noformat} import java.util*; Optional.ofNullable(null).isPresent() {noformat}
This, however, was fine:
{noformat} boolean b = Optional.ofNullable(null).isPresent(); b {noformat}
I think it's to do with the types. If I cast the null in the first case, it works:
{noformat} java.util.Optional.ofNullable((String)null).isPresent() {noformat}
But I don't immediately see why the assignment should work without error, and yet the expression fails. Is it because we count a type warning in the first case as a reason to fail the compile, but in the assignment it gets ignored because we're confident it's a statement?
Issue metadata
- Issue type: Bug
- Priority: Lowest
- Fix versions: 3.1.6