diff --git a/libraries/stdlib/src/kotlin/collections/MapAccessors.kt b/libraries/stdlib/src/kotlin/collections/MapAccessors.kt index 157762278c0..0de148d82e2 100644 --- a/libraries/stdlib/src/kotlin/collections/MapAccessors.kt +++ b/libraries/stdlib/src/kotlin/collections/MapAccessors.kt @@ -29,6 +29,13 @@ public inline operator fun Map.getValue(thisRef: public inline operator fun MutableMap.getValue(thisRef: Any?, property: KProperty<*>): V1 = @Suppress("UNCHECKED_CAST") (getOrImplicitDefault(property.name) as V1) +@Deprecated("Use getValue() with two type parameters instead") +@kotlin.jvm.JvmName("getVarContravariant") +@kotlin.internal.LowPriorityInOverloadResolution +@kotlin.internal.InlineOnly +public inline fun MutableMap.getValue(thisRef: Any?, property: KProperty<*>): V + = @Suppress("UNCHECKED_CAST") (getOrImplicitDefault(property.name) as V) + /** * Stores the value of the property for the given object in this mutable map. * @param thisRef the object for which the value is requested (not used). diff --git a/libraries/stdlib/test/properties/delegation/MapAccessorsTest.kt b/libraries/stdlib/test/properties/delegation/MapAccessorsTest.kt index 7e724498a0a..063f97f8ca8 100644 --- a/libraries/stdlib/test/properties/delegation/MapAccessorsTest.kt +++ b/libraries/stdlib/test/properties/delegation/MapAccessorsTest.kt @@ -63,4 +63,15 @@ class VarByMapExtensionsTest { map["d"] = null assertEquals(null, d) } + + @Test fun deprecatedAccessors() { + assertEquals( + expected = map.getValue(this, VarByMapExtensionsTest::c), + actual = map.getValue(this, VarByMapExtensionsTest::c) + ) + assertEquals( + expected = map2.getValue(this, VarByMapExtensionsTest::a2), + actual = map2.getValue(this, VarByMapExtensionsTest::a2) + ) + } } \ No newline at end of file