aboutsummaryrefslogtreecommitdiff
path: root/plugins/kotlin-as-java
diff options
context:
space:
mode:
authorAndrzej Ratajczak <andrzej.ratajczak98@gmail.com>2020-09-17 13:35:13 +0200
committerPaweł Marks <Kordyjan@users.noreply.github.com>2020-09-28 17:22:14 +0200
commit64ec7ad22e9541b639e854aa413a2cffd650e8d0 (patch)
tree42106fc356b23ce1a3c394deccb59e74d80ff0f0 /plugins/kotlin-as-java
parent2274d9261a59570cc3a1a26c3f7ddc167678fe8b (diff)
downloaddokka-64ec7ad22e9541b639e854aa413a2cffd650e8d0.tar.gz
dokka-64ec7ad22e9541b639e854aa413a2cffd650e8d0.tar.bz2
dokka-64ec7ad22e9541b639e854aa413a2cffd650e8d0.zip
Add better handling of functional types in rendered output
Diffstat (limited to 'plugins/kotlin-as-java')
-rw-r--r--plugins/kotlin-as-java/src/main/kotlin/converters/KotlinToJavaConverter.kt13
1 files changed, 10 insertions, 3 deletions
diff --git a/plugins/kotlin-as-java/src/main/kotlin/converters/KotlinToJavaConverter.kt b/plugins/kotlin-as-java/src/main/kotlin/converters/KotlinToJavaConverter.kt
index 5a9f0855..5112ae0b 100644
--- a/plugins/kotlin-as-java/src/main/kotlin/converters/KotlinToJavaConverter.kt
+++ b/plugins/kotlin-as-java/src/main/kotlin/converters/KotlinToJavaConverter.kt
@@ -188,7 +188,11 @@ private fun Projection.asJava(): Projection = when(this) {
private fun Bound.asJava(): Bound = when(this) {
is TypeParameter -> copy(dri.possiblyAsJava())
- is TypeConstructor -> copy(
+ is GenericTypeConstructor -> copy(
+ dri = dri.possiblyAsJava(),
+ projections = projections.map { it.asJava() }
+ )
+ is FunctionalTypeConstructor -> copy(
dri = dri.possiblyAsJava(),
projections = projections.map { it.asJava() }
)
@@ -229,7 +233,7 @@ internal fun DObject.asJava(): DObject = copy(
visibility = sourceSets.map {
it to JavaVisibility.Public
}.toMap(),
- type = TypeConstructor(dri, emptyList()),
+ type = GenericTypeConstructor(dri, emptyList()),
setter = null,
getter = null,
sourceSets = sourceSets,
@@ -276,7 +280,10 @@ internal fun String.getAsPrimitive(): JvmPrimitiveType? = org.jetbrains.kotlin.b
private fun DRI.partialFqName() = packageName?.let { "$it." } + classNames
private fun DRI.possiblyAsJava() = this.partialFqName().mapToJava()?.toDRI(this) ?: this
-private fun TypeConstructor.possiblyAsJava() = copy(dri = this.dri.possiblyAsJava())
+private fun TypeConstructor.possiblyAsJava() = when(this) {
+ is GenericTypeConstructor -> copy(dri = this.dri.possiblyAsJava())
+ is FunctionalTypeConstructor -> copy(dri = this.dri.possiblyAsJava())
+}
private fun String.mapToJava(): ClassId? =
JavaToKotlinClassMap.mapKotlinToJava(FqName(this).toUnsafe())