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

Bug 340459

Summary: [Xbase] Support for static method calls
Product: [Modeling] TMF Reporter: Christian Dietrich <christian.dietrich.opensource>
Component: XtextAssignee: Project Inbox <tmf.xtext-inbox>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: sebastian.zarnekow, sven.efftinge
Version: 2.0.0Flags: sven.efftinge: indigo+
Target Milestone: M7   
Hardware: All   
OS: All   
Whiteboard:

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