Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 367032 - [Xtend] "map" method cannot be used with EMap
Summary: [Xtend] "map" method cannot be used with EMap
Status: CLOSED FIXED
Alias: None
Product: Xtend
Classification: Tools
Component: Core (show other bugs)
Version: 2.2.0   Edit
Hardware: PC All
: P3 normal (vote)
Target Milestone: M6   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on: 376037
Blocks:
  Show dependency tree
 
Reported: 2011-12-18 08:06 EST by Nikolay Kasyanov CLA
Modified: 2017-10-31 11:16 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nikolay Kasyanov CLA 2011-12-18 08:06:24 EST
Build Identifier: 20110916-0149

EMF's EMap is actually a EList<java.util.Map.Entry<K,V>>, so it's obvious to use map to do something with entries.

But there is compiler error when trying to use map method on EMap instance. Code example:
val l = new BasicEMap<String, String>()
val ll = l.map(e | e.key) // error here

error message: Incompatible receiver type. Expected java.util.List<java.util.Map.Entry<java.lang.String,java.lang.String>> or java.util.Map.Entry<java.lang.String,java.lang.String>[] but was org.eclipse.emf.common.util.BasicEMap<java.lang.String,java.lang.String>

this code works:
val l = new BasicEList<Entry<String, String>>()
val ll = l.map(e | e.key)

Reproducible: Always
Comment 1 Sven Efftinge CLA 2011-12-18 08:17:46 EST
Don't you mean 

val ll = l.entrySet.map( e | e.key )

?
Comment 2 Nikolay Kasyanov CLA 2011-12-18 09:38:04 EST
(In reply to comment #1)
> Don't you mean 
> 
> val ll = l.entrySet.map( e | e.key )
> 
> ?

thanks, this works.
But isn't it strange that "map" can't be used directly with EMap class which implements List interface?
Comment 3 Dennis Huebner CLA 2013-02-14 05:50:28 EST
Works now.

val l = new BasicEMap<String, String>()
val ll = l.map(e | e.key) // No error here
Comment 4 Eclipse Webmaster CLA 2017-10-31 11:05:06 EDT
Requested via bug 522520.

-M.
Comment 5 Eclipse Webmaster CLA 2017-10-31 11:16:28 EDT
Requested via bug 522520.

-M.