From 7d4a734791a9a5fd82e7280e0815003a0e8fbccf Mon Sep 17 00:00:00 2001 From: Mikhael Bogdanov Date: Tue, 22 Sep 2020 11:44:58 +0200 Subject: [PATCH] Fix nullability of `typePath` parameter #KT-41484 Fixed --- .../codegen/inline/MethodBodyVisitor.kt | 2 +- .../ir/FirBlackBoxCodegenTestGenerated.java | 5 +++ .../annotations/typeAnnotations/kt41484.kt | 44 +++++++++++++++++++ .../codegen/BlackBoxCodegenTestGenerated.java | 5 +++ .../LightAnalysisModeTestGenerated.java | 5 +++ .../ir/IrBlackBoxCodegenTestGenerated.java | 5 +++ 6 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 compiler/testData/codegen/box/annotations/typeAnnotations/kt41484.kt diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/MethodBodyVisitor.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/MethodBodyVisitor.kt index f81ab391463..8ff2d8cd4c6 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/MethodBodyVisitor.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/MethodBodyVisitor.kt @@ -37,7 +37,7 @@ open class MethodBodyVisitor(mv: MethodVisitor) : MethodVisitor(Opcodes.API_VERS override fun visitAnnotation(desc: String, visible: Boolean): AnnotationVisitor? = null - override fun visitTypeAnnotation(typeRef: Int, typePath: TypePath, desc: String, visible: Boolean): AnnotationVisitor? = null + override fun visitTypeAnnotation(typeRef: Int, typePath: TypePath?, desc: String, visible: Boolean): AnnotationVisitor? = null override fun visitParameterAnnotation(parameter: Int, desc: String, visible: Boolean): AnnotationVisitor? = null diff --git a/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/codegen/ir/FirBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/codegen/ir/FirBlackBoxCodegenTestGenerated.java index 3a09ae2af5a..b009d059c93 100644 --- a/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/codegen/ir/FirBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/codegen/ir/FirBlackBoxCodegenTestGenerated.java @@ -276,6 +276,11 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/annotations/typeAnnotations/implicitReturn.kt"); } + @TestMetadata("kt41484.kt") + public void testKt41484() throws Exception { + runTest("compiler/testData/codegen/box/annotations/typeAnnotations/kt41484.kt"); + } + @TestMetadata("methodParameters.kt") public void testMethodParameters() throws Exception { runTest("compiler/testData/codegen/box/annotations/typeAnnotations/methodParameters.kt"); diff --git a/compiler/testData/codegen/box/annotations/typeAnnotations/kt41484.kt b/compiler/testData/codegen/box/annotations/typeAnnotations/kt41484.kt new file mode 100644 index 00000000000..c21ac1949ec --- /dev/null +++ b/compiler/testData/codegen/box/annotations/typeAnnotations/kt41484.kt @@ -0,0 +1,44 @@ +// KOTLIN_CONFIGURATION_FLAGS: +JVM.EMIT_JVM_TYPE_ANNOTATIONS +// TARGET_BACKEND: JVM +// IGNORE_BACKEND_FIR: JVM_IR +// JVM_TARGET: 1.8 +// FULL_JDK + +// FILE: Single.java + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +public class Single { + + public T value; + + public Single(T value) + { + this.value = value; + } + + @Retention(RetentionPolicy.RUNTIME) + @Target({ ElementType.TYPE_USE, ElementType.TYPE }) + public @ interface NonNull {} + + @NonNull + public static <@NonNull T> Single just(T item) + { + return new Single (item); + } +} + + +// FILE: Kotlin.kt + +public inline fun myfold(initial: T, operation: (T) -> T): T { + return operation(initial) +} + +fun box(): String { + return (myfold(Single.just("O")) { Single.just(it.value + "K") }).value +} + diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java index 1a1aa21a4ed..11e9373c9f7 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java @@ -276,6 +276,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/annotations/typeAnnotations/implicitReturn.kt"); } + @TestMetadata("kt41484.kt") + public void testKt41484() throws Exception { + runTest("compiler/testData/codegen/box/annotations/typeAnnotations/kt41484.kt"); + } + @TestMetadata("methodParameters.kt") public void testMethodParameters() throws Exception { runTest("compiler/testData/codegen/box/annotations/typeAnnotations/methodParameters.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index 7960aa17362..113a626c5b4 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -276,6 +276,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/annotations/typeAnnotations/implicitReturn.kt"); } + @TestMetadata("kt41484.kt") + public void testKt41484() throws Exception { + runTest("compiler/testData/codegen/box/annotations/typeAnnotations/kt41484.kt"); + } + @TestMetadata("methodParameters.kt") public void testMethodParameters() throws Exception { runTest("compiler/testData/codegen/box/annotations/typeAnnotations/methodParameters.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java index 2d975618681..dc6096e2dc8 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java @@ -276,6 +276,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/annotations/typeAnnotations/implicitReturn.kt"); } + @TestMetadata("kt41484.kt") + public void testKt41484() throws Exception { + runTest("compiler/testData/codegen/box/annotations/typeAnnotations/kt41484.kt"); + } + @TestMetadata("methodParameters.kt") public void testMethodParameters() throws Exception { runTest("compiler/testData/codegen/box/annotations/typeAnnotations/methodParameters.kt");