dokka icon indicating copy to clipboard operation
dokka copied to clipboard

Fix backwards interface method modifiers

Open Seggan opened this issue 3 months ago • 1 comments

Fixes #4279

Seggan avatar Sep 24 '25 20:09 Seggan

I cannot figure out how to write the test as

    @Test
    fun `interface methods should have default when needed`() {
        val source = source(
            """
            interface A {
                fun b() {}
                fun c()
            }
            """
        )
        val writerPlugin = TestOutputWriterPlugin()

        testInline(
            source,
            configuration,
            pluginOverrides = listOf(writerPlugin)
        ) {
            renderingStage = { _, _ ->
                val signatures = writerPlugin.writer
                    .renderedContent("root/kotlinAsJavaPlugin/-a/index.html")
                    .signature()

                val methodWithBody = signatures[1]
                methodWithBody.match(
                    "public default ", A("Unit"), A("b"), "()"
                )

                val methodWithoutBody = signatures[2]
                methodWithoutBody.match(
                    "public ", A("Unit"), A("c"), "()"
                )
            }
        }
    }

just throws "public default " expected but found: <a href="https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html">Unit</a>

Seggan avatar Sep 24 '25 20:09 Seggan