aboutsummaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/src/main/kotlin/links/DRI.kt4
-rw-r--r--core/src/test/kotlin/basic/DRITest.kt59
2 files changed, 61 insertions, 2 deletions
diff --git a/core/src/main/kotlin/links/DRI.kt b/core/src/main/kotlin/links/DRI.kt
index c13eb04c..b7e5dd1c 100644
--- a/core/src/main/kotlin/links/DRI.kt
+++ b/core/src/main/kotlin/links/DRI.kt
@@ -72,7 +72,7 @@ sealed class TypeReference {
companion object {
fun from(d: ReceiverParameterDescriptor): TypeReference? =
when (d.value) {
- is ExtensionReceiver -> from(d.type)
+ is ExtensionReceiver -> fromPossiblyNullable(d.type)
else -> run {
println("Unknown value type for $d")
null
@@ -80,7 +80,7 @@ sealed class TypeReference {
}
fun from(d: ValueParameterDescriptor): TypeReference? =
- from(d.type)
+ fromPossiblyNullable(d.type)
private fun fromPossiblyNullable(t: KotlinType, self: KotlinType? = null): TypeReference =
from(t, self).let { if (t.isMarkedNullable) Nullable(it) else it }
diff --git a/core/src/test/kotlin/basic/DRITest.kt b/core/src/test/kotlin/basic/DRITest.kt
index f8328e35..93a874ef 100644
--- a/core/src/test/kotlin/basic/DRITest.kt
+++ b/core/src/test/kotlin/basic/DRITest.kt
@@ -40,4 +40,63 @@ class DRITest: AbstractCoreTest() {
}
}
+ @Test
+ fun `#634 with immediate nullable self`() {
+ val configuration = dokkaConfiguration {
+ passes {
+ pass {
+ sourceRoots = listOf("src/")
+ }
+ }
+ }
+
+ testInline(
+ """
+ |/src/main/kotlin/basic/Test.kt
+ |package toplevel
+ |
+ |fun <T : Comparable<T>> Array<T>.doSomething(t: T?): Array<T> = TODO()
+ |}
+ """.trimMargin(),
+ configuration
+ ) {
+ documentablesMergingStage = { module ->
+ val expected = Nullable(TypeParam(listOf(TypeConstructor("kotlin.Comparable", listOf(SelfType)))))
+ val actual = module.packages.single()
+ .functions.single()
+ .dri.callable?.params?.single()
+ assertEquals(expected, actual)
+ }
+ }
+ }
+
+ @Test
+ fun `#634 with generic nullable receiver`() {
+ val configuration = dokkaConfiguration {
+ passes {
+ pass {
+ sourceRoots = listOf("src/")
+ }
+ }
+ }
+
+ testInline(
+ """
+ |/src/main/kotlin/basic/Test.kt
+ |package toplevel
+ |
+ |fun <T : Comparable<T>> T?.doSomethingWithNullable() = TODO()
+ |}
+ """.trimMargin(),
+ configuration
+ ) {
+ documentablesMergingStage = { module ->
+ val expected = Nullable(TypeParam(listOf(TypeConstructor("kotlin.Comparable", listOf(SelfType)))))
+ val actual = module.packages.single()
+ .functions.single()
+ .dri.callable?.receiver
+ assertEquals(expected, actual)
+ }
+ }
+ }
} \ No newline at end of file