Community
Participate
Working Groups
Consider the following case in compliance 12 with preview feature usage warning ignored: public class X { public void main(String [] args, final String argument) { switch(args[0]) { case "ABC", (false ? (String) "c" : (String) "d") : break; } } } There should be a dead code warning, but there isn't. If you shuffle the constants, this is reported. The reason is we don't call analyseCode() on all the constant expressions inside CaseStatement.analyseCode(...). I have a fix ready.
New Gerrit change created: https://git.eclipse.org/r/138986
*** Bug 545516 has been marked as a duplicate of this bug. ***
+1 for this issue.. However got another bug 545525 while testing related with multi-constants - However, this patch can be committed since that error is happening independent of this patch.
Gerrit change https://git.eclipse.org/r/138986 was merged to [BETA_JAVA_12]. Commit: http://git.eclipse.org/c/jdt/eclipse.jdt.core.git/commit/?id=3376a0f9b0b41ccc98b973fa93072064b1f74fd9
A few issues - realized a little later: the check needs to be: if (!this.parsingJava12Plus) { // problemReporter().caseStatementWithArrowNotBelow12(caseStatement); problemReporter().previewFeatureNotSupported(); //$NON-NLS-1$ } else if (!this.options.enablePreviewFeatures){ problemReporter().previewFeatureNotEnabled(); //$NON-NLS-1$ } else { if (this.options.isAnyEnabled(IrritantSet.PREVIEW)) { problemReporter().previewFeatureUsed( } } and the case.constantExpressions should be assigned only after all the checks. This is the root causeof bug 545387 as well. The <= 12 flag in the current patch does n't cover all these scenarios
*** Bug 545525 has been marked as a duplicate of this bug. ***
(In reply to Manoj Palat from comment #5) > checks. This is the root causeof bug 545387 as well. > Bug 545525 is the correct bug number of the duplicate and not the one above. (blame it on release pressure :()
Created attachment 277929 [details] test case @Jay: Please find a test case patch. Feel free to add this if it helps.
New Gerrit change created: https://git.eclipse.org/r/139017
(In reply to Manoj Palat from comment #8) > Created attachment 277929 [details] [diff] > test case > > @Jay: Please find a test case patch. Feel free to add this if it helps. Thanks Manoj! I had a similar test case, but it did point out that I had some unnecessary code in my version of test. I have fixed it now.
A word about the failures in FormatterRegressionTests: Formatter/Rewrite now expect the expressions() to return a non empty list and if we don't find, we fal back to the legacy expression. And looks like there's a difference in how the formatter treats the code in presence of expressions() and otherwise. This can be fixed, but I couldn't figure where in formatter this is done and decided to simply set the expressions (in compiler ast) regardless of the compliance level. The test case mentioned in bug 545525 is taken care of by rejecting the code at < 12. I am OK to revert the last piece of change in Parser#consumeCaseLable() and fix the formatter, but I don't see any harm in going with the latest patch. Manoj, please take a look. TIA!
(In reply to Jay Arthanareeswaran from comment #11) > > Manoj, please take a look. TIA! Thanks Jay. Code looks ok and my sanity tests also did not reveal any issue. In the latest build run neither do I see a failure in the rewriting test nor do I see any change in rewriting tests in the patch, but I see you have mentioned rewrite failures. can you please explain? If there are no rewrite failures, but only formatter issues, we can go ahead and commit the patch with a follow up bug on the formatter issue. +1 if that is the case.
(In reply to Manoj Palat from comment #12) > (In reply to Jay Arthanareeswaran from comment #11) > > > > Manoj, please take a look. TIA! > > Thanks Jay. Code looks ok and my sanity tests also did not reveal any issue. > In the latest build run neither do I see a failure in the rewriting test nor > do I see any change in rewriting tests in the patch, but I see you have > mentioned rewrite failures. can you please explain? I meant to say the change might affect rewrite as well if they are expecting expressions() always in AST > 12 (regardless of how many case constants). But then I don't see any failures. Probably they handle it better than the formatter, I suppose. Either way, the latest patch should make sure that those clients are not affected now.
Gerrit change https://git.eclipse.org/r/139017 was merged to [BETA_JAVA_12]. Commit: http://git.eclipse.org/c/jdt/eclipse.jdt.core.git/commit/?id=2a8617c89c5e3d9080624481df4455c71bf1f04a