aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Kotlin/DocumentationBuilder.kt9
-rw-r--r--test/data/classes/notOpenClass.kt7
-rw-r--r--test/src/model/ClassTest.kt10
3 files changed, 25 insertions, 1 deletions
diff --git a/src/Kotlin/DocumentationBuilder.kt b/src/Kotlin/DocumentationBuilder.kt
index 40c6d745..892a462e 100644
--- a/src/Kotlin/DocumentationBuilder.kt
+++ b/src/Kotlin/DocumentationBuilder.kt
@@ -71,7 +71,14 @@ class DocumentationBuilder(val session: ResolveSession, val options: Documentati
}
fun DocumentationNode.appendModality(descriptor: MemberDescriptor) {
- val modifier = descriptor.getModality().name().toLowerCase()
+ var modality = descriptor.getModality()
+ if (modality == Modality.OPEN) {
+ val containingClass = descriptor.getContainingDeclaration() as? ClassDescriptor
+ if (containingClass?.getModality() == Modality.FINAL) {
+ modality = Modality.FINAL
+ }
+ }
+ val modifier = modality.name().toLowerCase()
val node = DocumentationNode(modifier, Content.Empty, DocumentationNode.Kind.Modifier)
append(node, DocumentationReference.Kind.Detail)
}
diff --git a/test/data/classes/notOpenClass.kt b/test/data/classes/notOpenClass.kt
new file mode 100644
index 00000000..edee2c1a
--- /dev/null
+++ b/test/data/classes/notOpenClass.kt
@@ -0,0 +1,7 @@
+open class C() {
+ open fun f() {}
+}
+
+class D() : C() {
+ override fun f() {}
+}
diff --git a/test/src/model/ClassTest.kt b/test/src/model/ClassTest.kt
index f21c5c57..61bc68bd 100644
--- a/test/src/model/ClassTest.kt
+++ b/test/src/model/ClassTest.kt
@@ -222,4 +222,14 @@ public class ClassTest {
}
}
}
+
+ Test fun notOpenClass() {
+ verifyModel("test/data/classes/notOpenClass.kt") { model ->
+ with(model.members.single().members.first { it.name == "D"}.members.first { it.name == "f" }) {
+ val modifiers = details(DocumentationNode.Kind.Modifier)
+ assertEquals(2, modifiers.size())
+ assertEquals("final", modifiers[1].name)
+ }
+ }
+ }
}