Skip to content

Conversation

@marcphilipp
Copy link
Member

Prior to this commit, all methods of a potential test class were
checked for being test methods, including synthetic ones. However, when
resolving a test class only non-synthetic methods were taken into
account.

Since the Kotlin compiler generates a synthetic, static method suffixed
with $suspendImpl for every open (i.e. non-final) method and copies
its annotations, such methods were included in the check.

In addition to filtering out synthetic methods from being checked,
KotlinReflectionUtils no longer recognizes them as suspend functions.

Fixes #5102.


I hereby agree to the terms of the JUnit Contributor License Agreement.


Definition of Done

@marcphilipp marcphilipp self-assigned this Oct 28, 2025
@marcphilipp marcphilipp requested a review from sbrannen October 28, 2025 12:03
@marcphilipp marcphilipp force-pushed the marc/5102-suspendImpl-synthetic-method-fix branch 2 times, most recently from 56da3b8 to 682591f Compare October 28, 2025 12:07
Prior to this commit, _all_ methods of a potential test class were
checked for being test methods, including synthetic ones. However, when
resolving a test class only non-synthetic methods were taken into
account.

Since the Kotlin compiler generates a synthetic, static method suffixed
with `$suspendImpl` for every open (i.e. non-final) method and copies
its annotations, such methods were included in the check.

In addition to filtering out synthetic methods from being checked,
`KotlinReflectionUtils` no longer recognizes them as suspend functions.

Fixes #5102.
@marcphilipp marcphilipp force-pushed the marc/5102-suspendImpl-synthetic-method-fix branch from 682591f to a058571 Compare October 28, 2025 12:07
Copy link
Member

@sbrannen sbrannen left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks for addressing this so quickly. 👍

@marcphilipp marcphilipp merged commit 52fffcf into main Oct 28, 2025
16 checks passed
@marcphilipp marcphilipp deleted the marc/5102-suspendImpl-synthetic-method-fix branch October 28, 2025 14:28
marcphilipp added a commit that referenced this pull request Oct 30, 2025
Prior to this commit, _all_ methods of a potential test class were
checked for being test methods, including synthetic ones. However, when
resolving a test class only non-synthetic methods were taken into
account.

Since the Kotlin compiler generates a synthetic, static method suffixed
with `$suspendImpl` for every open (i.e. non-final) method and copies
its annotations, such methods were included in the check.

In addition to filtering out synthetic methods from being checked,
`KotlinReflectionUtils` no longer recognizes them as suspend functions.

Fixes #5102.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Synthetic methods generated by Kotlin compiler for suspend functions should not cause discovery errors

3 participants