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

Bug 367032

Summary: [Xtend] "map" method cannot be used with EMap
Product: [Tools] Xtend Reporter: Nikolay Kasyanov <corrmage>
Component: CoreAssignee: Project Inbox <xtend-inbox>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: dennis.huebner, sebastian.zarnekow, sven.efftinge
Version: 2.2.0   
Target Milestone: M6   
Hardware: PC   
OS: All   
Whiteboard:
Bug Depends on: 376037    
Bug Blocks:    

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.