fix: sanitize ':' in internal-name module suffix so KSP 2.3.9 works with Kotlin 2.4.0 default module names#2981
Open
mvanhorn wants to merge 2 commits into
Open
Conversation
…ith Kotlin 2.4.0 default module names Fixes google#2964
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.
Summary
KSP's
internal-member name mangling now sanitizes the module-name suffix the same way the Kotlin compiler does, instead of replacing only.and-. Kotlin 2.4.0's consistent${project.group}:${project.name}default module names inject a literal:into the mangled JVM name, and downstream processors that build generated class names from KSP's reported JVM name fail withCan't escape identifier ... because it contains illegal characters: :(the Dagger/Hilt report in #2964).Why this matters
KSP's reported JVM names need to agree byte-for-byte with what kotlinc actually emits. The compiler already solved the analogous problem for
.kotlin_modulefiles (KT-69701) withNameUtils.sanitizeAsJavaIdentifier;toSuffixinkotlin-analysis-api/.../util.ktnow applies the same sanitization, covering both theKaSourceModuleandKaLibraryModulebranches. The workarounds in the issue thread (dropinternal, overridemoduleName) stop being necessary.Testing
mangledNames.kttest data now covers a module name carrying:and other non-identifier characters. The colon-bearing compiler module name is passed through a test-harness hook (AbstractKSPAATest) rather than the test module directory name, so the Windows CI leg, where:is illegal in path components, is unaffected.Fixes #2964