Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump Kotlin to 1.5.0-RC #19

Merged
merged 1 commit into from
Apr 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 4 additions & 19 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.jetbrains.dokka.gradle.DokkaTask

plugins {
kotlin("multiplatform") version "1.4.30"
kotlin("multiplatform") version "1.5.0-RC"
id("org.jetbrains.dokka") version "1.4.32"
`maven-publish`
signing
Expand Down Expand Up @@ -51,16 +51,8 @@ kotlin {
}

val commonTest by getting {
dependencies {
implementation(kotlin("test-common"))
implementation(kotlin("test-annotations-common"))
}
}

val jvmTest by getting {
dependencies {
implementation(kotlin("test"))
implementation(kotlin("test-junit"))
}
}

Expand All @@ -75,12 +67,6 @@ kotlin {
dependsOn(commonTest)
}

val jsTest by getting {
dependencies {
implementation(kotlin("test-js"))
}
}

configure(otherTargets) {
compilations["main"].defaultSourceSet.dependsOn(nativeJsMain)
compilations["test"].defaultSourceSet.dependsOn(nativeJsTest)
Expand All @@ -90,10 +76,10 @@ kotlin {
}

val javadocJar by tasks.registering(Jar::class) {
val dokkaJavadoc = tasks.named<DokkaTask>("dokkaHtml")
dependsOn(dokkaJavadoc)
val dokkaHtml = tasks.named<DokkaTask>("dokkaHtml")
dependsOn(dokkaHtml)
archiveClassifier.set("javadoc")
from(dokkaJavadoc.get().outputDirectory)
from(dokkaHtml.get().outputDirectory)
}

signing {
Expand Down Expand Up @@ -159,7 +145,6 @@ publishing {
tasks.withType<KotlinCompile>().configureEach {
kotlinOptions {
jvmTarget = "1.8"
useIR = true
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
@file:JvmMultifileClass
@file:JvmName("MathKt")

package dev.erikchristensen.javamath2kmp

import kotlin.jvm.JvmMultifileClass
import kotlin.jvm.JvmName

infix fun Long.plusExact(other: Int): Long = this plusExact other.toLong()
infix fun Long.minusExact(other: Int): Long = this minusExact other.toLong()
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
@file:JvmMultifileClass
@file:JvmName("MathKt")

package dev.erikchristensen.javamath2kmp

import kotlin.jvm.JvmMultifileClass
import kotlin.jvm.JvmName

expect infix fun Long.floorMod(other: Long): Long
expect infix fun Int.floorMod(other: Int): Int
expect infix fun Long.floorMod(other: Int): Int
Expand Down
3 changes: 3 additions & 0 deletions src/jvmMain/kotlin/Math.kt → src/jvmMain/kotlin/Platform.kt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
@file:JvmMultifileClass
@file:JvmName("MathKt")

package dev.erikchristensen.javamath2kmp

actual infix fun Long.floorMod(other: Long): Long = Math.floorMod(this, other)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,30 +1,15 @@
package dev.erikchristensen.javamath2kmp

actual infix fun Long.floorMod(other: Long): Long = (this % other + other) % other
actual infix fun Int.floorMod(other: Int): Int = (this % other + other) % other
actual infix fun Long.floorMod(other: Int): Int = (this floorMod other.toLong()).toInt()
import kotlin.mod as kotlinMod
import kotlin.floorDiv as kotlinFloorDiv

actual infix fun Long.floorDiv(other: Long): Long {
val result = this / other
actual infix fun Long.floorMod(other: Long): Long = kotlinMod(other)
actual infix fun Int.floorMod(other: Int): Int = kotlinMod(other)
actual infix fun Long.floorMod(other: Int): Int = kotlinMod(other)

return if (this xor other < 0 && result * other != this) {
result - 1
} else {
result
}
}

actual infix fun Int.floorDiv(other: Int): Int {
val result = this / other

return if (this xor other < 0 && result * other != this) {
result - 1
} else {
result
}
}

actual infix fun Long.floorDiv(other: Int): Long = this floorDiv other.toLong()
actual infix fun Long.floorDiv(other: Long): Long = kotlinFloorDiv(other)
actual infix fun Int.floorDiv(other: Int): Int = kotlinFloorDiv(other)
actual infix fun Long.floorDiv(other: Int): Long = kotlinFloorDiv(other)

actual infix fun Long.plusExact(other: Long): Long {
val result = this + other
Expand Down