Add MutableMap.remove(K, V) as built-in declaration

Use PlatformDependent annotation to guarantee it's only be available for JDK8
Also adjust type-safe bridges and mutable collection stubs generation
This commit is contained in:
Denis Zharkov
2016-04-28 09:09:25 +03:00
parent 55c4f875c8
commit d259b91143
41 changed files with 875 additions and 77 deletions
@@ -16,6 +16,8 @@
package kotlin.collections
import kotlin.internal.PlatformDependent
/**
* Classes that inherit from this interface can be represented as a sequence of elements that can
* be iterated over.
@@ -350,6 +352,17 @@ public interface MutableMap<K, V> : Map<K, V> {
*/
public fun remove(key: K): V?
/**
* Removes the entry for the specified key only if it is mapped to the specified value.
*
* @return true if entry was removed
*/
@PlatformDependent
public fun remove(key: K, value: V): Boolean {
// See default implementation in JDK sources
return true
}
// Bulk Modification Operations
/**
* Updates this map with key/value pairs from the specified map [from].
@@ -23,3 +23,13 @@ package kotlin.internal
@Target(AnnotationTarget.TYPE_PARAMETER)
@Retention(AnnotationRetention.BINARY)
internal annotation class PureReifiable
/**
* Specifies that the corresponding built-in method exists depending on platform.
* Current implementation for JVM looks whether method with same JVM descriptor exists in the module JDK.
* For example MutableMap.remove(K, V) available only if corresponding
* method 'java/util/Map.remove(Ljava/lang/Object;Ljava/lang/Object;)Z' is defined in JDK (i.e. for major versions >= 8)
*/
@Target(AnnotationTarget.FUNCTION)
@Retention(AnnotationRetention.BINARY)
internal annotation class PlatformDependent