Add Map.getOrDefault method as PlatformDependent declaration with refined signature

- First parameter should have type of K instead of Any
- Special bridge should return second parameter if a key has wrong type
- Special bridge may throw an exception if defaultValue has wrong type

 #KT-13209 Fixed
This commit is contained in:
Denis Zharkov
2016-07-27 12:14:08 +03:00
parent 169acf2f31
commit 915e36cb02
15 changed files with 353 additions and 26 deletions
@@ -298,6 +298,17 @@ public interface Map<K, out V> {
*/
public operator fun get(key: K): V?
/**
* Returns the value corresponding to the given [key], or [defaultValue] if such a key is not present in the map.
*
* @since JDK 1.8
*/
@PlatformDependent
public fun getOrDefault(key: K, defaultValue: @UnsafeVariance V): V {
// See default implementation in JDK sources
return null as V
}
// Views
/**
* Returns a [Set] of all keys in this map.