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

Bug 358852

Summary: [Xbase] Introduce second implicit argument for feature calls
Product: [Modeling] TMF Reporter: Sven Efftinge <sven.efftinge>
Component: XtextAssignee: Project Inbox <tmf.xtext-inbox>
Status: CLOSED FIXED QA Contact:
Severity: enhancement    
Priority: P1 CC: sebastian.zarnekow
Version: 2.0.1Flags: sven.efftinge: indigo+
Target Milestone: SR2   
Hardware: All   
OS: All   
Whiteboard:

Description Sven Efftinge CLA 2011-09-26 03:26:05 EDT
Now that we allow having a second implicit variable, it makes even more sense to allow invocation of extension methods on 'this' and 'it'. This is especially interesting for Xtend.

Example:

class MyXtendClass {
  
  def prependHello(String myString) {
    'Hello '+myString
  }

  def testExtensionMethods() {
    val it = 'World'
    // currently we have to write
    it.prependHello
    // it should be possible to omit the receiver
    prependHello  // doesn't work at the moment
  }
}

Not that, if both 'this' and 'it' are compatible to the same extension method the implicit is bound to 'it'.
Comment 1 Sebastian Zarnekow CLA 2011-10-18 05:47:51 EDT
Concrete syntax:

featureCall()

possible resolutions (ordered):

it.featureCall()
this.featureCall()
extension.featureCall()
Static.featureCall()
this.featureCall(it)
extension.featureCall(it)
Static.featureCall(it)

====================================

Concreate syntax:

that.featureCall()

possible resolutions (ordered):

that.featureCall()
this.featureCall(that)
extension.featureCall(that)
Static.featureCall(that)
Comment 2 Sebastian Zarnekow CLA 2011-10-19 07:13:21 EDT
First shot pushed to master. There's still some remaining work for the feature / sugar precedencies.
Comment 3 Sebastian Zarnekow CLA 2011-10-23 10:23:09 EDT
Pushed to master.
Comment 4 Karsten Thoms CLA 2017-09-19 17:16:42 EDT
Closing all bugs that were set to RESOLVED before Neon.0
Comment 5 Karsten Thoms CLA 2017-09-19 17:28:02 EDT
Closing all bugs that were set to RESOLVED before Neon.0