From abd0932dfed97eb2236d1839ea1ee31faa734592 Mon Sep 17 00:00:00 2001 From: Andrey Breslav Date: Fri, 3 Feb 2012 15:00:55 +0400 Subject: [PATCH] Test for KT-274 Add Enumeration.iterator () method in global namespace --- .../tests/extensions/GenericIterator.jet | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 compiler/testData/diagnostics/tests/extensions/GenericIterator.jet diff --git a/compiler/testData/diagnostics/tests/extensions/GenericIterator.jet b/compiler/testData/diagnostics/tests/extensions/GenericIterator.jet new file mode 100644 index 00000000000..21d20539a15 --- /dev/null +++ b/compiler/testData/diagnostics/tests/extensions/GenericIterator.jet @@ -0,0 +1,27 @@ +import java.util.Enumeration + +fun a(e : java.util.Enumeration) { + for (i in e) { + i : Int + } +} + +fun T?.iterator() = object { + var hasNext = this@iterator != null + private set + + fun next() : T { + if (hasNext) { + hasNext = false + return this@iterator.sure() + } + throw java.util.NoSuchElementException() + } +} + +fun main(args : Array) { + val i : Int? = 1 + for (x in i) { + println(x) + } +} \ No newline at end of file