Skip to content

Commit d870d9d

Browse files
mglukhikhSpace Team
authored and
Space Team
committed
K1/K2: add tests for KT-65441 current behavior
1 parent 5885514 commit d870d9d

File tree

2 files changed

+50
-2
lines changed

2 files changed

+50
-2
lines changed

compiler/testData/diagnostics/tests/testsWithJava21/newListMethodsImmutable.fir.kt

+25-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
1-
// ISSUE: KT-64640
1+
// ISSUE: KT-64640, KT-65441
22

33
fun bar(x: List<String>) {
44
x.<!UNRESOLVED_REFERENCE!>addFirst<!>("")
55
x.<!UNRESOLVED_REFERENCE!>addLast<!>("")
66
x.<!UNRESOLVED_REFERENCE!>removeFirst<!>()
77
x.<!UNRESOLVED_REFERENCE!>removeLast<!>()
8+
x.<!UNRESOLVED_REFERENCE!>getFirst<!>()
9+
x.<!UNRESOLVED_REFERENCE!>getLast<!>()
10+
x.<!FUNCTION_CALL_EXPECTED!>first<!>
11+
x.<!FUNCTION_CALL_EXPECTED!>last<!>
812
}
913

1014
// Additional test for other SequenceCollection inheritor
@@ -13,11 +17,19 @@ fun baz(x: ArrayDeque<String>, y: LinkedHashSet<String>) {
1317
x.addLast("")
1418
x.removeFirst()
1519
x.removeLast()
20+
x.<!UNRESOLVED_REFERENCE!>getFirst<!>()
21+
x.<!UNRESOLVED_REFERENCE!>getLast<!>()
22+
x.<!FUNCTION_CALL_EXPECTED!>first<!>
23+
x.<!FUNCTION_CALL_EXPECTED!>last<!>
1624

1725
y.addFirst("")
1826
y.addLast("")
1927
y.removeFirst()
2028
y.removeLast()
29+
y.getFirst()
30+
y.getLast()
31+
y.first
32+
y.last
2133
}
2234

2335
// Test for collections with (add/remove)(First/Last) methods which are not covered by autotests
@@ -26,14 +38,26 @@ fun foo(x: java.util.SequencedCollection<String>, y: java.util.SequencedSet<Stri
2638
x.addLast("")
2739
x.removeFirst()
2840
x.removeLast()
41+
x.getFirst()
42+
x.getLast()
43+
x.first
44+
x.last
2945

3046
y.addFirst("")
3147
y.addLast("")
3248
y.removeFirst()
3349
y.removeLast()
50+
y.getFirst()
51+
y.getLast()
52+
y.first
53+
y.last
3454

3555
z.addFirst("")
3656
z.addLast("")
3757
z.removeFirst()
3858
z.removeLast()
59+
z.getFirst()
60+
z.getLast()
61+
z.first
62+
z.last
3963
}

compiler/testData/diagnostics/tests/testsWithJava21/newListMethodsImmutable.kt

+25-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
1-
// ISSUE: KT-64640
1+
// ISSUE: KT-64640, KT-65441
22

33
fun bar(x: List<String>) {
44
x.<!UNRESOLVED_REFERENCE!>addFirst<!>("")
55
x.<!UNRESOLVED_REFERENCE!>addLast<!>("")
66
x.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>removeFirst<!>()
77
x.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>removeLast<!>()
8+
x.<!DEPRECATION, JAVA_MODULE_DOES_NOT_EXPORT_PACKAGE!>getFirst<!>()
9+
x.<!DEPRECATION, JAVA_MODULE_DOES_NOT_EXPORT_PACKAGE!>getLast<!>()
10+
x.<!DEPRECATION!>first<!>
11+
x.<!DEPRECATION!>last<!>
812
}
913

1014
// Additional test for other SequenceCollection inheritor
@@ -13,11 +17,19 @@ fun baz(x: ArrayDeque<String>, y: LinkedHashSet<String>) {
1317
x.addLast("")
1418
x.removeFirst()
1519
x.removeLast()
20+
x.<!DEPRECATION!>getFirst<!>()
21+
x.<!DEPRECATION!>getLast<!>()
22+
x.<!DEPRECATION!>first<!>
23+
x.<!DEPRECATION!>last<!>
1624

1725
y.addFirst("")
1826
y.addLast("")
1927
y.removeFirst()
2028
y.removeLast()
29+
y.getFirst()
30+
y.getLast()
31+
y.first
32+
y.last
2133
}
2234

2335
// Test for collections with (add/remove)(First/Last) methods which are not covered by autotests
@@ -26,14 +38,26 @@ fun foo(x: java.util.SequencedCollection<String>, y: java.util.SequencedSet<Stri
2638
x.addLast("")
2739
x.removeFirst()
2840
x.removeLast()
41+
x.getFirst()
42+
x.getLast()
43+
x.first
44+
x.last
2945

3046
y.addFirst("")
3147
y.addLast("")
3248
y.removeFirst()
3349
y.removeLast()
50+
y.getFirst()
51+
y.getLast()
52+
y.first
53+
y.last
3454

3555
z.addFirst("")
3656
z.addLast("")
3757
z.removeFirst()
3858
z.removeLast()
59+
z.getFirst()
60+
z.getLast()
61+
z.first
62+
z.last
3963
}

0 commit comments

Comments
 (0)