Fix typealias usage nullability and annotations lost in deserialization

Issue #KT-40824 Fixed
This commit is contained in:
Sergey Igushkin
2020-08-05 20:40:28 +04:00
parent 4063aba677
commit f6356199d3
4 changed files with 53 additions and 2 deletions
@@ -0,0 +1,37 @@
// TARGET_BACKEND: JVM
// WITH_REFLECT
// FILE: A.kt
@Target(AnnotationTarget.TYPE)
annotation class Anno(val value: String)
class Foo
typealias MyFoo = Foo
typealias MyMaybeFoo = Foo?
class C<T>(val t: T)
typealias MyCMyFoo = C<@Anno("OK") MyFoo?>
typealias MyCMaybeFoo = C<@Anno("OK") MyMaybeFoo>
// FILE: B.kt
fun testMyFoo(myc: MyCMyFoo) {}
fun testMyMaybeFoo(mycmyb: MyCMaybeFoo) {}
fun box(): String {
testMyFoo(C(null))
testMyMaybeFoo(C(null))
for (fn in listOf(::testMyFoo, ::testMyMaybeFoo)) {
val mycType = fn.parameters.single().type
val argumentType = mycType.arguments.single().type!!
if (!argumentType.isMarkedNullable)
return "Fail on $fn: argument type should be seen as nullable"
val annotations = argumentType.annotations
if (annotations.toString() != "[@Anno(value=OK)]")
return "Fail on $fn: $annotations"
}
return "OK"
}