From 70000c87a37caa2a6b518a555f53c98514434403 Mon Sep 17 00:00:00 2001 From: Marcin Aman Date: Fri, 5 Feb 2021 14:55:45 +0100 Subject: Annotations for parameters (#1710) * Annotations for parameters * Annotations for parameters --- .../JavaAnnotationsForParametersTest.kt | 35 ++++++++++++++++++++-- 1 file changed, 32 insertions(+), 3 deletions(-) (limited to 'plugins/base/src/test/kotlin/model/annotations/JavaAnnotationsForParametersTest.kt') diff --git a/plugins/base/src/test/kotlin/model/annotations/JavaAnnotationsForParametersTest.kt b/plugins/base/src/test/kotlin/model/annotations/JavaAnnotationsForParametersTest.kt index 5679010d..9e00fafd 100644 --- a/plugins/base/src/test/kotlin/model/annotations/JavaAnnotationsForParametersTest.kt +++ b/plugins/base/src/test/kotlin/model/annotations/JavaAnnotationsForParametersTest.kt @@ -1,11 +1,10 @@ package model.annotations import org.jetbrains.dokka.links.DRI -import org.jetbrains.dokka.model.Annotations -import org.jetbrains.dokka.model.DClass -import org.jetbrains.dokka.model.DFunction +import org.jetbrains.dokka.model.* import org.junit.jupiter.api.Test import utils.AbstractModelTest +import kotlin.test.Ignore import kotlin.test.assertEquals class JavaAnnotationsForParametersTest : AbstractModelTest("/src/main/kotlin/java/Test.java", "java") { @@ -85,4 +84,34 @@ class JavaAnnotationsForParametersTest : AbstractModelTest("/src/main/kotlin/jav } } } + + @Test + fun `function with generic parameter that has annotated bounds`() { + inlineModelTest( + """ + |@Retention(RetentionPolicy.RUNTIME) + |@Target({ElementType.TYPE_USE}) + |@interface Hello { + | public String bar() default ""; + |} + |class Test { + | public List foo() { + | return null; + | } + |} + """.trimIndent() + ) { + with((this / "java" / "Test").cast()) { + with((this / "foo").cast()) { + val annotations = ((generics.first().bounds.first() as Nullable).inner as GenericTypeConstructor) + .extra[Annotations]?.directAnnotations?.flatMap { it.value } + val driOfHello = DRI("java", "Hello") + val annotationsValues = annotations?.flatMap { it.params.values }?.map { it.toString() }?.toList() + + assertEquals(listOf(driOfHello), annotations?.map { it.dri }) + assertEquals(listOf("baz"), annotationsValues) + } + } + } + } } \ No newline at end of file -- cgit