Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 455986

Summary: ASTParser ignores call to super() in K_STATEMENTS mode
Product: [Eclipse Project] JDT Reporter: Mateusz Matela <mateusz.matela>
Component: CoreAssignee: Olivier Thomann <Olivier_Thomann>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: manoj.palat, markus.kell.r, Olivier_Thomann, shankhba
Version: 4.5   
Target Milestone: 4.5 M5   
Hardware: PC   
OS: Windows 7   
Whiteboard:
Attachments:
Description Flags
Proposed patch
none
Proposed regression test none

Description Mateusz Matela CLA 2014-12-22 13:38:08 EST
Run this code snippet:

ASTParser parser = ASTParser.newParser(AST.JLS8);
parser.setKind(ASTParser.K_STATEMENTS);
parser.setSource("super();".toCharArray());
ASTNode astNode = parser.createAST(null);

The resulting astNode is a Block without any statements, but it should contain a SuperConstructorInvocation.

I've looked into ASTParser code and around line 1350 it seems that constructorDeclaration is converted using only its statements field, but constructorCall field should be used as well.
Comment 1 Olivier Thomann CLA 2014-12-22 14:00:22 EST
Indeed, this is an oversight.
Comment 2 Olivier Thomann CLA 2014-12-22 14:00:43 EST
Created attachment 249597 [details]
Proposed patch
Comment 3 Olivier Thomann CLA 2014-12-22 14:01:03 EST
Created attachment 249598 [details]
Proposed regression test
Comment 4 Manoj N Palat CLA 2015-01-05 00:03:04 EST
Thanks for patches Olivier. Ran the tests and committed via: http://git.eclipse.org/c/jdt/eclipse.jdt.core.git/commit/?id=1bf86fe4326efd3891490b85eefffb1c336ab872
Comment 5 Manoj N Palat CLA 2015-01-28 02:12:22 EST
Verified for Eclipse Mars 4.5 M5 Build id: I20150126-2000