Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 340459 - [Xbase] Support for static method calls
Summary: [Xbase] Support for static method calls
Status: CLOSED FIXED
Alias: None
Product: TMF
Classification: Modeling
Component: Xtext (show other bugs)
Version: 2.0.0   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: M7   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-03-18 12:36 EDT by Christian Dietrich CLA
Modified: 2017-09-19 18:02 EDT (History)
2 users (show)

See Also:
sven.efftinge: indigo+


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Christian Dietrich CLA 2011-03-18 12:36:44 EDT
I cannot call a static java method from an Xtend/Xbase.

Double xxx() {
    return Double.valueOf("1");
}

does not work,
but

import static extension java.lang.Double.*

...
Double xxx() {
   return valueOf("1");
}

does work but this might be ambigous in some cases
Comment 1 Sven Efftinge CLA 2011-03-18 12:49:16 EDT
It is not ambiguous, since the precedence of scopes is well defined. Though it shadows a similar named member on 'this' (which can be reached using 'this' explicitly).

However, the mentioned feature is planned to be added. But we won't use the Java syntax since it would harm the implementation too much. 
Instead we use a double colon '::' like in Xtend 1.

So it would be 'Double::valueOf("1")' instead.
Comment 2 Christian Dietrich CLA 2011-03-19 12:41:09 EDT
with ambigous i meant that with imports something like

import static extension java.lang.Double.*
import static extension java.lang.Integer.*

might be a problem cause both offer a valueOf with String as Parameter
Comment 3 Sven Efftinge CLA 2011-03-20 01:39:45 EDT
In that case they shouldn't be put on the scope at all (future plan).
But for the sake of simplicity in the implementation there is currently a defined precedence.
So the order of static imports matters.
Comment 4 Sebastian Zarnekow CLA 2011-03-29 10:53:58 EDT
Xbase 2.0M7 supports Double::valueOf('') as well as org::mypack::EnumType::LITERAL
Comment 5 Sebastian Zarnekow CLA 2011-03-29 10:54:30 EDT
I'll file a new ticket for this aspect.

(In reply to comment #3)
> In that case they shouldn't be put on the scope at all (future plan).
Comment 6 Karsten Thoms CLA 2017-09-19 17:52:15 EDT
Closing all bugs that were set to RESOLVED before Neon.0
Comment 7 Karsten Thoms CLA 2017-09-19 18:02:56 EDT
Closing all bugs that were set to RESOLVED before Neon.0