Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix arg name inside functional type #2478

Merged
merged 2 commits into from Apr 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -387,13 +387,14 @@ class KotlinSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLog
) {
return when (p) {
is TypeParameter -> {
if (p.presentableName != null) {
text(p.presentableName!!)
operator(": ")
}
annotationsInline(p)
link(p.name, p.dri)
}
is FunctionalTypeConstructor -> {
annotationsInline(p)
+funType(mainDRI.single(), mainSourcesetData, p)
}
is FunctionalTypeConstructor -> +funType(mainDRI.single(), mainSourcesetData, p)
is GenericTypeConstructor ->
group(styles = emptySet()) {
val linkText = if (showFullyQualifiedName && p.dri.packageName != null) {
Expand Down Expand Up @@ -443,6 +444,7 @@ class KotlinSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLog
text(type.presentableName!!)
operator(": ")
}
annotationsInline(type)
if (type.isSuspendable) keyword("suspend ")

if (type.isExtensionFunction) {
Expand Down
Expand Up @@ -108,6 +108,31 @@ class FunctionalTypeConstructorsSignatureTest : BaseAbstractTest() {
}
}

@Test
fun `kotlin syntactic sugar function with param name of generic and functional type`() {
val source = source("""
| @Target(AnnotationTarget.VALUE_PARAMETER, AnnotationTarget.TYPE)
| @MustBeDocumented
| annotation class Fancy
|
| fun <T> f(): (param1: T, param2: @Fancy ()->Unit) -> String "
""".trimIndent())
val writerPlugin = TestOutputWriterPlugin()

testInline(
source, configuration, pluginOverrides = listOf(writerPlugin)
) {
renderingStage = { _, _ ->
writerPlugin.writer.renderedContent("root/example/index.html").lastSignature().match(
"fun <", A("T"), "> ",
A("f"), "(): (param1:", A("T"),
", param2: ", Span("@", A("Fancy")), " () -> ", A("Unit"),
") -> ", A("String"), Span(),
ignoreSpanWithTokenStyle = true
)
}
}
}
@Disabled // Add coroutines on classpath and get proper import
@Test
fun `kotlin normal suspendable function`() {
Expand Down