Transform builtin Map declaration and adjust stdlib
This commit is contained in:
committed by
Mikhail Glukhikh
parent
f0e3fd617d
commit
6fa8083a70
@@ -284,33 +284,33 @@ public interface Map<K, out V> {
|
||||
/**
|
||||
* Returns `true` if the map contains the specified [key].
|
||||
*/
|
||||
public fun containsKey(key: Any?): Boolean
|
||||
public fun containsKey(key: K): Boolean
|
||||
|
||||
/**
|
||||
* Returns `true` if the map maps one or more keys to the specified [value].
|
||||
*/
|
||||
public fun containsValue(value: Any?): Boolean
|
||||
public fun containsValue(value: @UnsafeVariance V): Boolean
|
||||
|
||||
/**
|
||||
* Returns the value corresponding to the given [key], or `null` if such a key is not present in the map.
|
||||
*/
|
||||
public operator fun get(key: Any?): V?
|
||||
public operator fun get(key: K): V?
|
||||
|
||||
// Views
|
||||
/**
|
||||
* Returns a [Set] of all keys in this map.
|
||||
*/
|
||||
public fun keySet(): Set<K>
|
||||
public val keys: Set<K>
|
||||
|
||||
/**
|
||||
* Returns a [Collection] of all values in this map. Note that this collection may contain duplicate values.
|
||||
*/
|
||||
public fun values(): Collection<V>
|
||||
public val values: Collection<V>
|
||||
|
||||
/**
|
||||
* Returns a [Set] of all key/value pairs in this map.
|
||||
*/
|
||||
public fun entrySet(): Set<Map.Entry<K, V>>
|
||||
public val entries: Set<Map.Entry<K, V>>
|
||||
|
||||
/**
|
||||
* Represents a key/value pair held by a [Map].
|
||||
@@ -348,7 +348,7 @@ public interface MutableMap<K, V> : Map<K, V> {
|
||||
*
|
||||
* @return the previous value associated with the key, or `null` if the key was not present in the map.
|
||||
*/
|
||||
public fun remove(key: Any?): V?
|
||||
public fun remove(key: K): V?
|
||||
|
||||
// Bulk Modification Operations
|
||||
/**
|
||||
@@ -362,9 +362,9 @@ public interface MutableMap<K, V> : Map<K, V> {
|
||||
public fun clear(): Unit
|
||||
|
||||
// Views
|
||||
override fun keySet(): MutableSet<K>
|
||||
override fun values(): MutableCollection<V>
|
||||
override fun entrySet(): MutableSet<MutableMap.MutableEntry<K, V>>
|
||||
override val keys: MutableSet<K>
|
||||
override val values: MutableCollection<V>
|
||||
override val entries: MutableSet<MutableMap.MutableEntry<K, V>>
|
||||
|
||||
/**
|
||||
* Represents a key/value pair held by a [MutableMap].
|
||||
|
||||
+2
-1
@@ -41,7 +41,8 @@ object EMPTY_MEMBER_INDEX : MemberIndex {
|
||||
|
||||
private val ADDITIONAL_MEMBER_NAMES_MAP = mapOf(
|
||||
FqName("java.util.List") to listOf(Name.identifier("removeAt")),
|
||||
FqName("java.lang.CharSequence") to listOf(Name.identifier("get"))
|
||||
FqName("java.lang.CharSequence") to listOf(Name.identifier("get")),
|
||||
FqName("java.util.Map") to listOf(Name.identifier("keys"), Name.identifier("entries"))
|
||||
)
|
||||
|
||||
open class ClassMemberIndex(val jClass: JavaClass, val memberFilter: (JavaMember) -> Boolean) : MemberIndex {
|
||||
|
||||
+11
-3
@@ -35,7 +35,10 @@ object BuiltinSpecialProperties {
|
||||
private val PROPERTY_FQ_NAME_TO_JVM_GETTER_NAME_MAP = mapOf(
|
||||
FqName("kotlin.Collection.size") to Name.identifier("size"),
|
||||
FqName("kotlin.Map.size") to Name.identifier("size"),
|
||||
FqName("kotlin.CharSequence.length") to Name.identifier("length")
|
||||
FqName("kotlin.CharSequence.length") to Name.identifier("length"),
|
||||
FqName("kotlin.Map.keys") to Name.identifier("keySet"),
|
||||
FqName("kotlin.Map.values") to Name.identifier("values"),
|
||||
FqName("kotlin.Map.entries") to Name.identifier("entrySet")
|
||||
)
|
||||
|
||||
private val GETTER_JVM_NAME_TO_PROPERTIES_SHORT_NAME_MAP: Map<Name, List<Name>> =
|
||||
@@ -71,7 +74,12 @@ object BuiltinSpecialProperties {
|
||||
object BuiltinMethodsWithSpecialJvmSignature {
|
||||
private val ERASED_COLLECTION_PARAMETER_FQ_NAMES = setOf(FqName("kotlin.Collection.containsAll"))
|
||||
private val GENERIC_PARAMETERS_FQ_NAMES = setOf(
|
||||
FqName("kotlin.Collection.contains"), FqName("kotlin.MutableCollection.remove")
|
||||
FqName("kotlin.Collection.contains"),
|
||||
FqName("kotlin.MutableCollection.remove"),
|
||||
FqName("kotlin.Map.containsKey"),
|
||||
FqName("kotlin.Map.containsValue"),
|
||||
FqName("kotlin.Map.get"),
|
||||
FqName("kotlin.MutableMap.remove")
|
||||
)
|
||||
|
||||
private val ERASED_VALUE_PARAMETERS_FQ_NAMES =
|
||||
@@ -121,7 +129,7 @@ object BuiltinSpecialMethods {
|
||||
val REMOVE_AT_FQ_NAME = FqName("kotlin.MutableList.removeAt")
|
||||
|
||||
val FQ_NAMES_TO_JVM_MAP: Map<FqName, Name> = mapOf(
|
||||
REMOVE_AT_FQ_NAME to Name.identifier("remove"),
|
||||
REMOVE_AT_FQ_NAME to Name.identifier("remove"),
|
||||
FqName("kotlin.CharSequence.get") to Name.identifier("charAt")
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user