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:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user