Skip to content

refactor(dsl): remove Kotlin 2.4's 25 no-op DSL marker annotations - #22

Merged
oglassdev merged 2 commits into
mainfrom
refactor/dsl-marker-placement
Oct 14, 2026
Merged

oglassdev merged 2 commits into
mainfrom
refactor/dsl-marker-placement

Conversation

@oglassdev

@oglassdev oglassdev commented Oct 14, 2026 •

Copy link
Copy Markdown
Owner

Kotlin 2.4 warns about all 25 of our @KommandDSL/@ItemDsl/@InstanceDsl annotations on functions and properties (KT-81567). A @DslMarker only 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.

  • Removed every DSL marker that sits on a function or property.
  • Narrowed @Target to TYPE for 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.Builder properties (amount, itemName, …), onlyPlayers() and condition(). 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:

Code Before After
item { lore { amount = 3 } } blocked blocked
kommand { buildSyntax { subkommand("b") {} } } blocked blocked
buildSyntax { executor { _ -> onlyPlayers() } } blocked blocked
kommand { defaultExecutor { _ -> subkommand("x") {} } } blocked blocked
buildInstance { generator { setGenerator(null) } } compiles compiles (fixed in #23)

Testing

  • compileKotlin, compileTestKotlin and :example:compileKotlin pass, with zero DSL marker warnings.

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.
@oglassdev oglassdev changed the title refactor(dsl): clear Kotlin 2.4's 25 DSL marker warnings without losing IDE colors refactor(dsl): remove Kotlin 2.4's 25 no-op DSL marker annotations Oct 14, 2026
@oglassdev
oglassdev added this pull request to stack #24 October 14, 2026 23:16
@oglassdev
oglassdev merged commit a0cfb34 into main Oct 14, 2026
1 check passed
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.

1 participant