Skip to content
This repository has been archived by the owner on Jul 13, 2020. It is now read-only.

childrenRecursiveSequence: fix NoSuchElementException being thrown when hasNext() returned true #388

Merged
merged 1 commit into from
May 29, 2017

Conversation

DarkEspresso
Copy link
Contributor

This change addresses a problem caused by ViewChildrenRecursiveSequence's iterator next and hasNext both calling initItemIterator.

After hasNext returns true itemIterator is not null, therefore the condition
iterator == null || (!iterator.hasNext() && seqs.isNotEmpty())
in initItemIterator is equivalent to
!iterator.hasNext() && seqs.isNotEmpty()
which is false because iterator.hasNext() is true.

So initItemIterator in next() sets itemIterator to null, causing a NoSuchElementException to be thrown.

A test for the childrenSequence() and childrenRecursiveSequence() functions has been included.

@yanex yanex merged commit 4584577 into Kotlin:master May 29, 2017
@yanex
Copy link
Member

yanex commented May 29, 2017

Merged.
Thank you for the contribution!

yanex pushed a commit that referenced this pull request May 29, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants