Skip to content

[kotlin] Fix #6648: Multi-dollar interpolation for regular strings#6653

Merged
adangel merged 2 commits into
pmd:mainfrom
stokpop:issue-6648-multi-dollar-interpolation-part-2-v2
May 8, 2026
Merged

[kotlin] Fix #6648: Multi-dollar interpolation for regular strings#6653
adangel merged 2 commits into
pmd:mainfrom
stokpop:issue-6648-multi-dollar-interpolation-part-2-v2

Conversation

@stokpop
Copy link
Copy Markdown
Contributor

@stokpop stokpop commented May 7, 2026

Kotlin 2.2 introduces multi-dollar string interpolation: a string prefixed with N dollar signs requires N dollars to start an interpolation sequence (e.g. $$"..." needs $$ for interpolation).

Three grammar issues are fixed:

  • Inside mode lacked MultiDollarPrefix, causing parse errors in function and annotation arguments
  • LineString mode did not check multiLineMinDollars when matching LineStrRef and LineStrExprStart tokens
  • lineStringLiteral parser rule was missing MultiDollarPrefix

Tests added:

  • Regression tests for the two reported cases (function arg, annotation arg)
  • KEEP-375 spec examples as parser smoke tests
  • Tree dump test for LineStrRef and LineStrExprStart in multi-dollar context (moved to KotlinParserMultiLineStringTest)

Spec: https://github.com/Kotlin/KEEP/blob/main/proposals/KEEP-0375-dollar-escape.md

Related issues

Ready?

  • Added unit tests for fixed bug/feature
  • Passing all unit tests
  • Complete build ./mvnw clean verify passes (checked automatically by github actions)
  • Added (in-code) documentation (if needed)

stokpop added 2 commits May 7, 2026 14:18
…ue 6648)

Kotlin 2.2 introduces multi-dollar string interpolation: a string
prefixed with N dollar signs requires N dollars to start an
interpolation sequence (e.g. $$"..." needs $$ for interpolation).

Three grammar issues are fixed:
- Inside mode lacked MultiDollarPrefix, causing parse errors in
  function and annotation arguments
- LineString mode did not check multiLineMinDollars when matching
  LineStrRef and LineStrExprStart tokens
- lineStringLiteral parser rule was missing MultiDollarPrefix

Tests added:
- Regression tests for the two reported cases (function arg,
  annotation arg)
- KEEP-375 spec examples as parser smoke tests
- Tree dump test for LineStrRef and LineStrExprStart in multi-dollar
  context (moved to KotlinParserMultiLineStringTest)

References: pmd#6648
Spec: https://github.com/Kotlin/KEEP/blob/main/proposals/KEEP-0375-dollar-escape.md
@pmd-actions-helper
Copy link
Copy Markdown
Contributor

Documentation Preview

Compared to main:
This changeset changes 0 violations,
introduces 0 new violations, 0 new errors and 0 new configuration errors,
removes 0 violations, 15 errors and 9 configuration errors.
There are 0 changed duplications, 0 new duplications and 0 removed duplications.
There are 0 changed CPD errors, 0 new CPD errors and 0 removed CPD errors.

Regression Tester Report

(comment created at 2026-05-07 15:02:28+00:00 for decb6f6)

@adangel adangel changed the title [kotlin] multi-dollar interpolation for regular strings [kotlin] Multi-dollar interpolation for regular strings May 8, 2026
Copy link
Copy Markdown
Member

@adangel adangel left a comment

Choose a reason for hiding this comment

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

Thanks!


@Test
void multiDollarLineStringInFunctionArg() {
assertDoesNotThrow(() -> KotlinParsingHelper.DEFAULT.parse(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I guess assertDoesNotThrow only makes sense, when #6650 is merged...

@adangel adangel added this to the 7.25.0 milestone May 8, 2026
@adangel adangel added the in:grammar About the grammar of a lexer or parser, eg, a parse/lex exception label May 8, 2026
@adangel adangel changed the title [kotlin] Multi-dollar interpolation for regular strings [kotlin] Fix #6648: Multi-dollar interpolation for regular strings May 8, 2026
adangel added a commit that referenced this pull request May 8, 2026
@adangel adangel merged commit decb6f6 into pmd:main May 8, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

in:grammar About the grammar of a lexer or parser, eg, a parse/lex exception

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[kotlin] Multi-dollar interpolation parse error in annotations

2 participants