Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 361780 - [xtend] Good code compiles to invalid java code
Summary: [xtend] Good code compiles to invalid java code
Status: CLOSED DUPLICATE of bug 361782
Alias: None
Product: Xtend
Classification: Tools
Component: Core (show other bugs)
Version: 2.2.0   Edit
Hardware: PC Mac OS X - Carbon (unsup.)
: P3 normal (vote)
Target Milestone: M6   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-10-24 05:28 EDT by Sebastian Zarnekow CLA
Modified: 2012-04-04 03:47 EDT (History)
1 user (show)

See Also:
sven.efftinge: juno+


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sebastian Zarnekow CLA 2011-10-24 05:28:03 EDT
Try to implement a custom type provider with Xtend:

def dispatch type(XBinaryOperation bo, JvmTypeReference r, boolean b) {
  if (true) throw new RuntimeException("This is expected")
}

this compiles to:

protected JvmTypeReference _type(final XBinaryOperation bo, final JvmTypeReference r, final boolean b) {
    Object _xifexpression = null; <--- wrong type
    if (true) {
      RuntimeException _runtimeException = new RuntimeException("This is expected");
      throw _runtimeException;
    }
    return _xifexpression;
  }
Comment 1 Sebastian Zarnekow CLA 2012-04-04 03:37:57 EDT
The given sample now raises the expected error 

Incompatible return type of dispatch method. Expected org.eclipse.xtext.common.types.JvmTypeReference 
 but was void
Comment 2 Sebastian Zarnekow CLA 2012-04-04 03:38:56 EDT
Unfortunately this sample snippet reveals another problem:

def dispatch type(XBinaryOperation bo, JvmTypeReference r, boolean b) {
	  throw new RuntimeException("This is expected")
	}

The same error is raised as with the initial example.
Comment 3 Sebastian Zarnekow CLA 2012-04-04 03:47:31 EDT

*** This bug has been marked as a duplicate of bug 361782 ***