diff --git a/compiler/testData/diagnostics/tests/annotations/AnnotationForFunctionTypeParameter.txt b/compiler/testData/diagnostics/tests/annotations/AnnotationForFunctionTypeParameter.txt index 105d609e4f0..37d2b034e11 100644 --- a/compiler/testData/diagnostics/tests/annotations/AnnotationForFunctionTypeParameter.txt +++ b/compiler/testData/diagnostics/tests/annotations/AnnotationForFunctionTypeParameter.txt @@ -1,6 +1,6 @@ package -public fun topFun(): kotlin.Int +public fun topFun(): kotlin.Int public final annotation class A1 : kotlin.Annotation { public constructor A1() @@ -22,6 +22,6 @@ public final class SomeClass { public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public final fun foo(): kotlin.Unit public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int - public final fun method(): kotlin.Int + public final fun method(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } diff --git a/compiler/testData/diagnostics/tests/annotations/AnnotationsForPropertyTypeParameter.txt b/compiler/testData/diagnostics/tests/annotations/AnnotationsForPropertyTypeParameter.txt index 5fbd6594f40..fe5d5216e91 100644 --- a/compiler/testData/diagnostics/tests/annotations/AnnotationsForPropertyTypeParameter.txt +++ b/compiler/testData/diagnostics/tests/annotations/AnnotationsForPropertyTypeParameter.txt @@ -1,6 +1,6 @@ package -public val T.topProp: kotlin.Int +public val T.topProp: kotlin.Int public final annotation class A1 : kotlin.Annotation { public constructor A1() @@ -19,7 +19,7 @@ public final annotation class A2 : kotlin.Annotation { public final class SomeClass { public constructor SomeClass() - public final val T.field: kotlin.Int + public final val T.field: kotlin.Int public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public final fun foo(): kotlin.Unit public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/annotations/options/targets/typeParams.txt b/compiler/testData/diagnostics/tests/annotations/options/targets/typeParams.txt index a88825b9315..27eafda3071 100644 --- a/compiler/testData/diagnostics/tests/annotations/options/targets/typeParams.txt +++ b/compiler/testData/diagnostics/tests/annotations/options/targets/typeParams.txt @@ -1,11 +1,11 @@ package -public val T.topProp: kotlin.Int +public val T.topProp: kotlin.Int @A() public fun foo(): kotlin.Unit public fun foo(/*0*/ i: @A() kotlin.Int): kotlin.Unit public fun test(/*0*/ t: @A() T): T -public fun test2(/*0*/ t: T): T -public fun topFun(): kotlin.Int +public fun test2(/*0*/ t: T): T +public fun topFun(): kotlin.Int @kotlin.annotation.Target(allowedTargets = {AnnotationTarget.TYPE_PARAMETER}) public final annotation class A : kotlin.Annotation { public constructor A() @@ -34,13 +34,13 @@ public final class Class1 { public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public final fun foo(): kotlin.Unit public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int - public final fun method(): kotlin.Int + public final fun method(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } public final class Class2 { public constructor Class2() - public final val T.field: kotlin.Int + public final val T.field: kotlin.Int public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesAndLowPriority.txt b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesAndLowPriority.txt index 3fb1589551b..f20f288c78e 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesAndLowPriority.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesAndLowPriority.txt @@ -2,6 +2,6 @@ package public fun test(/*0*/ map: kotlin.collections.Map): kotlin.Unit @kotlin.Suppress(names = {"INVISIBLE_MEMBER", "INVISIBLE_REFERENCE"}) @kotlin.jvm.JvmName(name = "containsAny") @kotlin.internal.LowPriorityInOverloadResolution() public fun kotlin.collections.Iterable.contains1(/*0*/ element: T): kotlin.Int -@kotlin.Suppress(names = {"INVISIBLE_MEMBER", "INVISIBLE_REFERENCE"}) public fun kotlin.collections.Iterable.contains1(/*0*/ element: T): kotlin.Boolean +@kotlin.Suppress(names = {"INVISIBLE_MEMBER", "INVISIBLE_REFERENCE"}) public fun kotlin.collections.Iterable.contains1(/*0*/ element: T): kotlin.Boolean @kotlin.Suppress(names = {"INVISIBLE_MEMBER", "INVISIBLE_REFERENCE"}) @kotlin.jvm.JvmName(name = "getAny") @kotlin.internal.LowPriorityInOverloadResolution() public fun kotlin.collections.Map.get1(/*0*/ key: kotlin.Any?): kotlin.Int -@kotlin.Suppress(names = {"INVISIBLE_MEMBER", "INVISIBLE_REFERENCE"}) public fun kotlin.collections.Map.get1(/*0*/ key: K): V? +@kotlin.Suppress(names = {"INVISIBLE_MEMBER", "INVISIBLE_REFERENCE"}) public fun kotlin.collections.Map.get1(/*0*/ key: K): V? diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesAnnotationWithPlatformTypes.txt b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesAnnotationWithPlatformTypes.txt index f6a9c1b9bdb..89f68cbc0f9 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesAnnotationWithPlatformTypes.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesAnnotationWithPlatformTypes.txt @@ -1,6 +1,6 @@ package -@kotlin.Suppress(names = {"INVISIBLE_MEMBER", "INVISIBLE_REFERENCE"}) public fun assertEquals1(/*0*/ t1: T, /*1*/ t2: T): kotlin.Unit +@kotlin.Suppress(names = {"INVISIBLE_MEMBER", "INVISIBLE_REFERENCE"}) public fun assertEquals1(/*0*/ t1: T, /*1*/ t2: T): kotlin.Unit public fun test(): kotlin.Unit public open class Foo { diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/resolveWithOnlyInputTypesAnnotation.txt b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/resolveWithOnlyInputTypesAnnotation.txt index 325b223d2a9..678e5367136 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/resolveWithOnlyInputTypesAnnotation.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/resolveWithOnlyInputTypesAnnotation.txt @@ -1,7 +1,7 @@ package -@kotlin.Suppress(names = {"INVISIBLE_MEMBER", "INVISIBLE_REFERENCE"}) public fun assertEquals1(/*0*/ t1: T, /*1*/ t2: T): kotlin.Unit -@kotlin.Suppress(names = {"INVISIBLE_MEMBER", "INVISIBLE_REFERENCE"}) public fun expect1(/*0*/ expected: T, /*1*/ block: () -> T): kotlin.Unit +@kotlin.Suppress(names = {"INVISIBLE_MEMBER", "INVISIBLE_REFERENCE"}) public fun assertEquals1(/*0*/ t1: T, /*1*/ t2: T): kotlin.Unit +@kotlin.Suppress(names = {"INVISIBLE_MEMBER", "INVISIBLE_REFERENCE"}) public fun expect1(/*0*/ expected: T, /*1*/ block: () -> T): kotlin.Unit public fun test(): kotlin.Unit public fun test1(/*0*/ a: A, /*1*/ b: B, /*2*/ c: C): kotlin.Unit diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/types/TypeParameterAnnotation.txt b/compiler/testData/loadJava/compiledKotlin/annotations/types/TypeParameterAnnotation.txt index 0b35ce596c4..87d3b45fbb4 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/types/TypeParameterAnnotation.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/types/TypeParameterAnnotation.txt @@ -6,5 +6,5 @@ package test public final class SimpleTypeParameterAnnotation { /*primary*/ public constructor SimpleTypeParameterAnnotation() - public final fun foo(/*0*/ x: T): kotlin.Unit + public final fun foo(/*0*/ x: T): kotlin.Unit } diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/types/TypeParameterAnnotationWithArguments.txt b/compiler/testData/loadJava/compiledKotlin/annotations/types/TypeParameterAnnotationWithArguments.txt index 6c3cc6ec5bf..ceac49b902c 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/types/TypeParameterAnnotationWithArguments.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/types/TypeParameterAnnotationWithArguments.txt @@ -10,5 +10,5 @@ package test public final class SimpleTypeParameterAnnotation { /*primary*/ public constructor SimpleTypeParameterAnnotation() - public final fun foo(/*0*/ x: T): kotlin.Unit + public final fun foo(/*0*/ x: T): kotlin.Unit } diff --git a/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRendererImpl.kt b/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRendererImpl.kt index d415349ff2d..f7eaf27cd89 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRendererImpl.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRendererImpl.kt @@ -250,7 +250,7 @@ internal class DescriptorRendererImpl( private fun renderDefaultType(type: KotlinType): String { val sb = StringBuilder() - renderAnnotations(type, sb, /* needBrackets = */ true) + renderAnnotations(type, sb) if (type.isError) { sb.append(type.constructor.toString()) // Debug name of an error type is more informative @@ -366,7 +366,7 @@ internal class DescriptorRendererImpl( builder.append(if (fqName.isRoot) "root package" else renderFqName(fqName)) } } - private fun renderAnnotations(annotated: Annotated, builder: StringBuilder, needBrackets: Boolean = false) { + private fun renderAnnotations(annotated: Annotated, builder: StringBuilder) { if (DescriptorRendererModifier.ANNOTATIONS !in modifiers) return val excluded = if (annotated is KotlinType) excludedTypeAnnotationClasses else excludedAnnotationClasses @@ -537,6 +537,9 @@ internal class DescriptorRendererImpl( if (!variance.isEmpty()) { builder.append(renderKeyword(variance)).append(" ") } + + renderAnnotations(typeParameter, builder) + renderName(typeParameter, builder) val upperBoundsCount = typeParameter.upperBounds.size if ((upperBoundsCount > 1 && !topLevel) || upperBoundsCount == 1) { @@ -846,7 +849,7 @@ internal class DescriptorRendererImpl( val primaryConstructor = klass.unsubstitutedPrimaryConstructor if (primaryConstructor != null) { builder.append(" ") - renderAnnotations(primaryConstructor, builder, true) + renderAnnotations(primaryConstructor, builder) renderVisibility(primaryConstructor.visibility, builder) builder.append("constructor") renderValueParameters(primaryConstructor.valueParameters, primaryConstructor.hasSynthesizedParameterNames(), builder)