@@ -1098,8 +1098,82 @@ class LinkTest : BaseAbstractTest() {
1098
1098
}
1099
1099
}
1100
1100
1101
+ @Test
1102
+ fun `KDoc link should be unresolved to non-existed property with the name of Kotlin getter #3681` () {
1103
+ testInline(
1104
+ """
1105
+ |/src/main/kotlin/Testing.kt
1106
+ |fun getProperty() = 0
1107
+ |/**
1108
+ |* [property] is unresolved
1109
+ | */
1110
+ |fun usage() = 0
1111
+ |}
1112
+ """ .trimMargin(),
1113
+ configuration
1114
+ ) {
1115
+ documentablesMergingStage = { module ->
1116
+ assertEquals(null , module.getLinkDRIFrom(" usage" ))
1117
+ }
1118
+ }
1119
+ }
1120
+
1121
+ @Test
1122
+ fun `KDoc link should be resolved to two extensions with the same name #3631` () {
1123
+ testInline(
1124
+ """
1125
+ |/src/main/kotlin/Testing.kt
1126
+ |class C
1127
+ |public fun C.ensureActive() {}
1128
+ |/**
1129
+ | * [C.ensureActive]
1130
+ | */
1131
+ |class B
1132
+ |/**
1133
+ | * [C.ensureActive]
1134
+ | */
1135
+ |public fun B.ensureActive() {}
1136
+ """ .trimMargin(),
1137
+ configuration
1138
+ ) {
1139
+ documentablesMergingStage = { module ->
1140
+ val DRItoBensureActive = DRI (
1141
+ " " ,
1142
+ classNames = null ,
1143
+ callable = Callable (
1144
+ name = " ensureActive" ,
1145
+ receiver = TypeConstructor (fullyQualifiedName = " B" , params = emptyList()),
1146
+ params = emptyList()
1147
+ )
1148
+ )
1149
+ val link1 = module.dfs {
1150
+ it.dri == DRItoBensureActive
1151
+ }?.documentation?.values?.single()?.firstMemberOfTypeOrNull<DocumentationLink >()?.dri
1152
+ val link2 = module.getLinkDRIFrom(" B" )
1153
+
1154
+
1155
+ assertEquals(
1156
+ link1,
1157
+ DRI (
1158
+ " " ,
1159
+ classNames = null ,
1160
+ callable = Callable (
1161
+ name = " ensureActive" ,
1162
+ receiver = TypeConstructor (fullyQualifiedName = " C" , params = emptyList()),
1163
+ params = emptyList()
1164
+ )
1165
+ )
1166
+ )
1167
+
1168
+ assertEquals(link1, link2)
1169
+ }
1170
+ }
1171
+ }
1172
+
1101
1173
private fun DModule.getLinkDRIFrom (name : String ): DRI ? {
1102
- val link = this .dfs { it.name == name }?.documentation?.values?.single()?.firstMemberOfTypeOrNull<DocumentationLink >()
1174
+ val doc = this .dfs { it.name == name }?.documentation?.values?.single()
1175
+ ? : throw IllegalStateException (" Can't find documentation for declaration '$name '" )
1176
+ val link = doc.firstMemberOfTypeOrNull<DocumentationLink >()
1103
1177
return link?.dri
1104
1178
}
1105
1179
0 commit comments