// "Create function 'hasNext'" "true" class FooIterator { fun next(): T { throw Exception("not implemented") } fun hasNext(): Boolean { throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates. } } class Foo { fun iterator(): FooIterator { throw Exception("not implemented") } } fun foo() { for (i in Foo()) { } }