-
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
Confusing type validation error on tests when missing classpath entry #619
Comments
I think the problem is somewhere here. When I debug this, the 'String' identifier has a null type, and that's supposedly OK for type parameters, but the 'cursor' at runtime doesn't have a parent that is an instance of |
FWIW, it's the same if you change away from a concrete type to a type parameter:
|
That analysis sounds reasonable. The method should be using |
When I try that, it looks like the |
Yes, that sounds reasonable and a PR would be very welcome! I haven't looked at this code for a long time, but if the tests still all pass (including your new one), then I think this should be correct. |
Hm, not that easy, apparently. This test starts failing with that change, as well as a couple of others. I get the feeling a part of the problem is that |
Let's see if @timtebeek can chime in here. |
Hm, looks like the classpath hunch was correct. Adding
removes that parsing issue. So it could be seen as user error, but the feedback isn't great. |
Had a brief look; agree that it would be nice to differentiate between type validation checks that fail on the before or after source spec. Right now the API we have is fairly minimal, but we could for instance add a label to rewrite-kotlin/src/main/java/org/openrewrite/kotlin/Assertions.java Lines 209 to 237 in 0f94397
It's somewhat curious that you got the type validation on |
BTW, another thing to look into in this area is the behaviour when using a fully qualified import:
Then the |
What version of OpenRewrite are you using?
I am using
How are you running OpenRewrite?
As a unit test.
What is the smallest, simplest way to reproduce the problem?
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?
Changing to
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:
/*~~(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'
.The text was updated successfully, but these errors were encountered: