-
-
Notifications
You must be signed in to change notification settings - Fork 351
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
Type of filter by reflection #1015
Type of filter by reflection #1015
Conversation
you can go ahead with rebasing! |
You can already write it using java 8 lambda like this: List<CtExpression<?>> expressions2 = foo.getElements((CtExpression<?> e)->true);
expressions2.forEach(it->{
assertTrue(it instanceof CtExpression);
}); but it will not infer type correctly. It will fail with ClassCastException in call of matches. But it is expected and handled as not matches. I guess this ClassCastException has a performance impact... May be in Java 9 the parameter type of lambda can be get by reflection. |
87f65b2
to
a7b1977
Compare
interesting. could you add tests to check that the inferred |
Can I replace all the calls of Should I will keep |
OK, I will add these tests probably tomorrow in the evening. Good night ;) |
Tests were added |
The type of the Filter does not have to be specified in constructor, but is computed by reflection from the matches parameter type.
This PR is based on #1013, so I have to rebase it after you merge #1013. Just have a look if code like this OK, or we can make it even simpler?