Skip to content

Support markName #96

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Jun 20, 2025
Merged

Support markName #96

merged 10 commits into from
Jun 20, 2025

Conversation

ForteScarlet
Copy link
Owner

@ForteScarlet ForteScarlet commented Jun 19, 2025

see #95

Adds the property markName to each of the three existing annotations (JvmBlocking, JvmAsync, JsPromise) in the runtime, which, when specified, adds the corresponding annotation (@JvmName, @JsName) to the generated function (or getter of the property).

Warning

Known issues: KT-78473: @JsName does not work for @JsExport with property's getter, This may require waiting for an official Kotlin answer or fix for this issue.

There is no effect on the function, and it works fine.

In addition, the markNameProperty property has been added to the markAnnotation configuration item to allow customization of any behavior related to markName, e.g., by adding @Deprecated("${markName}") or something like that (or maybe you write your own custom annotation?).

For example, the build.gradle.kts:

suspendTransformPlugin {
    transformers {
        // others...
        addJvm {
            // others...
            markAnnotation {
                // others...
                // config your mark name property here
                markNameProperty {
                    propertyName = "markName" // The property name in your mark annotation
                    annotation {
                        packageName = "kotlin"
                        className = "Deprecated"
                        propertyName = "message" // The message in @Deprecated(message = "...")
                    }
                }
            }
        }
    }
}

NOTE: There are some limitations: you can only specify one annotation, and you can only specify one of its string-type parameters.

NOTE: There will be more restrictions in the JVM, such as the compiler warning or rejecting when using @JvmName on a non-final function.

@ForteScarlet ForteScarlet self-assigned this Jun 19, 2025
@ForteScarlet ForteScarlet added the enhancement New feature or request label Jun 19, 2025
@ForteScarlet ForteScarlet requested a review from Copilot June 19, 2025 16:59
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Adds markName support to existing annotations (JvmBlocking, JvmAsync, JsPromise) and enables configuration of a custom name‐marker annotation via the Gradle plugin extension. Key changes include:

  • Extends Kotlin annotation definitions (common, JVM, JS) with a new markName parameter and documentation.
  • Enhances the Gradle plugin DSL to configure markNameProperty and propagate it into generated code.
  • Updates compiler plugin logic (IR, FIR, copy utilities) to carry markName through code generation and testing artifacts, and bumps versions accordingly.

Reviewed Changes

Copilot reviewed 19 out of 25 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/test-js/src/commonMain/kotlin/markname/MarkNameTestInterface.kt Adds JS interface tests for markName support
tests/test-js/src/commonMain/kotlin/markname/MarkNameTestClass.kt Adds JS class tests for markName support
tests/test-js/build.gradle.kts Cleans up commented plugin configuration in JS tests
tests/build.gradle.kts Updates plugin version for tests
runtime/suspend-transform-annotation/src/commonMain/kotlin/.../SuspendTransformAnnotation.kt Adds markName expect property and docs to common annotation defs
runtime/suspend-transform-annotation/src/jvmMain/kotlin/.../SuspendTransformAnnotationJvm.kt Adds markName to JVM annotations with docs
runtime/suspend-transform-annotation/src/jsMain/kotlin/.../SuspendTransformAnnotationJs.kt Adds markName to JS annotations with docs
plugins/suspend-transform-plugin-gradle/.../SuspendTransformPluginExtension.kt Introduces markNameProperty in the Gradle extension DSL
compiler/suspend-transform-plugin/src/main/kotlin/.../CopyAnnotationUtils.kt Extends TransformAnnotationData to include markName
compiler/suspend-transform-plugin/src/main/kotlin/.../SuspendTransformSyntheticResolveExtension.kt Adds logic to copy marker annotations when markName is set
compiler/suspend-transform-plugin/src/main/kotlin/.../SuspendTransformFirTransformer.kt Inserts FIR transformer logic to attach marker annotations
compiler/suspend-transform-plugin-configuration/.../SuspendTransformConfiguration.kt Serializes markNameProperty in configuration and default settings
compiler/suspend-transform-plugin/src/testData/codegen/markName.kt Adds codegen input test for markName
compiler/suspend-transform-plugin/src/testData/codegen/markName.fir.txt Adds expected FIR dump for the new test
compiler/suspend-transform-plugin/src/test/.../AbstractTestRunner.kt Configures JVM artifact handlers to include ASM for new test
compiler/suspend-transform-plugin/src/test-gen/.../CodeGenTestRunnerGenerated.java Adds a generated test runner method for testMarkName
buildSrc/src/main/kotlin/IProject.kt Bumps the plugin version to 0.13.0
Comments suppressed due to low confidence (3)

compiler/suspend-transform-plugin/src/testData/codegen/markName.kt:1

  • Currently we only have a JVM async/blocking codegen test. Consider adding a parallel codegen test for JsPromise(markName = ...) to verify that @JsName is generated correctly in JS output.
// FIR_DUMP

Comment on lines 403 to +404
// TODO What is explicitReceiver?
// this.explicitReceiver
Copy link
Preview

Copilot AI Jun 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Remove or explain this commented placeholder. Leaving it may confuse future maintainers about intended behavior.

Suggested change
// TODO What is explicitReceiver?
// this.explicitReceiver
// TODO Investigate the purpose and usage of explicitReceiver.
// The explicitReceiver might be required for certain function calls or expressions.
// Implementation is pending further clarification of its role in this context.

Copilot uses AI. Check for mistakes.

@ForteScarlet ForteScarlet marked this pull request as draft June 19, 2025 17:01
@ForteScarlet ForteScarlet linked an issue Jun 19, 2025 that may be closed by this pull request
@ForteScarlet ForteScarlet marked this pull request as ready for review June 20, 2025 15:35
@ForteScarlet ForteScarlet merged commit c9ab3b9 into kt-220 Jun 20, 2025
1 check passed
@ForteScarlet ForteScarlet deleted the support-markName branch June 21, 2025 08:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Keep exported js name same as the suspend functions
1 participant