From 093d4b3108a19391770aa3d79781516e7a9bbff9 Mon Sep 17 00:00:00 2001 From: Sergey Igushkin Date: Wed, 5 Aug 2020 20:17:49 +0400 Subject: [PATCH] Revert "Fix typealias usage nullability and annotations lost in deserialization" This reverts commit 070848a1 --- .../annotationOnTypeUseInTypeAlias.kt | 31 ------------------- ...mpileKotlinAgainstKotlinTestGenerated.java | 5 --- ...mpileKotlinAgainstKotlinTestGenerated.java | 5 --- .../deserialization/TypeDeserializer.kt | 8 ++--- 4 files changed, 2 insertions(+), 47 deletions(-) delete mode 100644 compiler/testData/compileKotlinAgainstKotlin/annotationOnTypeUseInTypeAlias.kt diff --git a/compiler/testData/compileKotlinAgainstKotlin/annotationOnTypeUseInTypeAlias.kt b/compiler/testData/compileKotlinAgainstKotlin/annotationOnTypeUseInTypeAlias.kt deleted file mode 100644 index f4d38f6df6e..00000000000 --- a/compiler/testData/compileKotlinAgainstKotlin/annotationOnTypeUseInTypeAlias.kt +++ /dev/null @@ -1,31 +0,0 @@ -// TARGET_BACKEND: JVM -// WITH_REFLECT -// FILE: A.kt -@Target(AnnotationTarget.TYPE) -annotation class Anno(val value: String) - -class Foo - -typealias MyFoo = Foo - -class C(val t: T) - -typealias MyC = C<@Anno("OK") MyFoo?> - -// FILE: B.kt -fun test(myc: MyC) {} - -fun box(): String { - test(C(null)) - - val mycType = ::test.parameters.single().type - val argumentType = mycType.arguments.single().type!! - if (!argumentType.isMarkedNullable) - return "Fail: argument type should be seen as nullable" - - val annotations = argumentType.annotations - if (annotations.toString() != "[@Anno(value=OK)]") - return "Fail: $annotations" - - return "OK" -} \ No newline at end of file diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/CompileKotlinAgainstKotlinTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/CompileKotlinAgainstKotlinTestGenerated.java index c878917801c..10b1492161a 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/CompileKotlinAgainstKotlinTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/CompileKotlinAgainstKotlinTestGenerated.java @@ -38,11 +38,6 @@ public class CompileKotlinAgainstKotlinTestGenerated extends AbstractCompileKotl runTest("compiler/testData/compileKotlinAgainstKotlin/annotationInInterface.kt"); } - @TestMetadata("annotationOnTypeUseInTypeAlias.kt") - public void testAnnotationOnTypeUseInTypeAlias() throws Exception { - runTest("compiler/testData/compileKotlinAgainstKotlin/annotationOnTypeUseInTypeAlias.kt"); - } - @TestMetadata("annotationsOnTypeAliases.kt") public void testAnnotationsOnTypeAliases() throws Exception { runTest("compiler/testData/compileKotlinAgainstKotlin/annotationsOnTypeAliases.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrCompileKotlinAgainstKotlinTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrCompileKotlinAgainstKotlinTestGenerated.java index f16ce86ba6b..b0fe25b73dd 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrCompileKotlinAgainstKotlinTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrCompileKotlinAgainstKotlinTestGenerated.java @@ -38,11 +38,6 @@ public class IrCompileKotlinAgainstKotlinTestGenerated extends AbstractIrCompile runTest("compiler/testData/compileKotlinAgainstKotlin/annotationInInterface.kt"); } - @TestMetadata("annotationOnTypeUseInTypeAlias.kt") - public void testAnnotationOnTypeUseInTypeAlias() throws Exception { - runTest("compiler/testData/compileKotlinAgainstKotlin/annotationOnTypeUseInTypeAlias.kt"); - } - @TestMetadata("annotationsOnTypeAliases.kt") public void testAnnotationsOnTypeAliases() throws Exception { runTest("compiler/testData/compileKotlinAgainstKotlin/annotationsOnTypeAliases.kt"); diff --git a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/TypeDeserializer.kt b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/TypeDeserializer.kt index 1fc591ef9ce..a94b2acc996 100644 --- a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/TypeDeserializer.kt +++ b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/TypeDeserializer.kt @@ -92,12 +92,8 @@ class TypeDeserializer( val declarationDescriptor = constructor.declarationDescriptor val simpleType = when { - expandTypeAliases && declarationDescriptor is TypeAliasDescriptor -> { - val expandedType = with(KotlinTypeFactory) { declarationDescriptor.computeExpandedType(arguments) } - expandedType - .makeNullableAsSpecified(proto.nullable) - .replaceAnnotations(Annotations.create(annotations + expandedType.annotations)) - } + expandTypeAliases && declarationDescriptor is TypeAliasDescriptor -> + with(KotlinTypeFactory) { declarationDescriptor.computeExpandedType(arguments) } Flags.SUSPEND_TYPE.get(proto.flags) -> createSuspendFunctionType(annotations, constructor, arguments, proto.nullable) else ->