-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Suspend lambda gets mangled during parsing/rewrite #55
Suspend lambda gets mangled during parsing/rewrite #55
Conversation
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.openrewrite.kotlin.Assertions.kotlin; | ||
|
||
public class SuspendLambdaTest implements RewriteTest { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @nomisRev , thanks for reporting the issue and creating a PR!
I'm happy with the test, but I think it should be added to MethodDeclarationTest.
I'd prefer you to have credit for the changes -- would you please add the test the LambdaTest instead?
Info:
In the test package under org.openrewrite.kotlin.tree
each of the tests use ParserAssertions
instead of Assertions
. ParserAssertions
includes an additional step to check if the source is fully parsed by checking if any text exists in Space
. All of the parsing tests exist there, and we apply similar conventions across other languages.
Changes:
- Added issue annotation with a link to the open issue.
- Changed test name to communicate what is parsed.
@Issue("https://github.com/openrewrite/rewrite-kotlin/issues/56")
@Test
void lambdaMethodParameterWithModifier() {
rewriteRun(
kotlin(
"""
suspend fun example(
title: String,
verifyUnique: suspend (String) -> Boolean
): String = TODO()
""",
"""
suspend fun example(
title: String,
verifyUnique: suspend (String) -> Boolean
): String = TODO()
"""
)
);
}
Hey @traceyyoshima, First of all thank you of thinking about giving me credit! I update the PR according to your feedback but was a little bit confused about:
Looking at the tests in both MethodDeclarationTest and MethodDeclarationTest I felt it made more sense in the former. Additionally, I also added the empty spaces as done in the other parsers tests. If you have any more feedback please let me know, and I'll happily adjust accordingly. I added |
Ah, that's a great observation -- Initially, I added a comment suggesting |
That is actually not the case, there is a special case And another one I am not sure what is happening, so I'll open a new issue for it. I'll raise a PR in a sec. |
A Kotlin
suspend
lambda gets rewritten incorrectly.becomes