Bug 91761 - [1.5][compiler] Return statements ignored in anonymous inner classes used as enum constant constructor parameters.
Summary: [1.5][compiler] Return statements ignored in anonymous inner classes used as ...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 major (vote)
Target Milestone: 3.1 M7   Edit
Assignee: David Audel CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-04-18 13:33 EDT by David Gates CLA
Modified: 2005-05-12 14:10 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description David Gates CLA 2005-04-18 13:33:46 EDT
//BugDemo.java
interface Foo {
	public boolean bar();
}

enum BugDemo {
	CONSTANT(new Foo() {
		public boolean bar() { //marker on bar(): "This method must return a result of
type boolean"
			return true;
		}
	});
	
	BugDemo(Foo foo) {
	}
}
Comment 1 Philipe Mulet CLA 2005-04-25 18:05:56 EDT
build 3.1m6
Comment 2 Philipe Mulet CLA 2005-04-26 04:42:27 EDT
Problem is in parser which discard the statements inside the #bar() method.
Comment 3 David Audel CLA 2005-04-26 06:24:55 EDT
Enum constants are parsed during diet parse and this parse jump over method body.
We must force the no diet mode for enum constant arguments.
Comment 4 David Audel CLA 2005-04-26 07:23:30 EDT
inside the grammar

EnumConstantHeader ::= EnumConstantHeaderName Argumentsopt

must be replaced by

EnumConstantHeader ::= EnumConstantHeaderName ForceNoDiet Argumentsopt RestoreDiet
Comment 5 David Audel CLA 2005-04-26 07:40:10 EDT
Fixed and test added
  EnumTest#test101()
Comment 6 Olivier Thomann CLA 2005-05-12 14:10:18 EDT
Verified in I20050510-0010 + JDT/Core v_556