Skip to content

Add failing test for source order of nested lib class declarations - #3281

Open
SinArc163 wants to merge 1 commit into
google:mainfrom
SinArc163:declaration-source-order-test
Open

SinArc163 wants to merge 1 commit into
google:mainfrom
SinArc163:declaration-source-order-test

Conversation

@SinArc163

Copy link
Copy Markdown

Test-only PR for #2617, following the bug contribution workflow from CONTRIBUTING.md (failing test first, fix in a follow-up).

getDeclarationsInSourceOrder sorts KOTLIN_LIB members against the member order recorded in the container's class file. When the container is a class nested inside another class the wrong class file gets used, so for example an annotation class declared inside an object comes back as [<init>, b, a, c] instead of [a, b, c, <init>], while a top-level annotation class right next to it is ordered correctly.

The new test data declares a top-level annotation class and one nested inside an object in a lib module, plus copies in the source module for comparison, and the suite entry uses runFailingTest so it passes while the bug is present.

Happy to reshape the test if there's a preferred way to cover this.

getDeclarationsInSourceOrder restores source order for KOTLIN_LIB
containers by matching members against the container's class file.
For classes nested inside another class, the resolved class file is
the outermost enclosing class's, so the ordering comes out wrong.
Reproduces google#2617.
@google-cla

google-cla Bot commented Oct 27, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@SinArc163

Copy link
Copy Markdown
Author

CLA signed.

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