Skip to content

Conversation

Seggan
Copy link

@Seggan Seggan commented Sep 24, 2025

Fixes #4279

@Seggan
Copy link
Author

Seggan commented Sep 24, 2025

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>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Default methods in interfaces are backwards in the Javadoc format
1 participant