Fix some API holes in headers

This commit is contained in:
Ilya Gorbunov
2016-12-16 07:32:48 +03:00
parent 4f2410ffe0
commit c6a812b11c
3 changed files with 145 additions and 25 deletions
@@ -1,3 +1,19 @@
/*
* 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.collections
open header class ArrayList<E> : MutableList<E> {
@@ -5,6 +21,9 @@ open header class ArrayList<E> : MutableList<E> {
constructor()
constructor(c: Collection<E>)
fun trimToSize()
fun ensureCapacity(minCapacity: Int)
// From List
override val size: Int
override fun isEmpty(): Boolean
@@ -34,8 +53,10 @@ open header class ArrayList<E> : MutableList<E> {
}
open header class HashMap<K, V> : MutableMap<K, V> {
constructor(initialCapacity: Int)
constructor()
constructor(initialCapacity: Int)
constructor(initialCapacity: Int, loadFactor: Float)
constructor(original: Map<out K, V>)
// From Map
override val size: Int
@@ -55,14 +76,17 @@ open header class HashMap<K, V> : MutableMap<K, V> {
}
open header class LinkedHashMap<K, V> : HashMap<K, V> {
constructor(initialCapacity: Int)
constructor()
constructor(m: Map<out K, V>)
constructor(initialCapacity: Int)
constructor(initialCapacity: Int, loadFactor: Float)
constructor(original: Map<out K, V>)
}
open header class HashSet<E> : MutableSet<E> {
constructor()
constructor(initialCapacity: Int)
constructor(initialCapacity: Int, loadFactor: Float)
constructor(c: Collection<E>)
// From Set
override val size: Int
@@ -81,8 +105,9 @@ open header class HashSet<E> : MutableSet<E> {
}
open header class LinkedHashSet<E> : HashSet<E> {
constructor(initialCapacity: Int)
constructor()
constructor(initialCapacity: Int)
constructor(initialCapacity: Int, loadFactor: Float)
constructor(c: Collection<E>)
}
@@ -122,3 +147,6 @@ header inline fun <reified T> Collection<T>.toTypedArray(): Array<T>
header fun <T : Comparable<T>> MutableList<T>.sort(): Unit
header fun <T> MutableList<T>.sortWith(comparator: Comparator<in T>): Unit
// from Maps.kt
header operator fun <K, V> MutableMap<K, V>.set(key: K, value: V): Unit
+54 -1
View File
@@ -1,12 +1,32 @@
/*
* 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
import kotlin.annotation.AnnotationTarget.*
open header class Error : Throwable {
constructor()
constructor(message: String)
}
open header class Exception : Throwable
open header class Exception : Throwable {
constructor()
constructor(message: String)
}
open header class IllegalArgumentException : RuntimeException {
constructor()
@@ -14,10 +34,12 @@ open header class IllegalArgumentException : RuntimeException {
}
open header class IllegalStateException : RuntimeException {
constructor()
constructor(message: String)
}
open header class IndexOutOfBoundsException : RuntimeException {
constructor()
constructor(message: String)
}
@@ -32,6 +54,7 @@ open header class RuntimeException : Exception {
}
open header class UnsupportedOperationException : RuntimeException {
constructor()
constructor(message: String)
}
@@ -40,6 +63,7 @@ header interface Comparator<T> {
fun compare(a: T, b: T): Int
}
header inline fun <T> Comparator(crossinline comparison: (T, T) -> Int): Comparator<T>
// From kotlin.kt
@@ -57,6 +81,17 @@ internal header object Math {
}
// From numbers.kt
header fun Double.isNaN(): Boolean
header fun Float.isNaN(): Boolean
header fun Double.isInfinite(): Boolean
header fun Float.isInfinite(): Boolean
header fun Double.isFinite(): Boolean
header fun Float.isFinite(): Boolean
// From concurrent.kt
@Target(PROPERTY, FIELD)
@@ -65,3 +100,21 @@ header annotation class Volatile
inline header fun <R> synchronized(lock: Any, crossinline block: () -> R): R
// from lazy.kt
public header fun <T> lazy(initializer: () -> T): Lazy<T>
/**
* Creates a new instance of the [Lazy] that uses the specified initialization function [initializer].
*
* The [mode] parameter is ignored. */
public header fun <T> lazy(mode: LazyThreadSafetyMode, initializer: () -> T): Lazy<T>
/**
* Creates a new instance of the [Lazy] that uses the specified initialization function [initializer].
*
* The [lock] parameter is ignored.
*/
public header fun <T> lazy(lock: Any?, initializer: () -> T): Lazy<T>
+59 -20
View File
@@ -1,3 +1,19 @@
/*
* 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.text
header interface Appendable {
@@ -22,39 +38,38 @@ header class Regex {
constructor(pattern: String, option: RegexOption)
constructor(pattern: String, options: Set<RegexOption>)
fun matchEntire(input: CharSequence): MatchResult?
fun matches(input: CharSequence): Boolean
fun containsMatchIn(input: CharSequence): Boolean
fun replace(input: CharSequence, replacement: String): String
fun replace(input: CharSequence, transform: (MatchResult) -> CharSequence): String
fun replaceFirst(input: CharSequence, replacement: String): String
// TODO: requires optional parameters
fun find(input: CharSequence): MatchResult?
fun find(input: CharSequence, startIndex: Int): MatchResult?
fun findAll(input: CharSequence): Sequence<MatchResult>
fun findAll(input: CharSequence, startIndex: Int): Sequence<MatchResult>
fun split(input: CharSequence): List<String>
fun split(input: CharSequence, limit: Int): List<String>
header companion object {
fun fromLiteral(literal: String): Regex
fun escape(literal: String): String
fun escapeReplacement(literal: String): String
}
}
header class MatchGroup
header enum class RegexOption
public header interface MatchGroupCollection : Collection<MatchGroup?> {
public operator fun get(index: Int): MatchGroup?
header class MatchGroup {
val value: String
}
public header interface MatchNamedGroupCollection : MatchGroupCollection {
public operator fun get(name: String): MatchGroup?
header enum class RegexOption {
IGNORE_CASE,
MULTILINE
}
public header interface MatchResult {
public val range: IntRange
public val value: String
public val groups: MatchGroupCollection
public val groupValues: List<String>
//public val destructured: Destructured
public fun next(): MatchResult?
}
// From char.kt
header fun Char.isWhitespace(): Boolean
@@ -70,6 +85,30 @@ internal header fun String.nativeLastIndexOf(str: String, fromIndex: Int): Int
internal header fun String.nativeStartsWith(s: String, position: Int): Boolean
internal header fun String.nativeEndsWith(s: String): Boolean
public header fun String.substring(startIndex: Int): String
public header fun String.substring(startIndex: Int, endIndex: Int): String
public header inline fun String.toUpperCase(): String
public header inline fun String.toLowerCase(): String
public header inline fun String.capitalize(): String
public header inline fun String.decapitalize(): String
public header fun CharSequence.repeat(n: Int): String
// TOOD: requires optional parameters (and named!)
header fun String.replace(oldChar: Char, newChar: Char): String
header fun String.replace(oldChar: Char, newChar: Char, ignoreCase: Boolean): String
header fun String.replace(oldValue: String, newValue: String): String
header fun String.replace(oldValue: String, newValue: String, ignoreCase: Boolean): String
header fun String.replaceFirst(oldChar: Char, newChar: Char): String
header fun String.replaceFirst(oldChar: Char, newChar: Char, ignoreCase: Boolean): String
header fun String.replaceFirst(oldValue: String, newValue: String): String
header fun String.replaceFirst(oldValue: String, newValue: String, ignoreCase: Boolean): String
header fun String?.equals(other: String?): Boolean
header fun String?.equals(other: String?, ignoreCase: Boolean): Boolean
// From stringsCode.kt
internal inline header fun String.nativeIndexOf(ch: Char, fromIndex: Int): Int