diff --git a/libraries/kotlin.test/common/src/main/kotlin/kotlin/test/AssertionsH.kt b/libraries/kotlin.test/common/src/main/kotlin/kotlin/test/AssertionsH.kt index 5c1cd282408..610b0ae17e0 100644 --- a/libraries/kotlin.test/common/src/main/kotlin/kotlin/test/AssertionsH.kt +++ b/libraries/kotlin.test/common/src/main/kotlin/kotlin/test/AssertionsH.kt @@ -6,7 +6,7 @@ import kotlin.reflect.KClass * Comments out a block of test code until it is implemented while keeping a link to the code * to implement in your unit test output */ -header fun todo(block: () -> Unit) +expect fun todo(block: () -> Unit) /** Asserts that a [block] fails with a specific exception of type [exceptionClass] being thrown. */ -header fun assertFailsWith(exceptionClass: KClass, message: String?, block: () -> Unit): T +expect fun assertFailsWith(exceptionClass: KClass, message: String?, block: () -> Unit): T diff --git a/libraries/kotlin.test/common/src/main/kotlin/kotlin/test/Utils.kt b/libraries/kotlin.test/common/src/main/kotlin/kotlin/test/Utils.kt index c808b3d5d66..99e80dc56db 100644 --- a/libraries/kotlin.test/common/src/main/kotlin/kotlin/test/Utils.kt +++ b/libraries/kotlin.test/common/src/main/kotlin/kotlin/test/Utils.kt @@ -1,7 +1,7 @@ package kotlin.test internal fun messagePrefix(message: String?) = if (message == null) "" else "$message. " -internal header fun lookupAsserter(): Asserter +internal expect fun lookupAsserter(): Asserter @PublishedApi // required to get stable name as it's called from box tests internal fun overrideAsserter(value: Asserter?): Asserter? { diff --git a/libraries/kotlin.test/common/src/main/kotlin/org/junit/Test.kt b/libraries/kotlin.test/common/src/main/kotlin/org/junit/Test.kt index 31460f5c959..53f5c6f165e 100644 --- a/libraries/kotlin.test/common/src/main/kotlin/org/junit/Test.kt +++ b/libraries/kotlin.test/common/src/main/kotlin/org/junit/Test.kt @@ -1,4 +1,4 @@ package org.junit @Suppress("NO_ACTUAL_FOR_EXPECT") -header annotation class Test +expect annotation class Test diff --git a/libraries/stdlib/common/src/kotlin/CollectionsH.kt b/libraries/stdlib/common/src/kotlin/CollectionsH.kt index 29617da361b..dad4d73da23 100644 --- a/libraries/stdlib/common/src/kotlin/CollectionsH.kt +++ b/libraries/stdlib/common/src/kotlin/CollectionsH.kt @@ -16,7 +16,7 @@ package kotlin.collections -open header class ArrayList : MutableList { +open expect class ArrayList : MutableList { constructor(capacity: Int) constructor() constructor(c: Collection) @@ -52,7 +52,7 @@ open header class ArrayList : MutableList { override fun subList(fromIndex: Int, toIndex: Int): MutableList } -open header class HashMap : MutableMap { +open expect class HashMap : MutableMap { constructor() constructor(initialCapacity: Int) constructor(initialCapacity: Int, loadFactor: Float) @@ -75,14 +75,14 @@ open header class HashMap : MutableMap { override val entries: MutableSet> } -open header class LinkedHashMap : HashMap { +open expect class LinkedHashMap : HashMap { constructor() constructor(initialCapacity: Int) constructor(initialCapacity: Int, loadFactor: Float) constructor(original: Map) } -open header class HashSet : MutableSet { +open expect class HashSet : MutableSet { constructor() constructor(initialCapacity: Int) constructor(initialCapacity: Int, loadFactor: Float) @@ -104,17 +104,17 @@ open header class HashSet : MutableSet { override fun clear() } -open header class LinkedHashSet : HashSet { +open expect class LinkedHashSet : HashSet { constructor() constructor(initialCapacity: Int) constructor(initialCapacity: Int, loadFactor: Float) constructor(c: Collection) } -header interface RandomAccess +expect interface RandomAccess -header abstract class AbstractMutableList : MutableList { +expect abstract class AbstractMutableList : MutableList { protected constructor() // From List @@ -144,19 +144,19 @@ header abstract class AbstractMutableList : MutableList { // From collections.kt /** Returns the array if it's not `null`, or an empty array otherwise. */ -header inline fun Array?.orEmpty(): Array +expect inline fun Array?.orEmpty(): Array -header inline fun Collection.toTypedArray(): Array +expect inline fun Collection.toTypedArray(): Array -header fun > MutableList.sort(): Unit -header fun MutableList.sortWith(comparator: Comparator): Unit +expect fun > MutableList.sort(): Unit +expect fun MutableList.sortWith(comparator: Comparator): Unit // from Grouping.kt -public header fun Grouping.eachCount(): Map -// public header inline fun Grouping.eachSumOf(valueSelector: (T) -> Int): Map +public expect fun Grouping.eachCount(): Map +// public expect inline fun Grouping.eachSumOf(valueSelector: (T) -> Int): Map -internal header fun copyToArrayImpl(collection: Collection<*>): Array +internal expect fun copyToArrayImpl(collection: Collection<*>): Array -internal header fun copyToArrayImpl(collection: Collection<*>, array: Array): Array +internal expect fun copyToArrayImpl(collection: Collection<*>, array: Array): Array diff --git a/libraries/stdlib/common/src/kotlin/ConsoleH.kt b/libraries/stdlib/common/src/kotlin/ConsoleH.kt index aa57572dff0..6b976c0e66c 100644 --- a/libraries/stdlib/common/src/kotlin/ConsoleH.kt +++ b/libraries/stdlib/common/src/kotlin/ConsoleH.kt @@ -2,10 +2,10 @@ package kotlin.io /** Prints a newline to the standard output stream. */ -public header fun println() +public expect fun println() /** Prints the given message and newline to the standard output stream. */ -public header fun println(message: Any?) +public expect fun println(message: Any?) /** Prints the given message to the standard output stream. */ -public header fun print(message: Any?) +public expect fun print(message: Any?) diff --git a/libraries/stdlib/common/src/kotlin/CoroutinesH.kt b/libraries/stdlib/common/src/kotlin/CoroutinesH.kt index c88a7fe7e1b..74cc6332dd1 100644 --- a/libraries/stdlib/common/src/kotlin/CoroutinesH.kt +++ b/libraries/stdlib/common/src/kotlin/CoroutinesH.kt @@ -1,7 +1,7 @@ package kotlin.coroutines.experimental @PublishedApi -internal header class SafeContinuation : Continuation { +internal expect class SafeContinuation : Continuation { internal constructor(delegate: Continuation, initialResult: Any?) @PublishedApi diff --git a/libraries/stdlib/common/src/kotlin/CoroutinesIntrinsicsH.kt b/libraries/stdlib/common/src/kotlin/CoroutinesIntrinsicsH.kt index 0cc510533eb..b0121e11281 100644 --- a/libraries/stdlib/common/src/kotlin/CoroutinesIntrinsicsH.kt +++ b/libraries/stdlib/common/src/kotlin/CoroutinesIntrinsicsH.kt @@ -26,7 +26,7 @@ import kotlin.coroutines.experimental.Continuation * coroutine using a reference to the suspending function. */ @SinceKotlin("1.1") -public header inline fun (suspend () -> T).startCoroutineUninterceptedOrReturn( +public expect inline fun (suspend () -> T).startCoroutineUninterceptedOrReturn( completion: Continuation ): Any? @@ -38,18 +38,18 @@ public header inline fun (suspend () -> T).startCoroutineUninterceptedOrRetu * coroutine using a reference to the suspending function. */ @SinceKotlin("1.1") -public header inline fun (suspend R.() -> T).startCoroutineUninterceptedOrReturn( +public expect inline fun (suspend R.() -> T).startCoroutineUninterceptedOrReturn( receiver: R, completion: Continuation ): Any? @SinceKotlin("1.1") -public header fun (suspend () -> T).createCoroutineUnchecked( +public expect fun (suspend () -> T).createCoroutineUnchecked( completion: Continuation ): Continuation @SinceKotlin("1.1") -public header fun (suspend R.() -> T).createCoroutineUnchecked( +public expect fun (suspend R.() -> T).createCoroutineUnchecked( receiver: R, completion: Continuation ): Continuation diff --git a/libraries/stdlib/common/src/kotlin/JvmAnnotationsH.kt b/libraries/stdlib/common/src/kotlin/JvmAnnotationsH.kt index 6e8a8842817..373e280241b 100644 --- a/libraries/stdlib/common/src/kotlin/JvmAnnotationsH.kt +++ b/libraries/stdlib/common/src/kotlin/JvmAnnotationsH.kt @@ -3,9 +3,9 @@ package kotlin.jvm import kotlin.annotation.AnnotationTarget.* @Target(FUNCTION, PROPERTY_GETTER, PROPERTY_SETTER, FILE) -header annotation class JvmName(val name: String) +expect annotation class JvmName(val name: String) @Target(FILE) -header annotation class JvmMultifileClass +expect annotation class JvmMultifileClass -header annotation class JvmField +expect annotation class JvmField diff --git a/libraries/stdlib/common/src/kotlin/KotlinH.kt b/libraries/stdlib/common/src/kotlin/KotlinH.kt index 1674d90ffdb..847ea95b798 100644 --- a/libraries/stdlib/common/src/kotlin/KotlinH.kt +++ b/libraries/stdlib/common/src/kotlin/KotlinH.kt @@ -18,101 +18,101 @@ package kotlin import kotlin.annotation.AnnotationTarget.* -open header class Error : Throwable { +open expect class Error : Throwable { constructor() constructor(message: String) } -open header class Exception : Throwable { +open expect class Exception : Throwable { constructor() constructor(message: String) } -open header class IllegalArgumentException : RuntimeException { +open expect class IllegalArgumentException : RuntimeException { constructor() constructor(message: String) } -open header class IllegalStateException : RuntimeException { +open expect class IllegalStateException : RuntimeException { constructor() constructor(message: String) } -open header class IndexOutOfBoundsException : RuntimeException { +open expect class IndexOutOfBoundsException : RuntimeException { constructor() constructor(message: String) } -open header class NoSuchElementException : RuntimeException { +open expect class NoSuchElementException : RuntimeException { constructor() constructor(message: String) } -open header class RuntimeException : Exception { +open expect class RuntimeException : Exception { constructor() constructor(message: String) } -open header class UnsupportedOperationException : RuntimeException { +open expect class UnsupportedOperationException : RuntimeException { constructor() constructor(message: String) } // TODO: Provide typealias impl in stdlib-jvm -open header class AssertionError : Error { +open expect class AssertionError : Error { constructor() constructor(message: String) } -header interface Comparator { +expect interface Comparator { fun compare(a: T, b: T): Int } -header inline fun Comparator(crossinline comparison: (a: T, b: T) -> Int): Comparator +expect inline fun Comparator(crossinline comparison: (a: T, b: T) -> Int): Comparator // From kotlin.kt -internal header fun arrayOfNulls(reference: Array, size: Int): Array -internal inline header fun Map.toSingletonMapOrSelf(): Map -internal inline header fun Map.toSingletonMap(): Map -internal inline header fun Array.copyToArrayOfAny(isVarargs: Boolean): Array +internal expect fun arrayOfNulls(reference: Array, size: Int): Array +internal inline expect fun Map.toSingletonMapOrSelf(): Map +internal inline expect fun Map.toSingletonMap(): Map +internal inline expect fun Array.copyToArrayOfAny(isVarargs: Boolean): Array -internal header interface Serializable +internal expect interface Serializable // 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 +expect fun Double.isNaN(): Boolean +expect fun Float.isNaN(): Boolean +expect fun Double.isInfinite(): Boolean +expect fun Float.isInfinite(): Boolean +expect fun Double.isFinite(): Boolean +expect fun Float.isFinite(): Boolean // From concurrent.kt @Target(PROPERTY, FIELD) -header annotation class Volatile +expect annotation class Volatile -inline header fun synchronized(lock: Any, crossinline block: () -> R): R +inline expect fun synchronized(lock: Any, crossinline block: () -> R): R // from lazy.kt -public header fun lazy(initializer: () -> T): Lazy +public expect fun lazy(initializer: () -> T): Lazy /** * Creates a new instance of the [Lazy] that uses the specified initialization function [initializer]. * * The [mode] parameter is ignored. */ -public header fun lazy(mode: LazyThreadSafetyMode, initializer: () -> T): Lazy +public expect fun lazy(mode: LazyThreadSafetyMode, initializer: () -> T): Lazy /** * Creates a new instance of the [Lazy] that uses the specified initialization function [initializer]. * * The [lock] parameter is ignored. */ -public header fun lazy(lock: Any?, initializer: () -> T): Lazy +public expect fun lazy(lock: Any?, initializer: () -> T): Lazy diff --git a/libraries/stdlib/common/src/kotlin/SequencesH.kt b/libraries/stdlib/common/src/kotlin/SequencesH.kt index 54bb012610f..03b3767aa75 100644 --- a/libraries/stdlib/common/src/kotlin/SequencesH.kt +++ b/libraries/stdlib/common/src/kotlin/SequencesH.kt @@ -1,6 +1,6 @@ package kotlin.sequences -internal header class ConstrainedOnceSequence : Sequence { +internal expect class ConstrainedOnceSequence : Sequence { constructor(sequence: Sequence) override fun iterator(): Iterator diff --git a/libraries/stdlib/common/src/kotlin/TextH.kt b/libraries/stdlib/common/src/kotlin/TextH.kt index f0f8020cad4..928dad577f9 100644 --- a/libraries/stdlib/common/src/kotlin/TextH.kt +++ b/libraries/stdlib/common/src/kotlin/TextH.kt @@ -16,13 +16,13 @@ package kotlin.text -header interface Appendable { +expect interface Appendable { fun append(c: Char): Appendable fun append(csq: CharSequence?): Appendable fun append(csq: CharSequence?, start: Int, end: Int): Appendable } -header class StringBuilder : Appendable, CharSequence { +expect class StringBuilder : Appendable, CharSequence { constructor() constructor(capacity: Int) constructor(seq: CharSequence) @@ -38,7 +38,7 @@ header class StringBuilder : Appendable, CharSequence { fun append(obj: Any?): StringBuilder } -header class Regex { +expect class Regex { constructor(pattern: String) constructor(pattern: String, option: RegexOption) constructor(pattern: String, options: Set) @@ -65,11 +65,11 @@ header class Regex { } } -header class MatchGroup { +expect class MatchGroup { val value: String } -header enum class RegexOption { +expect enum class RegexOption { IGNORE_CASE, MULTILINE } @@ -77,50 +77,50 @@ header enum class RegexOption { // From char.kt -header fun Char.isWhitespace(): Boolean -header fun Char.toLowerCase(): Char -header fun Char.toUpperCase(): Char -header fun Char.isHighSurrogate(): Boolean -header fun Char.isLowSurrogate(): Boolean +expect fun Char.isWhitespace(): Boolean +expect fun Char.toLowerCase(): Char +expect fun Char.toUpperCase(): Char +expect fun Char.isHighSurrogate(): Boolean +expect fun Char.isLowSurrogate(): Boolean // From string.kt -internal header fun String.nativeIndexOf(str: String, fromIndex: Int): Int -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 +internal expect fun String.nativeIndexOf(str: String, fromIndex: Int): Int +internal expect fun String.nativeLastIndexOf(str: String, fromIndex: Int): Int +internal expect fun String.nativeStartsWith(s: String, position: Int): Boolean +internal expect 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 expect fun String.substring(startIndex: Int): String +public expect 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 +public expect inline fun String.toUpperCase(): String +public expect inline fun String.toLowerCase(): String +public expect inline fun String.capitalize(): String +public expect inline fun String.decapitalize(): String +public expect 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 +expect fun String.replace(oldChar: Char, newChar: Char): String +expect fun String.replace(oldChar: Char, newChar: Char, ignoreCase: Boolean): String +expect fun String.replace(oldValue: String, newValue: String): String +expect fun String.replace(oldValue: String, newValue: String, ignoreCase: Boolean): String +expect fun String.replaceFirst(oldChar: Char, newChar: Char): String +expect fun String.replaceFirst(oldChar: Char, newChar: Char, ignoreCase: Boolean): String +expect fun String.replaceFirst(oldValue: String, newValue: String): String +expect fun String.replaceFirst(oldValue: String, newValue: String, ignoreCase: Boolean): String +expect fun String?.equals(other: String?): Boolean +expect fun String?.equals(other: String?, ignoreCase: Boolean): Boolean // From stringsCode.kt -internal inline header fun String.nativeIndexOf(ch: Char, fromIndex: Int): Int -internal inline header fun String.nativeLastIndexOf(ch: Char, fromIndex: Int): Int +internal inline expect fun String.nativeIndexOf(ch: Char, fromIndex: Int): Int +internal inline expect fun String.nativeLastIndexOf(ch: Char, fromIndex: Int): Int -header fun CharSequence.isBlank(): Boolean -header fun CharSequence.regionMatches(thisOffset: Int, other: CharSequence, otherOffset: Int, length: Int, ignoreCase: Boolean): Boolean +expect fun CharSequence.isBlank(): Boolean +expect fun CharSequence.regionMatches(thisOffset: Int, other: CharSequence, otherOffset: Int, length: Int, ignoreCase: Boolean): Boolean @@ -128,76 +128,76 @@ header fun CharSequence.regionMatches(thisOffset: Int, other: CharSequence, othe * Parses the string as a signed [Byte] number and returns the result. * @throws NumberFormatException if the string is not a valid representation of a number. */ -header fun String.toByte(): Byte +expect fun String.toByte(): Byte /** * Parses the string as a signed [Byte] number and returns the result. * @throws NumberFormatException if the string is not a valid representation of a number. */ -header fun String.toByte(radix: Int): Byte +expect fun String.toByte(radix: Int): Byte /** * Parses the string as a [Short] number and returns the result. * @throws NumberFormatException if the string is not a valid representation of a number. */ -header fun String.toShort(): Short +expect fun String.toShort(): Short /** * Parses the string as a [Short] number and returns the result. * @throws NumberFormatException if the string is not a valid representation of a number. */ -header fun String.toShort(radix: Int): Short +expect fun String.toShort(radix: Int): Short /** * Parses the string as an [Int] number and returns the result. * @throws NumberFormatException if the string is not a valid representation of a number. */ -header fun String.toInt(): Int +expect fun String.toInt(): Int /** * Parses the string as an [Int] number and returns the result. * @throws NumberFormatException if the string is not a valid representation of a number. */ -header fun String.toInt(radix: Int): Int +expect fun String.toInt(radix: Int): Int /** * Parses the string as a [Long] number and returns the result. * @throws NumberFormatException if the string is not a valid representation of a number. */ -header fun String.toLong(): Long +expect fun String.toLong(): Long /** * Parses the string as a [Long] number and returns the result. * @throws NumberFormatException if the string is not a valid representation of a number. */ -header fun String.toLong(radix: Int): Long +expect fun String.toLong(radix: Int): Long /** * Parses the string as a [Double] number and returns the result. * @throws NumberFormatException if the string is not a valid representation of a number. */ -header fun String.toDouble(): Double +expect fun String.toDouble(): Double /** * Parses the string as a [Float] number and returns the result. * @throws NumberFormatException if the string is not a valid representation of a number. */ -header fun String.toFloat(): Float +expect fun String.toFloat(): Float /** * Parses the string as a [Double] number and returns the result * or `null` if the string is not a valid representation of a number. */ -header fun String.toDoubleOrNull(): Double? +expect fun String.toDoubleOrNull(): Double? /** * Parses the string as a [Float] number and returns the result * or `null` if the string is not a valid representation of a number. */ -header fun String.toFloatOrNull(): Float? +expect fun String.toFloatOrNull(): Float? @PublishedApi -internal header fun checkRadix(radix: Int): Int -internal header fun digitOf(char: Char, radix: Int): Int +internal expect fun checkRadix(radix: Int): Int +internal expect fun digitOf(char: Char, radix: Int): Int diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/multiplatformProject/lib/src/main/kotlin/PlatformClass.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/multiplatformProject/lib/src/main/kotlin/PlatformClass.kt index 405238ed8b7..526586c399e 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/multiplatformProject/lib/src/main/kotlin/PlatformClass.kt +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/multiplatformProject/lib/src/main/kotlin/PlatformClass.kt @@ -1,6 +1,6 @@ package foo -header class PlatformClass { +expect class PlatformClass { val value: String } diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/multiplatformProject/lib/src/test/kotlin/PlatformTest.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/multiplatformProject/lib/src/test/kotlin/PlatformTest.kt index f6da234ab3e..2688286a168 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/multiplatformProject/lib/src/test/kotlin/PlatformTest.kt +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/multiplatformProject/lib/src/test/kotlin/PlatformTest.kt @@ -1,6 +1,6 @@ package foo -header class PlatformTest { +expect class PlatformTest { val value: PlatformClass } diff --git a/libraries/tools/kotlin-maven-plugin-test/src/it/test-multiplatform/shared/src/main/kotlin/org/jetbrains/api.kt b/libraries/tools/kotlin-maven-plugin-test/src/it/test-multiplatform/shared/src/main/kotlin/org/jetbrains/api.kt index f881a47de90..5d9dcf70a38 100644 --- a/libraries/tools/kotlin-maven-plugin-test/src/it/test-multiplatform/shared/src/main/kotlin/org/jetbrains/api.kt +++ b/libraries/tools/kotlin-maven-plugin-test/src/it/test-multiplatform/shared/src/main/kotlin/org/jetbrains/api.kt @@ -1,6 +1,6 @@ package org.jetbrains -header fun doMain() +expect fun doMain() fun getGreeting() : String { return "Hello, World!"