-
-
Notifications
You must be signed in to change notification settings - Fork 638
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
Iterator.toCharSeq() error #1685
Comments
Changing the @SuppressWarnings("unchecked")
default CharSeq toCharSeq() {
return CharSeq.ofAll((Iterable<? extends Character>) iterator());
} @danieldietrich Is there any better way of fixing this? |
Good catch! Please do it this way: interface Value<T> {
default CharSeq toCharSeq() {
if (this instanceof CharSeq) {
return (CharSeq) this;
} if (isEmpty()) {
return CharSeq.empty();
} else {
return CharSeq.of(iterator().mkString());
}
}
} Update: @ashrko619 I realized that the |
@ashrko619 please do this in a separate PR - after it is fixed we can pull #1684 |
@danieldietrich There a lots of errors in the tests after fixing the @Test
public void shouldConvertToCharSeq() {
final Value<Integer> value = of(1, 2, 3);
final CharSeq charSeq = value.toCharSeq();
assertThat(charSeq).isEqualTo(CharSeq.of(value.toString()));
}
Should we create a new issue for fixing these tests? |
Mmhh, this will definitely change the semantics (and therefore won't be behavioral backward compatible any more) - but it is worth it. The current behavior can be seen as a bug. Let's fix the tests in this issue. I think it should not be much work because several errors will depend on tests in an abstract test class. Fixing these tests will multiply regarding the specific collection tests. If you think it is too much I'm able to do it this evening (approx. in 5 hours). |
@danieldietrich No problems, I have already started working on fixing them 😉 |
The following code fails
with the following error
The problem is in this method
Here
toString()
callsAbstractIterator.toString()
The text was updated successfully, but these errors were encountered: