Add tests for obsolete issues

#KT-37734 Obsolete
 #KT-39824 Obsolete
This commit is contained in:
Mikhail Zarechenskiy
2020-06-26 06:24:59 +03:00
parent 9844607d0f
commit 684ca5029f
14 changed files with 121 additions and 0 deletions
+33
View File
@@ -0,0 +1,33 @@
// WITH_RUNTIME
fun <C : Any> diContext(context: C): DIContext<C> = DIContext(TypeToken(), context)
fun <C : Any> diContext(getContext: () -> C): DIContext<C> = DIContext<C>(TypeToken()) { getContext() }
interface DIContext<C : Any> {
val type: TypeToken<C>
val value: C
fun print() {
result += value.toString()
}
data class Value<C : Any>(override val type: TypeToken<C>, override val value: C) : DIContext<C>
class Lazy<C : Any>(override val type: TypeToken<C>, public val getValue: () -> C) : DIContext<C> {
override val value: C by lazy(getValue)
}
companion object {
operator fun <C : Any> invoke(type: TypeToken<C>, value: C): DIContext<C> = Value(type, value)
operator fun <C : Any> invoke(type: TypeToken<C>, getValue: () -> C): DIContext<C> = Lazy(type, getValue)
}
}
class TypeToken<T>
var result = ""
fun box(): String {
diContext("O").print()
diContext { "K" }.print()
return result
}
@@ -0,0 +1,17 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER -DEBUG_INFO_CONSTANT -UNUSED_EXPRESSION
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
fun <@kotlin.internal.OnlyInputTypes K, V, V1 : V?>
Map<out K, @kotlin.internal.Exact V>.getOrDefault_Exact(key: K, defaultValue: V1): V1 = TODO()
fun test() {
val map: Map<String, Int> = mapOf("x" to 1)
val r1 = map.getOrDefault_Exact("y", null)
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Nothing?")!>r1<!>
val r2 = map.getOrDefault_Exact("y", null as Int?)
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int?")!>r2<!>
map.getOrDefault_Exact("y", "string")
}
@@ -0,0 +1,17 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER -DEBUG_INFO_CONSTANT -UNUSED_EXPRESSION
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
fun <@kotlin.internal.OnlyInputTypes K, V, V1 : V?>
Map<out K, @kotlin.internal.Exact V>.getOrDefault_Exact(key: K, defaultValue: V1): V1 = TODO()
fun test() {
val map: Map<String, Int> = mapOf("x" to 1)
val r1 = map.getOrDefault_Exact("y", null)
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Nothing?")!>r1<!>
val r2 = map.getOrDefault_Exact("y", null as Int?)
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int?")!>r2<!>
map.getOrDefault_Exact("y", <!TYPE_MISMATCH, TYPE_MISMATCH!>"string"<!>)
}
@@ -0,0 +1,4 @@
package
public fun test(): kotlin.Unit
@kotlin.Suppress(names = {"INVISIBLE_MEMBER", "INVISIBLE_REFERENCE"}) public fun </*0*/ @kotlin.internal.OnlyInputTypes K, /*1*/ V, /*2*/ V1 : V?> kotlin.collections.Map<out K, V>.getOrDefault_Exact(/*0*/ key: K, /*1*/ defaultValue: V1): V1