Skip to content

Commit a76a8fc

Browse files
committed
Adjust various testData to remove/charAt transformation
1 parent 6d864e0 commit a76a8fc

File tree

20 files changed

+30
-30
lines changed

20 files changed

+30
-30
lines changed

compiler/testData/codegen/box/builtinStubMethods/ListWithAllImplementations.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ class MyList<T>(val v: T): List<T> {
1414
override fun equals(other: Any?): Boolean = false
1515

1616
public fun add(e: T): Boolean = true
17-
public fun remove(o: Any?): Boolean = true
17+
public fun remove(o: T): Boolean = true
1818
public fun addAll(c: Collection<T>): Boolean = true
1919
public fun addAll(index: Int, c: Collection<T>): Boolean = true
2020
public fun removeAll(c: Collection<Any?>): Boolean = true
2121
public fun retainAll(c: Collection<Any?>): Boolean = true
2222
public fun clear() {}
2323
public fun set(index: Int, element: T): T = element
2424
public fun add(index: Int, element: T) {}
25-
public fun remove(index: Int): T = v
25+
public fun removeAt(index: Int): T = v
2626
}
2727

2828
fun box(): String {

compiler/testData/codegen/box/builtinStubMethods/ListWithAllInheritedImplementations.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
open class Super<T>(val v: T) {
22
public fun add(e: T): Boolean = true
3-
public fun remove(o: Any?): Boolean = true
3+
public fun remove(o: T): Boolean = true
44
public fun addAll(c: Collection<T>): Boolean = true
55
public fun addAll(index: Int, c: Collection<T>): Boolean = true
66
public fun removeAll(c: Collection<Any?>): Boolean = true
77
public fun retainAll(c: Collection<Any?>): Boolean = true
88
public fun clear() {}
99
public fun set(index: Int, element: T): T = element
1010
public fun add(index: Int, element: T) {}
11-
public fun remove(index: Int): T = v
11+
public fun removeAt(index: Int): T = v
1212
}
1313

1414
class MyList<T>(v: T): Super<T>(v), List<T> {

compiler/testData/codegen/box/builtinStubMethods/extendJavaCollections/arrayList.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ fun box(): String {
1717
a.add("")
1818
a.set(0, "")
1919
a.add(0, "")
20-
a.remove(0)
20+
a.removeAt(0)
2121
a.remove("")
2222

2323
return "OK"

compiler/testData/codegen/box/builtinStubMethods/inheritedImplementations.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
open class SetStringImpl {
22
fun add(s: String): Boolean = false
3-
fun remove(o: Any?): Boolean = false
3+
fun remove(o: String): Boolean = false
44
fun clear(): Unit {}
55
}
66

compiler/testData/codegen/box/builtinsProperties/collectionImpl.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class A1 : MutableCollection<String> {
2222
throw UnsupportedOperationException()
2323
}
2424

25-
override fun remove(o: Any?): Boolean {
25+
override fun remove(o: String): Boolean {
2626
throw UnsupportedOperationException()
2727
}
2828

compiler/testData/codegen/box/extensionFunctions/simple.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
fun StringBuilder.first() = this.charAt(0)
1+
fun StringBuilder.first() = this.get(0)
22

33
fun foo() = StringBuilder("foo").first()
44

compiler/testData/codegen/box/extensionFunctions/whenFail.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
fun StringBuilder.takeFirst(): Char {
22
if (this.length() == 0) return 0.toChar()
3-
val c = this.charAt(0)
3+
val c = this.get(0)
44
this.deleteCharAt(0)
55
return c
66
}

compiler/testData/codegen/box/intrinsics/infixCall.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
fun box(): String {
2-
val o = "OK" charAt 0
2+
val o = "OK" get 0
33
val array = CharArray(2)
44
array[1] = 'K'
55
val k = array get 1

compiler/testData/codegen/box/strings/kt5956.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// KT-5956 java.lang.AbstractMethodError: test.Thing.subSequence(II)Ljava/lang/CharSequence
22

33
class Thing(val delegate: CharSequence) : CharSequence {
4-
override fun charAt(index: Int): Char {
4+
override fun get(index: Int): Char {
55
throw UnsupportedOperationException()
66
}
77
override fun length(): Int = 0

compiler/testData/codegen/boxWithJava/collections/mutableList/mutableList.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ open class KList<E> : MutableList<E> {
33
throw UnsupportedOperationException()
44
}
55

6-
override fun remove(o: Any?): Boolean {
6+
override fun remove(o: E): Boolean {
77
throw UnsupportedOperationException()
88
}
99

@@ -35,7 +35,7 @@ open class KList<E> : MutableList<E> {
3535
throw UnsupportedOperationException()
3636
}
3737

38-
override fun remove(index: Int): E {
38+
override fun removeAt(index: Int): E {
3939
throw UnsupportedOperationException()
4040
}
4141

compiler/testData/codegen/boxWithJava/collections/strList/strList.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ open class KList : MutableList<String> {
2929
throw UnsupportedOperationException()
3030
}
3131

32-
override fun remove(o: Any?): Boolean {
32+
override fun remove(o: String): Boolean {
3333
throw UnsupportedOperationException()
3434
}
3535

@@ -61,7 +61,7 @@ open class KList : MutableList<String> {
6161
throw UnsupportedOperationException()
6262
}
6363

64-
override fun remove(index: Int): String {
64+
override fun removeAt(index: Int): String {
6565
throw UnsupportedOperationException()
6666
}
6767

compiler/testData/diagnostics/tests/library/Collections.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ fun <T> testMutableCollection(c: MutableCollection<T>, t: T) {
2626

2727
val <!UNUSED_VARIABLE!>mutableIterator<!>: MutableIterator<T> = c.iterator()
2828
c.add(t)
29-
c.remove(1)
29+
c.remove(<!UNCHECKED_CAST!>1 as T<!>)
3030
c.addAll(c)
3131
c.removeAll(c)
3232
c.retainAll(c)
@@ -52,7 +52,7 @@ fun <T> testList(l: List<T>, <!UNUSED_PARAMETER!>t<!>: T) {
5252
fun <T> testMutableList(l: MutableList<T>, t: T) {
5353
val <!UNUSED_VARIABLE!>value<!>: T = l.set(1, t)
5454
l.add(1, t)
55-
l.remove(1)
55+
l.removeAt(1)
5656
val <!UNUSED_VARIABLE!>mutableListIterator<!>: MutableListIterator<T> = l.listIterator()
5757
val <!UNUSED_VARIABLE!>mutableListIterator1<!>: MutableListIterator<T> = l.listIterator(1)
5858
val <!UNUSED_VARIABLE!>mutableList<!>: MutableList<T> = l.subList(1, 2)
@@ -84,7 +84,7 @@ fun <T> testMutableSet(s: MutableSet<T>, t: T) {
8484

8585
val <!UNUSED_VARIABLE!>mutableIterator<!>: MutableIterator<T> = s.iterator()
8686
s.add(t)
87-
s.remove(1)
87+
s.remove(<!UNCHECKED_CAST!>1 as T<!>)
8888
s.addAll(s)
8989
s.removeAll(s)
9090
s.retainAll(s)

compiler/testData/diagnostics/tests/regressions/DoubleDefine.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import java.util.*
33
import java.io.*
44

55
fun takeFirst(expr: StringBuilder): Char {
6-
val c = expr.charAt(0)
6+
val c = expr.get(0)
77
expr.deleteCharAt(0)
88
return c
99
}
@@ -31,7 +31,7 @@ fun evaluateAdd(expr: StringBuilder, numbers: ArrayList<Int>): Int {
3131
fun evaluate(expr: StringBuilder, numbers: ArrayList<Int>): Int {
3232
val lhs = evaluateAdd(expr, numbers)
3333
if (expr.length() > 0) {
34-
val <!UNUSED_VARIABLE!>c<!> = expr.charAt(0)
34+
val <!UNUSED_VARIABLE!>c<!> = expr.get(0)
3535
expr.deleteCharAt(0)
3636
}
3737
return lhs

compiler/testData/diagnostics/tests/smartCasts/safecalls/extensionCall.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ fun String.bar(s: String) = s
22

33
fun foo(s: String?) {
44
s?.bar(<!DEBUG_INFO_SMARTCAST!>s<!>)
5-
s?.charAt(<!DEBUG_INFO_SMARTCAST!>s<!>.length())
5+
s?.get(<!DEBUG_INFO_SMARTCAST!>s<!>.length())
66
}

compiler/tests/org/jetbrains/kotlin/codegen/PackageGenTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ public void testSubstituteJavaMethodTypeParameters() throws Exception {
384384
}
385385

386386
public void testCallMethodDeclaredInSuperclass() throws Exception {
387-
loadText("fun foo(sb: StringBuilder) = sb.charAt(0)");
387+
loadText("fun foo(sb: StringBuilder) = sb.get(0)");
388388
Method main = generateFunction();
389389
StringBuilder sb = new StringBuilder("x");
390390
assertEquals('x', ((Character) main.invoke(null, sb)).charValue());

idea/idea-completion/testData/basic/java/boldOrGrayed/ImmediateMembersForPlatformType.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ class C {
1111
// EXIST: { itemText: "extFunForString", attributes: "bold" }
1212
// EXIST: { itemText: "extFunForAny", attributes: "" }
1313
// EXIST: { itemText: "extFunForStringNullable", attributes: "bold" }
14-
// EXIST: { itemText: "charAt", attributes: "" }
14+
// EXIST: { itemText: "get", attributes: "" }

idea/testData/checker/regression/DoubleDefine.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import java.util.*
33
import java.io.*
44

55
fun takeFirst(expr: StringBuilder): Char {
6-
val c = expr.charAt(0)
6+
val c = expr.get(0)
77
expr.deleteCharAt(0)
88
return c
99
}
@@ -31,7 +31,7 @@ fun evaluateAdd(expr: StringBuilder, numbers: ArrayList<Int>): Int {
3131
fun evaluate(expr: StringBuilder, numbers: ArrayList<Int>): Int {
3232
val lhs = evaluateAdd(expr, numbers)
3333
if (expr.length() > 0) {
34-
val <warning>c</warning> = expr.charAt(0)
34+
val <warning>c</warning> = expr.get(0)
3535
expr.deleteCharAt(0)
3636
}
3737
return lhs

js/js.translator/testData/java/arrayList/cases/misc.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ fun box(): Boolean {
1111

1212
// test addAt
1313
list.add(0, 400)
14-
list.remove(0);
14+
list.removeAt(0);
1515
list.add(1, 500)
1616
// test contains, addAll
1717
if (!list.contains(500) || list.contains(600) || list.addAll(ArrayList<Int>())) {

js/js.translator/testData/java/arrayList/cases/remove.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ fun box(): Boolean {
88
arr.add(i)
99
}
1010

11-
val removedElement = arr.remove(2)
12-
val removed = arr.remove(4: Any)
11+
val removedElement = arr.removeAt(2)
12+
val removed = arr.remove(4)
1313
return arr.size() == 4 && removedElement == 2 && removed && arr[0] == 0 && arr[1] == 1 && arr[2] == 3 && arr[3] == 5
1414
}

js/js.translator/testData/java/arrayList/cases/removeWithIndexOutOfBounds.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ fun box(): Boolean {
77

88
val arr = ArrayList<Int>()
99
try {
10-
arr.remove(2)
10+
arr.removeAt(2)
1111
}
1212
catch(e: IndexOutOfBoundsException) {
1313
threwForEmptyList = true
@@ -20,7 +20,7 @@ fun box(): Boolean {
2020
var threwForFilled = false
2121

2222
try {
23-
arr.remove(20)
23+
arr.removeAt(20)
2424
}
2525
catch(e: IndexOutOfBoundsException) {
2626
threwForFilled = true

0 commit comments

Comments
 (0)