-
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
Added type validation to Assertions. #543
Conversation
3c3f7c5
to
16bb779
Compare
Resolved: |
16bb779
to
ebff530
Compare
@@ -196,6 +209,36 @@ public static UncheckedConsumer<SourceSpec<?>> spaceConscious() { | |||
}; | |||
} | |||
|
|||
private static void assertValidTypes(TypeValidation typeValidation, J sf) { |
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.
@knutwannheden @kunli2, I don't think mixins will help us customize the FindMissingTypes
recipe. Initially, I thought about creating a FindMissingKotlinTypes
recipe/visitor, which could arguably be helpful. But I recall Jonathan preferring nearly identical recipes not to be created. Eventually, if we find there is a need for the augmented recipe, we can move the code.
What do you think? Is it fine to have the visitor in Assertions for now or would you prefer a recipe?
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.
At some point I would be interested in the details regarding the mixins, do that we can try to come up with a fix or another approach for this. An alternative might be delegation kind of like we do in the printer.
For now I think what you currently have is good. Having type validations working is really a step forward. Thanks for fixing this!
|
||
import java.util.List; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.openrewrite.kotlin.Assertions.kotlin; | ||
|
||
@SuppressWarnings({"RedundantSuppression", "RedundantNullableReturnType", "RedundantVisibilityModifier", "UnusedReceiverParameter", "SortModifiers", "TrailingComma"}) | ||
@SuppressWarnings({"RedundantSuppression", "RedundantNullableReturnType", "RedundantVisibilityModifier", "UnusedReceiverParameter", "SortModifiers", "TrailingComma", "RedundantGetter", "RedundantSetter"}) | ||
class AnnotationTest 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.
I cleaned up the errors/warnings here when I looked through the tests.
ebff530
to
e333f1d
Compare
@knutwannheden type validation is essentially ready for review. The failing tests are identifiers with aliases, and I'm looking into how to detect aliases. import java.util.regex.Pattern.CASE_INSENSITIVE as i
class A {
val f = arrayOf(i)
} |
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.
As we can disable validations on a test case basis, we can fix any remaining issues in follow up PRs.
Disabled type validation on tests with intentionally unresolvable types. Fixed NPE in KotlinPrinter. Fixed errors in AnnotationTest.
e333f1d
to
25bf1ca
Compare
Disabled the alias tests and opened: #545 to track a fix for aliases. Tracking the declarations of a name will allow us to apply the appropriate field type comparison. |
Changes:
fixes #482
fixes #474