KT-15789 Kotlin plugin incorrectly converts for-loops from Java to Kotlin
#KT-15789 fixed
This commit is contained in:
committed by
Simon Ogorodnik
parent
bf3d4471cd
commit
82a70283b5
@@ -1,8 +1,9 @@
|
||||
internal class C {
|
||||
fun foo(o: Any) {
|
||||
if (o is String) {
|
||||
val l = o.length
|
||||
val substring = o.substring(l - 2)
|
||||
val s = o
|
||||
val l = s.length
|
||||
val substring = s.substring(l - 2)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
public class C {
|
||||
|
||||
public static void consume1(C c) {
|
||||
|
||||
}
|
||||
|
||||
public static void consume2(C c) {
|
||||
|
||||
}
|
||||
|
||||
public static void foo(List<C> cList) {
|
||||
for (Iterator iter = cList.iterator(); iter.hasNext();) {
|
||||
C c = (C) iter.next();
|
||||
consume1(c);
|
||||
consume2(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
object C {
|
||||
|
||||
fun consume1(c: C) {
|
||||
|
||||
}
|
||||
|
||||
fun consume2(c: C) {
|
||||
|
||||
}
|
||||
|
||||
fun foo(cList: List<C>) {
|
||||
val iter = cList.iterator()
|
||||
while (iter.hasNext()) {
|
||||
val c = iter.next()
|
||||
consume1(c)
|
||||
consume2(c)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user