Open
Description
What version of OpenRewrite are you using?
I am using
- openrewrite-test v8.40.3
- openrewrite-kotlin v1.23.1
How are you running OpenRewrite?
As a unit test.
What is the smallest, simplest way to reproduce the problem?
@Test
fun shouldAddAdditionalMethodToInterface() {
rewriteRun(
kotlin("""
import io.reactivex.rxjava3.core.Observable
interface MyApi {
fun myObservable(): Observable<String>
}
""".trimIndent(),
"""
import io.reactivex.rxjava3.core.Observable
interface MyApi {
@Deprecated("Use myFlow() instead", ReplaceWith("myFlow()"))
fun myObservable(): Observable<String>
fun myFlow(): Flow<String>
}
""".trimIndent()),
)
}
What did you expect to see?
I expected a test failure, because I haven't implemented the rule in question.
What did you see instead?
A test parsing error.
What is the full stack trace of any errors you encountered?
LST contains missing or invalid type information
Identifier->ParameterizedType->MethodDeclaration->Block->ClassDeclaration->CompilationUnit
/*~~(Identifier type is missing or malformed)~~>*/String
java.lang.IllegalStateException: LST contains missing or invalid type information
Identifier->ParameterizedType->MethodDeclaration->Block->ClassDeclaration->CompilationUnit
/*~~(Identifier type is missing or malformed)~~>*/String
at org.openrewrite.kotlin.Assertions.assertValidTypes(Assertions.java:234)
at org.openrewrite.kotlin.Assertions.validateTypes(Assertions.java:56)
at org.openrewrite.test.RewriteTest.rewriteRun(RewriteTest.java:303)
at org.openrewrite.test.RewriteTest.rewriteRun(RewriteTest.java:132)
at org.openrewrite.test.RewriteTest.rewriteRun(RewriteTest.java:127)
Changing to
interface MyApi {
fun myObservable(): Observable<java.lang.String>
}
Makes the problem go away. But that's not exactly reasonable, IMO, since that's not how people write Kotlin (or Java!).
It would be fantastic if the error message could be clearer, as well. Some suggestions for improvements:
- Specify whether this is in the 'before' or 'after'
- The line
/*~~(Identifier type is missing or malformed)~~>*/String
is very hard to understand - the 'String' bit looks almost like it's a bug. Why not simply say something likeIdentifier type is missing or malformed for type 'String'
. - Including the place in the file where parsing failed would help; line+column.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Backlog