KT-89073 [SLC] Preserve @JvmExposeBoxed when no boxed wrapper is generated - #7948
Open
Alexey Belkov (abelkov) wants to merge 9 commits into
Open
KT-89073 [SLC] Preserve @JvmExposeBoxed when no boxed wrapper is generated#7948Alexey Belkov (abelkov) wants to merge 9 commits into
Alexey Belkov (abelkov) wants to merge 9 commits into
Conversation
The JVM backend suite covers several declaration shapes that were absent from symbol light classes. Add explicit and directive cases for large-arity methods and FunctionN, nullable Result bounds, secondary, internal, and default constructors, nullable data-class fields, companion extensions, IntroducedAt constructors, and version overloads. Note: some of this testdata exposes existing bugs: KT-86855, KT-89069, KT-89073.
The JVM backend does not generate a boxed wrapper when an explicitly annotated declaration has no value-class type that needs boxing. Instead, it keeps a single declaration with `@JvmExposeBoxed`. For functions and property accessors, `@JvmName` takes precedence over `@JvmExposeBoxed.jvmName` when both annotations provide a name. This case also arises with `@JvmOverloads`: annotations are copied to generated overloads before value-class lowering, and removing a defaulted value-class parameter can leave an overload with nothing to box. Symbol light classes modeled these declarations as regular methods. They therefore filtered out `@JvmExposeBoxed` and could report a Java name that was absent from bytecode. Introduce `REGULAR`, `BOXED`, and `EXPOSED_AS_IS` light-method kinds. `EXPOSED_AS_IS` uses regular JVM type mapping while retaining both annotations and their naming precedence. Use it for explicitly annotated declarations for which the backend emits no separate boxed wrapper. Apply the same handling to functions, property accessors, and constructors, and update source light-class expectations to match compiled declarations. ^KT-89073 Fixed
When the JVM backend creates a boxed method, it removes `@JvmName`. If `@JvmExposeBoxed` has no explicit name, the backend copies the `@JvmName` value to its `jvmName` argument. The same applies when `@JvmExposeBoxed` is synthesized for a containing class annotation or the compiler option. Symbol light classes already used the correct name for the boxed method, but rendered `@JvmExposeBoxed` without the copied argument. Its annotation therefore differed from the corresponding bytecode declaration. Inspect both annotations before `@JvmName` is filtered from the boxed method. Keep an explicit `@JvmExposeBoxed` name unchanged. Otherwise, use the `@JvmName` argument when creating a synthetic annotation or replacing a bare source annotation. Preserve the Kotlin origin when replacing an annotation. ^KT-89073
Code Owners
PR commands for maintainers
|
Alexey Belkov (abelkov)
requested a review
from Dmitrii Gridin (dimonchik0036)
September 4, 2026 14:10
| arguments = listOfNotNull(exposedName), | ||
| ) | ||
| } else if (exposedName != null) { | ||
| currentRawAnnotations[exposeBoxedAnnotationIndex] = SymbolLightSimpleAnnotation( |
There was a problem hiding this comment.
What's a practical benefit of copying the argument?
The presence of the annotation is a useful sign to understand whether the declaration was generated, but which problem does the argument solve?
The method already has a proper boxed name. The backend can optimize the metadata in the same way by stripping this redundant data
Dmitrii Gridin (dimonchik0036)
self-requested a review
September 4, 2026 18:07
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.
No description provided.