Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » [Xtend2] ?. operator for primitives
[Xtend2] ?. operator for primitives [message #682842] Sun, 12 June 2011 08:12 Go to next message
Jos Warmer is currently offline Jos WarmerFriend
Messages: 114
Registered: October 2010
Senior Member
Maybe this is already known, but the following code:
var String empty = null;
var int i = empty?.length

results in Java that has compilation error (cannot cast from null to int):
String empty = null;
int _length = empty==null?(int)null:empty.length();
int i = _length;

There should probably be a check that the return type of the ?.method() is nit a primitive type.
(no subject) [message #682914 is a reply to message #682842] Sun, 12 June 2011 12:33 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Hi Jos,

could you please add your example to this ticket:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=347175

Thanks,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com

Am 12.06.11 10:12, schrieb Jos Warmer:
> Maybe this is already known, but the following code:
> var String empty = null;
> var int i = empty?.length
>
> results in Java that has compilation error (cannot cast from null to int):
> String empty = null;
> int _length = empty==null?(int)null:empty.length();
> int i = _length;
>
> There should probably be a check that the return type of the ?.method()
> is nit a primitive type.
Re: (no subject) [message #682922 is a reply to message #682914] Sun, 12 June 2011 13:37 Go to previous message
Jos Warmer is currently offline Jos WarmerFriend
Messages: 114
Registered: October 2010
Senior Member
Done
Previous Topic:remove WS between
Next Topic:[Xtend2] class with empty method does not compile
Goto Forum:
  


Current Time: Fri Apr 26 15:22:22 GMT 2024

Powered by FUDForum. Page generated in 0.03610 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top