Bug 179477

Summary: [compiler] problem in first element of array initializer suppresses further problems
Product: [Eclipse Project] JDT Reporter: Markus Keller <markus.kell.r>
Component: CoreAssignee: Philipe Mulet <philippe_mulet>
Status: VERIFIED FIXED QA Contact:
Severity: minor    
Priority: P3    
Version: 3.3   
Target Milestone: 3.3 M7   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Bug Depends on:    
Bug Blocks: 156731    
Attachments:
Description Flags
Proposed patch
none
Second part of the patch (for regression induced) none

Description Markus Keller CLA 2007-03-27 06:28:09 EDT
N20070327-0010

Problems in the first element of an array initializer suppress problems in subsequent elements:

public class Try {
    String[] m(String arg) {
        System.out.println(argument + argument);
        return new String[] { argument + argument, argument/*no problem*/ };
    }
}

I would expect that the last 'argument' is also flagged as error. This would e.g. allow the 'Rename In File' quick assist to include it when started on the first 'argument'.
Comment 1 Philipe Mulet CLA 2007-03-27 07:14:07 EDT
We could indeed by a little more fault tolerant, and keep trying to report more errors at once (as we usually try to do where it makes sense).
Comment 2 Philipe Mulet CLA 2007-03-27 07:29:43 EDT
Added ArrayTest#test013
Comment 3 Philipe Mulet CLA 2007-03-27 09:38:06 EDT
Created attachment 62086 [details]
Proposed patch
Comment 4 Philipe Mulet CLA 2007-03-27 09:38:32 EDT
Released for 3.3M7.
Fixed
Comment 5 Olivier Thomann CLA 2007-03-28 09:28:43 EDT
Test org.eclipse.jdt.ui.tests.quickfix.UnresolvedVariablesQuickFixTest#testVarInAnnotation3
needs to be updated.
Comment 6 Olivier Thomann CLA 2007-03-28 10:05:02 EDT
The following test case:
public class E {
    public @interface Annot {
        float[] value();
    }
    @Annot(value={x})
    class Inner {
    }
}
now reports two errors instead of one:
x cannot be resolved
The value for annotation attribute E.Annot.value must be a constant expression

Prior to the fix, only the first error was reported. The second error can be seen as a secondary error.
Comment 7 Philipe Mulet CLA 2007-03-29 07:53:38 EDT
Agreed. Fixed the other case as well, added AnnotationTest#test226.
Comment 8 Philipe Mulet CLA 2007-03-29 07:54:17 EDT
Created attachment 62375 [details]
Second part of the patch (for regression induced)
Comment 9 Jerome Lanneluc CLA 2007-04-27 07:29:08 EDT
Verified for 3.3M7 with I20070427-0010