Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 358852 - [Xbase] Introduce second implicit argument for feature calls
Summary: [Xbase] Introduce second implicit argument for feature calls
Status: CLOSED FIXED
Alias: None
Product: TMF
Classification: Modeling
Component: Xtext (show other bugs)
Version: 2.0.1   Edit
Hardware: All All
: P1 enhancement (vote)
Target Milestone: SR2   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-09-26 03:26 EDT by Sven Efftinge CLA
Modified: 2017-09-19 17:28 EDT (History)
1 user (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 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