Repository navigation
refactor(dsl): remove Kotlin 2.4's 25 no-op DSL marker annotations - #22
Merged
Merged
Conversation
Kotlin 2.4 warns that @DslMarker annotations on functions and properties have no effect. Drop them from functions whose lambda parameter is already marked, mark KommandSyntaxBuilder itself, and narrow each marker's @target so the no-op placement can't come back. @ItemDsl stays on the ItemStack.Builder properties, with the warning suppressed, since that is the only way IDEs highlight them.
Removes @ItemDsl from the ItemStack.Builder properties along with its warning suppression, and the class-level @KommandDSL on KommandSyntaxBuilder. Every marker now targets TYPE only.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Kotlin 2.4 warns about all 25 of our
@KommandDSL/@ItemDsl/@InstanceDslannotations on functions and properties (KT-81567). A@DslMarkeronly restricts scope when it's on a type, such as the lambda receiver (block: @KommandDSL Kommand.() -> Unit), and those type annotations were already in place. The function and property annotations only fed IntelliJ's DSL coloring, so they can go.@TargettoTYPEfor all four markers (including@EventDSL), so the no-op placement no longer compiles.Trade-off: IntelliJ no longer colors calls that have no marked lambda, such as the
ItemStack.Builderproperties (amount,itemName, …),onlyPlayers()andcondition(). On IntelliJ 2026.2+, calls that take a marked lambda (kommand { },buildSyntax { },item { }, …) are still colored (KTIJ-38335).Scoping is unchanged
I compiled the same scope-escape probe before and after:
item { lore { amount = 3 } }kommand { buildSyntax { subkommand("b") {} } }buildSyntax { executor { _ -> onlyPlayers() } }kommand { defaultExecutor { _ -> subkommand("x") {} } }buildInstance { generator { setGenerator(null) } }Testing
compileKotlin,compileTestKotlinand:example:compileKotlinpass, with zero DSL marker warnings.