Bug 52221

Summary: [Compiler] should reject Local type usage when defined in other switch case block
Product: [Eclipse Project] JDT Reporter: Philipe Mulet <philippe_mulet>
Component: CoreAssignee: Philipe Mulet <philippe_mulet>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: 3.0   
Target Milestone: 3.0 M8   
Hardware: PC   
OS: Windows 2000   
Whiteboard:

Description Philipe Mulet CLA 2004-02-17 04:42:43 EST
Build 3.0M7

1.4 compliant compilers should reject the following code:

class X {
    public static void main(String[] args) {
        switch(args.length) {
            case 1:
                class Local {
	        }
                break;
                
	    case 0 :
		System.out.println(new Local()); // Local undefined
        }
    }
}
Comment 1 Philipe Mulet CLA 2004-02-17 04:43:28 EST
Javac 1.4.1, Jikes 1.18 do tolerate this code as we do.
Comment 2 Philipe Mulet CLA 2004-02-17 06:22:11 EST
Interestingly enough, the spec still allows the variable 'i' to be seen across 
switch case blocks... only a definite assignment issue is raised. The name can 
be resolved.

class X {
    public static void main(String[] args) {
        
        switch(args.length) {
            
            case 1:
                int i = 0;
                break;
                
			case 0 :
			    System.out.println(i);
        }
    }
}
Comment 3 Philipe Mulet CLA 2004-02-17 09:35:32 EST
Fixed, added regression tests: Compliance13/Compliance14#test073 & test074
Comment 4 Jerome Lanneluc CLA 2004-03-24 11:02:18 EST
Verified in build I200403240800.