Skip to content

Fix backwards interface method modifiers - #4280

Open
Seggan wants to merge 1 commit into
Kotlin:masterfrom
pylonmc:fix/backwards-interface-methods
Open

Fix backwards interface method modifiers#4280
Seggan wants to merge 1 commit into
Kotlin:masterfrom
pylonmc:fix/backwards-interface-methods

Conversation

@Seggan

@Seggan Seggan commented Sep 24, 2025

Copy link
Copy Markdown

Fixes #4279

@Seggan

Seggan commented Sep 24, 2025

Copy link
Copy Markdown
Author

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