Move Comparator to kotlin.comparisons and make it imported by default.

#KT-2084
This commit is contained in:
Ilya Gorbunov
2016-11-14 00:54:31 +03:00
parent 090bd76ac9
commit 63535393e7
4 changed files with 32 additions and 8 deletions
@@ -43,6 +43,7 @@ abstract class TargetPlatform(val platformName: String) {
add(ImportPath("kotlin.ranges.*"))
add(ImportPath("kotlin.sequences.*"))
add(ImportPath("kotlin.text.*"))
add(ImportPath("kotlin.comparisons.Comparator"))
}
override val platformConfigurator =
+26
View File
@@ -0,0 +1,26 @@
/*
* Copyright 2010-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package kotlin.comparisons
public interface Comparator<T> {
@JsName("compare") fun compare(a: T, b: T): Int
}
public inline fun <T> Comparator(crossinline comparison: (T, T) -> Int): Comparator<T> = object : Comparator<T> {
override fun compare(a: T, b: T): Int = comparison(a, b)
}
-8
View File
@@ -16,14 +16,6 @@
package java.util
interface Comparator<T> {
@JsName("compare") fun compare(a: T, b: T): Int
}
inline fun <T> Comparator(crossinline comparison: (T, T) -> Int): Comparator<T> = object : Comparator<T> {
override fun compare(a: T, b: T): Int = comparison(a, b)
}
// TODO: Not supported
// typealias Date = kotlin.js.Date
@@ -0,0 +1,5 @@
@file:kotlin.jvm.JvmVersion
package kotlin.comparisons
public typealias Comparator<T> = java.util.Comparator<T>