diff --git a/compiler/testData/diagnostics/tests/inference/dependantOnVarianceNullable.kt b/compiler/testData/diagnostics/tests/inference/dependantOnVarianceNullable.kt index cbdd402fc91..1320e4a0ae2 100644 --- a/compiler/testData/diagnostics/tests/inference/dependantOnVarianceNullable.kt +++ b/compiler/testData/diagnostics/tests/inference/dependantOnVarianceNullable.kt @@ -6,7 +6,7 @@ import java.util.Collections.* fun foo(list: List) : String { val w : String = max(list, comparator {o1, o2 -> 1 - })!! + }) return w } diff --git a/compiler/testData/diagnostics/tests/inference/possibleCycleOnConstraints.kt b/compiler/testData/diagnostics/tests/inference/possibleCycleOnConstraints.kt index 8e61222f43c..d9ae91f79f0 100644 --- a/compiler/testData/diagnostics/tests/inference/possibleCycleOnConstraints.kt +++ b/compiler/testData/diagnostics/tests/inference/possibleCycleOnConstraints.kt @@ -8,6 +8,6 @@ fun test() { //here possibly can be a cycle on constraints val x = g { Collections.emptyList() } - val y = g { Collections.emptyList()!! } - val z : List = g { Collections.emptyList()!! } + val y = g { Collections.emptyList() } + val z : List = g { Collections.emptyList() } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/regressions/kt335.336.kt b/compiler/testData/diagnostics/tests/regressions/kt335.336.kt index ed75c27ed38..637acf77467 100644 --- a/compiler/testData/diagnostics/tests/regressions/kt335.336.kt +++ b/compiler/testData/diagnostics/tests/regressions/kt335.336.kt @@ -3,7 +3,7 @@ import java.util.* -fun > List.sort() { +fun > MutableList.sort() { Collections.sort(this) // Error here } diff --git a/idea/testData/quickfix/typeAddition/afterPublicValWithoutReturnType.kt b/idea/testData/quickfix/typeAddition/afterPublicValWithoutReturnType.kt index 26a7212cbef..4ce950dfa02 100644 --- a/idea/testData/quickfix/typeAddition/afterPublicValWithoutReturnType.kt +++ b/idea/testData/quickfix/typeAddition/afterPublicValWithoutReturnType.kt @@ -1,4 +1,4 @@ // "Specify type explicitly" "true" package a -public val l: MutableList? = java.util.Collections.emptyList() \ No newline at end of file +public val l: MutableList = java.util.Collections.emptyList() \ No newline at end of file diff --git a/idea/testData/quickfix/typeImports/afterHasThisImport.kt b/idea/testData/quickfix/typeImports/afterHasThisImport.kt index 1d7fe9b733a..0c191f11df9 100644 --- a/idea/testData/quickfix/typeImports/afterHasThisImport.kt +++ b/idea/testData/quickfix/typeImports/afterHasThisImport.kt @@ -9,7 +9,7 @@ import java.util.List class M { trait A { - val l: MutableList? + val l: MutableList } } } \ No newline at end of file diff --git a/idea/testData/quickfix/typeImports/afterToImport1.kt b/idea/testData/quickfix/typeImports/afterToImport1.kt index 97493069390..4de85bcf87e 100644 --- a/idea/testData/quickfix/typeImports/afterToImport1.kt +++ b/idea/testData/quickfix/typeImports/afterToImport1.kt @@ -5,6 +5,6 @@ import java.util.Collections class M { trait A { - abstract val l: MutableList? + abstract val l: MutableList } } \ No newline at end of file diff --git a/jdk-annotations/java/util/annotations.xml b/jdk-annotations/java/util/annotations.xml index ac63a9aa5f7..1c008cbbfea 100644 --- a/jdk-annotations/java/util/annotations.xml +++ b/jdk-annotations/java/util/annotations.xml @@ -751,6 +751,8 @@ + + @@ -759,7 +761,7 @@ + val=""fun <T> sort(a : Array<out T>, c : Comparator<in T>?) : Unit""/> @@ -767,6 +769,399 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/libraries/stdlib/src/kotlin/IterablesSpecial.kt b/libraries/stdlib/src/kotlin/IterablesSpecial.kt index 162086445ae..b8157f476d0 100644 --- a/libraries/stdlib/src/kotlin/IterablesSpecial.kt +++ b/libraries/stdlib/src/kotlin/IterablesSpecial.kt @@ -106,14 +106,14 @@ public fun Iterable.withIndices(): List> { return answer } -public inline fun > Iterable.sort() : List { - val list = toList() +public inline fun > MutableIterable.sort() : List { + val list = toCollection(ArrayList()) java.util.Collections.sort(list) return list } public inline fun Iterable.sort(comparator: java.util.Comparator) : List { - val list = toList() + val list = toCollection(ArrayList()) java.util.Collections.sort(list, comparator) return list } diff --git a/libraries/stdlib/src/kotlin/IterablesSpecialJVM.kt b/libraries/stdlib/src/kotlin/IterablesSpecialJVM.kt index c12a48d5185..f4936d60f61 100644 --- a/libraries/stdlib/src/kotlin/IterablesSpecialJVM.kt +++ b/libraries/stdlib/src/kotlin/IterablesSpecialJVM.kt @@ -2,6 +2,7 @@ package kotlin import java.util.AbstractList import java.util.Comparator +import java.util.ArrayList // TODO this function is here as it breaks the JS compiler; lets move back to JLangIterablesSpecial when it works again :) @@ -13,7 +14,7 @@ import java.util.Comparator * @includeFunctionBody ../../test/CollectionTest.kt sortBy */ public inline fun > Iterable.sortBy(f: (T) -> R): List { - val sortedList = this.toList() + val sortedList = toCollection(ArrayList()) val sortBy: Comparator = comparator {(x: T, y: T) -> val xr = f(x) val yr = f(y) diff --git a/libraries/stdlib/src/kotlin/JUtil.kt b/libraries/stdlib/src/kotlin/JUtil.kt index 5b0648874e3..48bf009d685 100644 --- a/libraries/stdlib/src/kotlin/JUtil.kt +++ b/libraries/stdlib/src/kotlin/JUtil.kt @@ -36,7 +36,7 @@ public inline fun Collection?.orEmpty() : Collection /** TODO these functions don't work when they generate the Array versions when they are in JLIterables */ -public inline fun > Iterable.toSortedList() : List = toList().sort() +public inline fun > Iterable.toSortedList() : List = toCollection(ArrayList()).sort() public inline fun > Iterable.toSortedList(comparator: java.util.Comparator) : List = toList().sort(comparator)