Skip to content
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

Make ErrorCollector#checkSucceeds() generic #1013

Closed
wants to merge 1 commit into from
Closed

Make ErrorCollector#checkSucceeds() generic #1013

wants to merge 1 commit into from

Conversation

oehme
Copy link
Contributor

@oehme oehme commented Oct 26, 2014

This brings the signatures in line with others like Assert.assertThat.
Especially the checkSucceeds would be hardly usable in languages with target typing (Java8/Xtend) otherwise.

@kcooney
Copy link
Member

kcooney commented Oct 26, 2014

Thanks for the fix. Could you please update the tests for ErrorCollector to include a call that would compile with the new signature but not the old one, then squash the two commits?

@oehme
Copy link
Contributor Author

oehme commented Oct 27, 2014

There you go =)

I rolled back the change to the checkThat-methods, since they work just fine without the lower bound. It would only be a problem if they used the type parameter T somewhere else, e.g. as a return type.

@@ -73,7 +73,7 @@ public Object call() throws Exception {
* Execution continues, but the test will fail at the end if
* {@code callable} threw an exception.
*/
public Object checkSucceeds(Callable<Object> callable) {
public Object checkSucceeds(Callable<?> callable) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a better signature would be:

public <V> V checkSucceeds(Callable<V> callable)

If this is the only change (other than the tests) could you update the commit message to be someone more specific? Perhaps "Make ErrorCollector.checkSucceeds() generic"

@oehme oehme changed the title widen generics in ErrorCollector Make ErrorCollector#checkSucceeds() generic Oct 31, 2014
@@ -73,7 +73,7 @@ public Object call() throws Exception {
* Execution continues, but the test will fail at the end if
* {@code callable} threw an exception.
*/
public Object checkSucceeds(Callable<Object> callable) {
public <T> T checkSucceeds(Callable<? extends T> callable) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should really be:

public <T> T checkSucceeds(Callable<T> callable) {

.. because of the return type of Callable.call(). Stated another way, if you pass in a Callable<Integer> then the return type should be a Integer, but the signature you have would mean "return some super type of Integer"

@kcooney
Copy link
Member

kcooney commented Nov 27, 2014

@oehme Sorry for not responding earlier. Github didn't notify us that you had pushed a new commit. I think you need to ping the thread for us to be notified.

@oehme
Copy link
Contributor Author

oehme commented Nov 27, 2014

Oh I see. Well no problem, I'm glad I could help =)

2014-11-27 5:36 GMT+01:00 Kevin Cooney [email protected]:

@oehme https://github.com/oehme Sorry for not responding earlier.
Github didn't notify us that you had pushed a new commit. I think you need
to ping the thread for us to be notified.


Reply to this email directly or view it on GitHub
#1013 (comment).

@kcooney
Copy link
Member

kcooney commented Nov 28, 2014

@oehme thanks for.helping! Any chance you could fix the generics on checkSucceeds?

@oehme
Copy link
Contributor Author

oehme commented Nov 28, 2014

Oh sorry I didn't see that comment. You're right, that upper bound is not necessary, I'll fix that.

@kcooney kcooney closed this in 60aaf96 Nov 30, 2014
@kcooney
Copy link
Member

kcooney commented Nov 30, 2014

I fixed the signature on my side and merged this pull. Thanks!

kcooney added a commit that referenced this pull request Dec 4, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants