diff --git a/libraries/stdlib/src/kotlin/properties/MapAccessors.kt b/libraries/stdlib/src/kotlin/properties/MapAccessors.kt index 2fa8ce13766..49dad03a858 100644 --- a/libraries/stdlib/src/kotlin/properties/MapAccessors.kt +++ b/libraries/stdlib/src/kotlin/properties/MapAccessors.kt @@ -11,7 +11,7 @@ package kotlin.properties * * @throws NoSuchElementException when the map doesn't contain value for the property name and doesn't provide an implicit default (see [withDefault]). */ -public fun Map.getValue(thisRef: Any?, property: PropertyMetadata): V = getOrImplicitDefault(property.name) as V +public fun Map.getValue(thisRef: Any?, property: PropertyMetadata): V1 = getOrImplicitDefault(property.name) as V1 /** * Returns the value of the property for the given object from this mutable map. diff --git a/libraries/stdlib/test/properties/delegation/MapAccessorsTest.kt b/libraries/stdlib/test/properties/delegation/MapAccessorsTest.kt index a4f4336b018..a6e08864858 100644 --- a/libraries/stdlib/test/properties/delegation/MapAccessorsTest.kt +++ b/libraries/stdlib/test/properties/delegation/MapAccessorsTest.kt @@ -9,11 +9,13 @@ class ValByMapExtensionsTest { val map: Map = hashMapOf("a" to "all", "b" to "bar", "c" to "code") val genericMap = mapOf("i" to 1, "x" to 1.0) - val a: String by map + val a by map val b: String by map val c: Any by map val d: String? by map - val e: String? by map.withDefault { "default" } + val e: String by map.withDefault { "default" } + val f: String? by map.withDefault { null } + // val n: Int by map // prohibited by type system val i: Int by genericMap val x: Double by genericMap @@ -23,6 +25,7 @@ class ValByMapExtensionsTest { assertEquals("bar", b) assertEquals("code", c) assertEquals("default", e) + assertEquals(null, f) assertEquals(1, i) assertEquals(1.0, x) assertTrue(assertFails { d } is NoSuchElementException)