diff --git a/libraries/kdoc/src/main/kotlin/org/jetbrains/kotlin/template/TemplateCore.kt b/libraries/kdoc/src/main/kotlin/org/jetbrains/kotlin/template/TemplateCore.kt index 964152345a4..f581b66a2d5 100644 --- a/libraries/kdoc/src/main/kotlin/org/jetbrains/kotlin/template/TemplateCore.kt +++ b/libraries/kdoc/src/main/kotlin/org/jetbrains/kotlin/template/TemplateCore.kt @@ -81,7 +81,7 @@ abstract class TextTemplate() : TemplateSupport(), Printer { fun renderTo(os: OutputStream): Unit { // TODO compiler error - //OutputStreamWriter(os).foreach{ renderTo(it) } + //OutputStreamWriter(os).forEach{ renderTo(it) } val s = OutputStreamWriter(os) renderTo(s) s.close() @@ -89,7 +89,7 @@ abstract class TextTemplate() : TemplateSupport(), Printer { fun renderTo(file: File): Unit { // TODO compiler error - //FileWriter(file).foreach{ s -> renderTo(s) } + //FileWriter(file).forEach{ s -> renderTo(s) } val s = FileWriter(file) renderTo(s) s.close() diff --git a/libraries/stdlib/src/JavaIo.kt b/libraries/stdlib/src/JavaIo.kt index abeb9732d46..c847a77bd0f 100644 --- a/libraries/stdlib/src/JavaIo.kt +++ b/libraries/stdlib/src/JavaIo.kt @@ -199,7 +199,7 @@ inline fun Reader.buffered(): BufferedReader = if(this is BufferedReader) this e inline fun Reader.buffered(bufferSize: Int) = BufferedReader(this, bufferSize) -inline fun Reader.foreachLine(block: (String) -> Unit): Unit { +inline fun Reader.forEachLine(block: (String) -> Unit): Unit { this.use{ val iter = buffered().lineIterator() while (iter.hasNext) { diff --git a/libraries/stdlib/src/JavaIterables.kt b/libraries/stdlib/src/JavaIterables.kt index 80fb970453d..be59815caa8 100644 --- a/libraries/stdlib/src/JavaIterables.kt +++ b/libraries/stdlib/src/JavaIterables.kt @@ -104,7 +104,7 @@ inline fun java.lang.Iterable.flatMapTo(result: Collection, transfo } /** Performs the given operation on each element inside the collection */ -inline fun java.lang.Iterable.foreach(operation: (element: T) -> Unit) { +inline fun java.lang.Iterable.forEach(operation: (element: T) -> Unit) { for (elem in this) operation(elem) } diff --git a/libraries/stdlib/src/generated/ArraysFromJavaIterables.kt b/libraries/stdlib/src/generated/ArraysFromJavaIterables.kt index fff72dc1fb7..6cc7a6e91bf 100644 --- a/libraries/stdlib/src/generated/ArraysFromJavaIterables.kt +++ b/libraries/stdlib/src/generated/ArraysFromJavaIterables.kt @@ -107,7 +107,7 @@ inline fun Array.flatMapTo(result: Collection, transform: (T)-> Col } /** Performs the given operation on each element inside the collection */ -inline fun Array.foreach(operation: (element: T) -> Unit) { +inline fun Array.forEach(operation: (element: T) -> Unit) { for (elem in this) operation(elem) } diff --git a/libraries/stdlib/src/generated/StandardFromJavaIterables.kt b/libraries/stdlib/src/generated/StandardFromJavaIterables.kt index 6f3470b2f73..3714a677c35 100644 --- a/libraries/stdlib/src/generated/StandardFromJavaIterables.kt +++ b/libraries/stdlib/src/generated/StandardFromJavaIterables.kt @@ -95,7 +95,7 @@ inline fun Iterable.flatMapTo(result: Collection, transform: (T)-> } /** Performs the given operation on each element inside the collection */ -inline fun Iterable.foreach(operation: (element: T) -> Unit) { +inline fun Iterable.forEach(operation: (element: T) -> Unit) { for (elem in this) operation(elem) } diff --git a/libraries/testlib/test/CollectionApiCheck.kt b/libraries/testlib/test/CollectionApiCheck.kt index 811508f8908..4e23ead9e21 100644 --- a/libraries/testlib/test/CollectionApiCheck.kt +++ b/libraries/testlib/test/CollectionApiCheck.kt @@ -20,7 +20,7 @@ trait Traversable { fun filter(predicate: (T)-> Boolean) : Collection /** Performs the given operation on each element inside the collection */ - fun foreach(operation: (element: T)-> Unit) + fun forEach(operation: (element: T)-> Unit) /** Returns a new collection containing the results of applying the given function to each element in this collection */ fun java.lang.Iterable.map(transform : (T)-> R) : Collection diff --git a/libraries/testlib/test/CollectionTest.kt b/libraries/testlib/test/CollectionTest.kt index bdb6fdf9551..5b8eec239eb 100644 --- a/libraries/testlib/test/CollectionTest.kt +++ b/libraries/testlib/test/CollectionTest.kt @@ -125,7 +125,7 @@ class CollectionTest() : TestCase() { fun testForeach() { var count = 0 - data.foreach{ count += it.length } + data.forEach{ count += it.length } assertEquals(6, count) } diff --git a/libraries/testlib/test/IoTest.kt b/libraries/testlib/test/IoTest.kt index 27a95b35780..5d46da4571f 100644 --- a/libraries/testlib/test/IoTest.kt +++ b/libraries/testlib/test/IoTest.kt @@ -55,17 +55,17 @@ class IoTest() : TestCase() { val reader = sample() /* TODO would be nicer maybe to write this as - reader.lines.foreach { ... } + reader.lines.forEach { ... } as we could one day maybe one day write that as for (line in reader.lines) if the for(elem in thing) {...} statement could act as syntax sugar for - thing.foreach{ elem -> ... } + thing.forEach{ elem -> ... } - if thing is not an Iterable/array/Iterator but has a suitable foreach method + if thing is not an Iterable/array/Iterator but has a suitable forEach method */ - reader.foreachLine{ + reader.forEachLine{ list.add(it) } diff --git a/libraries/testlib/test/regressions/Kt1149.kt b/libraries/testlib/test/regressions/Kt1149.kt index 8404e5093f8..d0d2becdcff 100644 --- a/libraries/testlib/test/regressions/Kt1149.kt +++ b/libraries/testlib/test/regressions/Kt1149.kt @@ -17,7 +17,7 @@ class Kt1149Test() : TestCase() { res.add("anonymous.foo()") } }) - list.foreach{ it.foo() } + list.forEach{ it.foo() } Assert.assertEquals("anonymous.foo()", res[0]) } }