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

Bug 354384

Summary: [xbase] Allow instantiating inner classes
Product: [Modeling] TMF Reporter: Knut Wannheden <knut.wannheden>
Component: XtextAssignee: Project Inbox <tmf.xtext-inbox>
Status: NEW --- QA Contact:
Severity: enhancement    
Priority: P3 CC: btickets, christian.dietrich.opensource, dennis.huebner, jeremie.bresson, nowind_lee, sebastian.zarnekow, sven.efftinge
Version: 2.5.0   
Target Milestone: ---   
Hardware: PC   
OS: Mac OS X - Carbon (unsup.)   
Whiteboard:
Bug Depends on: 427279    
Bug Blocks:    

Description Knut Wannheden CLA 2011-08-10 10:41:05 EDT
Given the following Java classes:

public class Foo {
  public class Bar {
  }
}

In Xtend2 I should be able to write "new Foo().new Bar()". But that gives me a parse error on the second "new".

The editor does however accept "new Foo$Bar()". But that's of course wrong and the generated code doesn't compile.

Setting this one to minor as I think this is fairly unusual coding style.
Comment 1 Sven Efftinge CLA 2014-02-03 10:24:05 EST
*** Bug 377463 has been marked as a duplicate of this bug. ***
Comment 2 Dennis Huebner CLA 2015-11-03 08:49:32 EST
Had the same issue today. If the outer type is not final, following strategy could be a workaround:

val bar = new Foo(){def createBar() {new Bar}}.createBar()