Allow delegating val properties to out-projected MutableMap

Change generic signature of MutableMap.getValue, use 'out @Exact V' and `V1: V` types instead of single `in V`.
Fix affected IR generation tests.

#KT-18789 Fixed
This commit is contained in:
Ilya Gorbunov
2017-07-01 17:00:16 +03:00
parent e503c1d411
commit 7efaa7cabc
6 changed files with 18 additions and 7 deletions
@@ -113,8 +113,9 @@ FILE /classLevelProperties.kt
$this: VALUE_PARAMETER this@C: C
BLOCK_BODY
RETURN type=kotlin.Nothing from='<get-test8>(): Int'
CALL 'getValue(Any?, KProperty<*>) on MutableMap<in String, in Int>: Int' type=kotlin.Int origin=null
CALL 'getValue(Any?, KProperty<*>) on MutableMap<in String, out Int>: Int' type=kotlin.Int origin=null
<V>: Int
<V1 : V>: Int
$receiver: GET_FIELD '`test8$delegate`: HashMap<String, Int> /* = HashMap<String, Int> */' type=kotlin.collections.HashMap<kotlin.String, kotlin.Int> /* = java.util.HashMap<kotlin.String, kotlin.Int> */ origin=null
receiver: GET_VAR 'this@C: C' type=C origin=null
thisRef: GET_VAR 'this@C: C' type=C origin=null
@@ -65,8 +65,9 @@ FILE /delegatedProperties.kt
$this: VALUE_PARAMETER this@C: C
BLOCK_BODY
RETURN type=kotlin.Nothing from='<get-test3>(): Any'
CALL 'getValue(Any?, KProperty<*>) on MutableMap<in String, in Any>: Any' type=kotlin.Any origin=null
CALL 'getValue(Any?, KProperty<*>) on MutableMap<in String, out Any>: Any' type=kotlin.Any origin=null
<V>: Any
<V1 : V>: Any
$receiver: GET_FIELD '`test3$delegate`: MutableMap<String, Any>' type=kotlin.collections.MutableMap<kotlin.String, kotlin.Any> origin=null
receiver: GET_VAR 'this@C: C' type=C origin=null
thisRef: GET_VAR 'this@C: C' type=C origin=null
@@ -99,8 +100,9 @@ FILE /delegatedProperties.kt
FUN DELEGATED_PROPERTY_ACCESSOR public fun <get-test4>(): kotlin.Any
BLOCK_BODY
RETURN type=kotlin.Nothing from='<get-test4>(): Any'
CALL 'getValue(Any?, KProperty<*>) on MutableMap<in String, in Any>: Any' type=kotlin.Any origin=null
CALL 'getValue(Any?, KProperty<*>) on MutableMap<in String, out Any>: Any' type=kotlin.Any origin=null
<V>: Any
<V1 : V>: Any
$receiver: GET_FIELD '`test4$delegate`: HashMap<String, Any> /* = HashMap<String, Any> */' type=kotlin.collections.HashMap<kotlin.String, kotlin.Any> /* = java.util.HashMap<kotlin.String, kotlin.Any> */ origin=null
thisRef: CONST Null type=kotlin.Nothing? value='null'
property: PROPERTY_REFERENCE 'test4: Any' field=null getter='<get-test4>(): Any' setter='<set-test4>(Any): Unit' type=kotlin.reflect.KMutableProperty0<kotlin.Any> origin=PROPERTY_REFERENCE_FOR_DELEGATE
@@ -31,8 +31,9 @@ FILE /localDelegatedProperties.kt
FUN DELEGATED_PROPERTY_ACCESSOR local final fun <get-x>(): kotlin.Int
BLOCK_BODY
RETURN type=kotlin.Nothing from='<get-x>(): Int'
CALL 'getValue(Any?, KProperty<*>) on MutableMap<in String, in Int>: Int' type=kotlin.Int origin=null
CALL 'getValue(Any?, KProperty<*>) on MutableMap<in String, out Int>: Int' type=kotlin.Int origin=null
<V>: Int
<V1 : V>: Int
$receiver: GET_VAR '`x$delegate`: HashMap<String, Int> /* = HashMap<String, Int> */' type=kotlin.collections.HashMap<kotlin.String, kotlin.Int> /* = java.util.HashMap<kotlin.String, kotlin.Int> */ origin=null
thisRef: CONST Null type=kotlin.Nothing? value='null'
property: LOCAL_DELEGATED_PROPERTY_REFERENCE 'x: Int' delegate='`x$delegate`: HashMap<String, Int> /* = HashMap<String, Int> */' getter='<get-x>(): Int' setter='<set-x>(Int): Unit' type=kotlin.reflect.KMutableProperty0<kotlin.Int> origin=PROPERTY_REFERENCE_FOR_DELEGATE
@@ -87,8 +87,9 @@ FILE /packageLevelProperties.kt
FUN DELEGATED_PROPERTY_ACCESSOR public fun <get-test8>(): kotlin.Int
BLOCK_BODY
RETURN type=kotlin.Nothing from='<get-test8>(): Int'
CALL 'getValue(Any?, KProperty<*>) on MutableMap<in String, in Int>: Int' type=kotlin.Int origin=null
CALL 'getValue(Any?, KProperty<*>) on MutableMap<in String, out Int>: Int' type=kotlin.Int origin=null
<V>: Int
<V1 : V>: Int
$receiver: GET_FIELD '`test8$delegate`: HashMap<String, Int> /* = HashMap<String, Int> */' type=kotlin.collections.HashMap<kotlin.String, kotlin.Int> /* = java.util.HashMap<kotlin.String, kotlin.Int> */ origin=null
thisRef: CONST Null type=kotlin.Nothing? value='null'
property: PROPERTY_REFERENCE 'test8: Int' field=null getter='<get-test8>(): Int' setter='<set-test8>(Int): Unit' type=kotlin.reflect.KMutableProperty0<kotlin.Int> origin=PROPERTY_REFERENCE_FOR_DELEGATE