diff --git a/compiler/testData/compileJavaAgainstKotlin/callableReference/GenericSignature.txt b/compiler/testData/compileJavaAgainstKotlin/callableReference/GenericSignature.txt index fac461bc655..0b88e7f7518 100644 --- a/compiler/testData/compileJavaAgainstKotlin/callableReference/GenericSignature.txt +++ b/compiler/testData/compileJavaAgainstKotlin/callableReference/GenericSignature.txt @@ -7,7 +7,7 @@ public/*package*/ open class Bar : test.Foo { public open class Foo { public constructor Foo() - public open fun request(): kotlin.reflect.KFunction1<@kotlin.ParameterName(name = "id") kotlin.Long, test.Request> + public open fun request(): kotlin.reflect.KFunction1 } public final class Request { diff --git a/compiler/testData/diagnostics/tests/callableReference/function/annotationClassConstructor.txt b/compiler/testData/diagnostics/tests/callableReference/function/annotationClassConstructor.txt index a7768c7e259..4dfffcc7cae 100644 --- a/compiler/testData/diagnostics/tests/callableReference/function/annotationClassConstructor.txt +++ b/compiler/testData/diagnostics/tests/callableReference/function/annotationClassConstructor.txt @@ -1,7 +1,7 @@ package public val annClassRef: kotlin.reflect.KClass -public val annCtorRef: kotlin.reflect.KFunction1<@kotlin.ParameterName(name = "prop") kotlin.String, Ann> +public val annCtorRef: kotlin.reflect.KFunction1 public val annPropRef: kotlin.reflect.KProperty1 public final annotation class Ann : kotlin.Annotation { diff --git a/compiler/testData/diagnostics/tests/callableReference/sam.txt b/compiler/testData/diagnostics/tests/callableReference/sam.txt index 01c40b03a16..004a7758e30 100644 --- a/compiler/testData/diagnostics/tests/callableReference/sam.txt +++ b/compiler/testData/diagnostics/tests/callableReference/sam.txt @@ -5,17 +5,17 @@ public fun f2(): kotlin.reflect.KFunction1 public fun f3(): kotlin.reflect.KClass public fun f4(): kotlin.reflect.KFunction1 public fun f5(): kotlin.reflect.KClass> -public fun f6(): kotlin.reflect.KFunction2, @kotlin.ParameterName(name = "t") kotlin.Nothing!, kotlin.Unit> +public fun f6(): kotlin.reflect.KFunction2, kotlin.Nothing!, kotlin.Unit> public fun f7(): kotlin.reflect.KClass> -public fun f8(): kotlin.reflect.KFunction2, @kotlin.ParameterName(name = "t") kotlin.String!, kotlin.Unit> +public fun f8(): kotlin.reflect.KFunction2, kotlin.String!, kotlin.Unit> public fun g1(): kotlin.reflect.KClass public fun g2(): kotlin.reflect.KFunction0 public fun g3(): kotlin.reflect.KClass public fun g4(): kotlin.reflect.KFunction0 public fun g5(): kotlin.reflect.KClass> -public fun g6(): kotlin.reflect.KFunction1<@kotlin.ParameterName(name = "t") kotlin.String!, kotlin.Unit> +public fun g6(): kotlin.reflect.KFunction1 public fun g7(): kotlin.reflect.KClass> -public fun g8(): kotlin.reflect.KFunction1<@kotlin.ParameterName(name = "t") kotlin.String!, kotlin.Unit> +public fun g8(): kotlin.reflect.KFunction1 package test { diff --git a/compiler/testData/diagnostics/tests/deprecated/functionUsage.txt b/compiler/testData/diagnostics/tests/deprecated/functionUsage.txt index 1c23d355d75..eb7421ac0f4 100644 --- a/compiler/testData/diagnostics/tests/deprecated/functionUsage.txt +++ b/compiler/testData/diagnostics/tests/deprecated/functionUsage.txt @@ -4,7 +4,7 @@ package public fun block(): kotlin.Unit public fun expression(): UsefulClass public fun invoker(): kotlin.Unit -public fun reflection(): kotlin.reflect.KFunction1<@kotlin.ParameterName(name = "param") kotlin.Int, UsefulClass> +public fun reflection(): kotlin.reflect.KFunction1 public fun reflection2(): kotlin.reflect.KFunction1 @kotlin.Deprecated(message = "does nothing good") public fun kotlin.Any.doNothing(): kotlin.String diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/50.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/50.kt index 5c3a9b63269..e3d4e60baa3 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/50.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/50.kt @@ -95,9 +95,9 @@ fun Inv.case_7() { // TESTCASE NUMBER: 8 fun T.case_8() { this as MutableList - ")!>this::equals + ")!>this::equals this.equals(10) - ")!>::equals + ")!>::equals equals(10) } diff --git a/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRendererImpl.kt b/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRendererImpl.kt index 8c19a076b4f..e6629fc3f1c 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRendererImpl.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRendererImpl.kt @@ -41,10 +41,6 @@ internal class DescriptorRendererImpl( } as DescriptorRendererImpl } - private val functionTypeParameterTypesRenderer: DescriptorRenderer by lazy { - withOptions { excludedTypeAnnotationClasses += listOf(KotlinBuiltIns.FQ_NAMES.parameterName) } - } - /* FORMATTING */ private fun renderKeyword(keyword: String): String = when (textFormat) { RenderingFormat.PLAIN -> keyword @@ -365,7 +361,7 @@ internal class DescriptorRendererImpl( append(": ") } - append(functionTypeParameterTypesRenderer.renderTypeProjection(typeProjection)) + append(renderTypeProjection(typeProjection)) } append(") ").append(arrow()).append(" ") @@ -413,7 +409,10 @@ internal class DescriptorRendererImpl( val annotationFilter = annotationFilter for (annotation in annotated.annotations) { - if (annotation.fqName !in excluded && (annotationFilter == null || annotationFilter(annotation))) { + if (annotation.fqName !in excluded + && !annotation.isParameterName() + && (annotationFilter == null || annotationFilter(annotation)) + ) { append(renderAnnotation(annotation, target)) if (eachAnnotationOnNewLine) { appendln() @@ -424,6 +423,10 @@ internal class DescriptorRendererImpl( } } + private fun AnnotationDescriptor.isParameterName(): Boolean { + return fqName == KotlinBuiltIns.FQ_NAMES.parameterName + } + override fun renderAnnotation(annotation: AnnotationDescriptor, target: AnnotationUseSiteTarget?): String { return buildString { append('@') diff --git a/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRendererOptionsImpl.kt b/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRendererOptionsImpl.kt index 9938968baee..fce2e7c04ae 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRendererOptionsImpl.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRendererOptionsImpl.kt @@ -16,6 +16,7 @@ package org.jetbrains.kotlin.renderer +import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor import org.jetbrains.kotlin.name.FqName diff --git a/idea/testData/decompiler/decompiledTextJvm/ParameterName.expected.kt b/idea/testData/decompiler/decompiledTextJvm/ParameterName.expected.kt new file mode 100644 index 00000000000..29b6dd32516 --- /dev/null +++ b/idea/testData/decompiler/decompiledTextJvm/ParameterName.expected.kt @@ -0,0 +1,6 @@ +// IntelliJ API Decompiler stub source generated from a class file +// Implementation of methods is not available + +package test + +public inline fun test.Foo.Companion.foo(crossinline block: test.Context.(A, B) -> D): kotlin.Unit { /* compiled code */ } diff --git a/idea/testData/decompiler/decompiledTextJvm/ParameterName/Test.kt b/idea/testData/decompiler/decompiledTextJvm/ParameterName/Test.kt new file mode 100644 index 00000000000..d9d8170925d --- /dev/null +++ b/idea/testData/decompiler/decompiledTextJvm/ParameterName/Test.kt @@ -0,0 +1,10 @@ +@file:JvmName("ParameterName") +package test + +class Foo { + companion object +} + +class Context + +inline fun Foo.Companion.foo(crossinline block: Context.(input: A, state: B) -> D) {} \ No newline at end of file diff --git a/idea/testData/intentions/movePropertyToConstructor/functionReference.kt.after b/idea/testData/intentions/movePropertyToConstructor/functionReference.kt.after index 391688c3dbb..86f19cf261e 100644 --- a/idea/testData/intentions/movePropertyToConstructor/functionReference.kt.after +++ b/idea/testData/intentions/movePropertyToConstructor/functionReference.kt.after @@ -6,9 +6,5 @@ fun foo(a: Int, b: String, d: Baz) { } -class TestClass( - val prop1: KFunction3<@ParameterName(name = "a") Int, @ParameterName(name = "b") String, @ParameterName( - name = "d" - ) Baz, Unit> = ::foo -) { +class TestClass(val prop1: KFunction3 = ::foo) { } \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/decompiler/textBuilder/JvmDecompiledTextTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/decompiler/textBuilder/JvmDecompiledTextTestGenerated.java index 010e6720afa..6b319edd3fe 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/decompiler/textBuilder/JvmDecompiledTextTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/decompiler/textBuilder/JvmDecompiledTextTestGenerated.java @@ -48,6 +48,11 @@ public class JvmDecompiledTextTestGenerated extends AbstractJvmDecompiledTextTes runTest("idea/testData/decompiler/decompiledTextJvm/PackageWithQuotes/"); } + @TestMetadata("ParameterName") + public void testParameterName() throws Exception { + runTest("idea/testData/decompiler/decompiledTextJvm/ParameterName/"); + } + @TestMetadata("TestKt") public void testTestKt() throws Exception { runTest("idea/testData/decompiler/decompiledTextJvm/TestKt/"); @@ -110,6 +115,19 @@ public class JvmDecompiledTextTestGenerated extends AbstractJvmDecompiledTextTes } } + @TestMetadata("idea/testData/decompiler/decompiledTextJvm/ParameterName") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ParameterName extends AbstractJvmDecompiledTextTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInParameterName() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/testData/decompiler/decompiledTextJvm/ParameterName"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + @TestMetadata("idea/testData/decompiler/decompiledTextJvm/TestKt") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class)