diff --git a/libraries/stdlib/src/kotlin/JUtilMaps.kt b/libraries/stdlib/src/kotlin/JUtilMaps.kt index 22a6175fe3c..b429f71ec8a 100644 --- a/libraries/stdlib/src/kotlin/JUtilMaps.kt +++ b/libraries/stdlib/src/kotlin/JUtilMaps.kt @@ -4,8 +4,7 @@ import java.util.Map as JMap import java.util.HashMap import java.util.Collections -// Temporary workaround: commenting out -//import java.util.Map.Entry as JEntry +import java.util.Map.Entry as JEntry // Map APIs @@ -26,14 +25,12 @@ public inline fun java.util.Map?.orEmpty() : java.util.Map /** Returns the key of the entry */ -// Temporary workaround: commenting out -//val JEntry.key : K -// get() = getKey().sure() +val JEntry.key : K + get() = getKey().sure() /** Returns the value of the entry */ -// Temporary workaround: commenting out -//val JEntry.value : V -// get() = getValue().sure() +val JEntry.value : V + get() = getValue().sure() /** * Returns the value for the given key or returns the result of the defaultValue function if there was no entry for the given key @@ -69,7 +66,7 @@ public inline fun java.util.Map.getOrPut(key: K, defaultValue: ()-> V /** * Returns an [[Iterator]] over the entries in the [[Map]] * - * @includeFunctionBody ../../test/MapTest.kt iterate + * @includeFunctionBody ../../test/MapTest.kt iterateWithProperties */ public inline fun java.util.Map.iterator(): java.util.Iterator> { val entrySet = this.entrySet()!! diff --git a/libraries/stdlib/test/MapTest.kt b/libraries/stdlib/test/MapTest.kt index 887ae86ade4..7368510c507 100644 --- a/libraries/stdlib/test/MapTest.kt +++ b/libraries/stdlib/test/MapTest.kt @@ -52,42 +52,31 @@ class MapTest { map["location"] = "Mells" map["name"] = "James" - var list = arrayList() + val list = arrayList() for (e in map) { println("key = ${e.getKey()}, value = ${e.getValue()}") - list.add(e.getKey()) list.add(e.getValue()) -/* - // TODO compiler bug - list += e.getKey() - list += e.getValue() -*/ } assertEquals(6, list.size()) assertEquals("beverage,beer,location,Mells,name,James", list.makeString(",")) } - /* - TODO compiler bug - - test fun iteratorWithProperties() { + test fun iterateWithProperties() { val map = TreeMap() map["beverage"] = "beer" map["location"] = "Mells" map["name"] = "James" - var list = arrayList() + val list = arrayList() for (e in map) { - println("got $e") println("key = ${e.key}, value = ${e.value}") - list += e.key - list += e.value + list.add(e.key) + list.add(e.value) } assertEquals(6, list.size()) assertEquals("beverage,beer,location,Mells,name,James", list.makeString(",")) } - */ }