Bug 83847

Summary: [compiler][1.5] can create annonymous class of an enum
Product: [Eclipse Project] JDT Reporter: Martin Aeschlimann <martinae>
Component: CoreAssignee: Philipe Mulet <philippe_mulet>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: 3.0   
Target Milestone: 3.1 M5   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Apply on QualifiedAllocationExpression
none
Apply on QualifiedAllocationExpression none

Description Martin Aeschlimann CLA 2005-01-27 12:42:35 EST
20050127

The compiler allows this but probably shouldn't (javac rejects it).

public enum E {
  A;
  private void foo() {
    E e= new E() {
    };
  }
}
Comment 1 Olivier Thomann CLA 2005-01-27 14:15:59 EST
Created attachment 17521 [details]
Apply on QualifiedAllocationExpression
Comment 2 Philipe Mulet CLA 2005-01-27 14:17:16 EST
We should complain. Enums cannot be subclassed by user code (only enum constant
bodies can do so).

Thanks for finding it
Comment 3 Olivier Thomann CLA 2005-01-27 14:35:07 EST
The patch doesn't work.
The test needs to be:
receiverType.isEnum() && type != null
Comment 4 Olivier Thomann CLA 2005-01-27 14:46:00 EST
Created attachment 17522 [details]
Apply on QualifiedAllocationExpression
Comment 5 Philipe Mulet CLA 2005-01-27 15:44:57 EST
I had figured this too.
Comment 6 Philipe Mulet CLA 2005-01-27 15:49:06 EST
Added EnumTest#test065.
Fixed
Comment 7 Jerome Lanneluc CLA 2005-02-15 06:30:59 EST
Verified in I20050214