Bug 79144

Summary: [1.5][compiler] generic type checking not performed for method return array types
Product: [Eclipse Project] JDT Reporter: mike andrews <mikea>
Component: CoreAssignee: Philipe Mulet <philippe_mulet>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: eclipse.org
Version: 3.1   
Target Milestone: 3.1 M5   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description mike andrews CLA 2004-11-21 08:20:53 EST
the following code MUST generate a compiler error or warning, but doesn't:

public Set<String>[] test() {
   Set[] sets = new Set[10];
   return sets;
}
Comment 1 Dave Latham CLA 2004-11-29 12:55:06 EST
I think the same problem applies for all array assignments, for example, this
code produces no warnings, but gives a run time class cast exception:

public class GenericArrayTrouble {
    public static void main(String[] args) {
        List<Integer>[] nums = new List[] {Collections.singletonList("Uh oh")};
        System.out.println(nums[0].get(0).intValue());
    } 
}
Comment 2 Philipe Mulet CLA 2005-01-15 09:24:29 EST
We did not properly check array types.
Added support, we now report: 

Type safety: The expression of type Set[] needs unchecked conversion to conform
to Set<String>[].

Added GenericTypeTest#test462.

Comment 3 Philipe Mulet CLA 2005-01-15 09:26:06 EST
Second scenario is the same issue indeed.
Added GenericTypeTest#test463.

Fixed
Comment 4 Philipe Mulet CLA 2005-01-15 09:27:30 EST
Tests are actually: test463 & test464.
Comment 5 Jerome Lanneluc CLA 2005-02-15 06:01:14 EST
Verified in I20050214