For loop with arrayList() failed to compile?

The following runs fine in the WebDemo, but failed with command line compiler

fun main(args : Array<String>) {   for (n in arrayList(1,2,3))           println(n) }

ERROR: /Users/zemian/apps/kotlinc/./Test.kt: (2, 12) None of the hasNext() functions is applicable for iterator() of type 'jet.MutableIterator<jet.Int>?' ERROR: /Users/zemian/apps/kotlinc/./Test.kt: (2, 12) None of the next() functions is applicable for iterator() of type 'jet.MutableIterator<jet.Int>?' WARNING: /Users/zemian/apps/kotlinc/./Test.kt: (4, 28) Unnecessary safe call on a non-null receiver of type java.util.ArrayList<jet.Int> exec() finished with COMPILATION_ERROR return code

What happened here?

I am using Kotlin Compiler version 0.4.68

Zemian

Something is wrong with external JDK annotations. I think you have Java 7: either use Java 6 or update Kotlin to a recent nightly build.

You are right Andrey, I am using JDK7.

I have verified that this works with JDK6, and the latest build 0.4.177 as well. So it’s good.

Thanks!
-Z