Fix warnings related to OptIn/UseExperimental
This commit is contained in:
+1
@@ -48,6 +48,7 @@ class CompileServiceClientSideImpl(
|
||||
|
||||
override fun startKeepAlives() {
|
||||
val keepAliveMessage = Server.KeepAliveMessage<CompileServiceServerSide>()
|
||||
@OptIn(ObsoleteCoroutinesApi::class)
|
||||
GlobalScope.async(newSingleThreadContext("keepAliveThread")) {
|
||||
delay(KEEPALIVE_PERIOD * 4)
|
||||
while (true) {
|
||||
|
||||
+12
-9
@@ -5,24 +5,25 @@
|
||||
|
||||
package org.jetbrains.kotlin.daemon.common.experimental
|
||||
|
||||
import io.ktor.network.selector.ActorSelectorManager
|
||||
import io.ktor.network.sockets.aSocket
|
||||
import kotlinx.coroutines.*
|
||||
import io.ktor.network.selector.*
|
||||
import io.ktor.network.sockets.*
|
||||
import io.ktor.util.*
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import org.jetbrains.kotlin.daemon.common.LoopbackNetworkInterface
|
||||
import org.jetbrains.kotlin.daemon.common.experimental.socketInfrastructure.ServerSocketWrapper
|
||||
import org.jetbrains.kotlin.daemon.common.*
|
||||
import java.io.IOException
|
||||
import java.io.Serializable
|
||||
import java.net.*
|
||||
import java.rmi.server.RMIClientSocketFactory
|
||||
import java.rmi.server.RMIServerSocketFactory
|
||||
import java.net.InetAddress
|
||||
import java.net.InetSocketAddress
|
||||
import java.util.*
|
||||
|
||||
|
||||
object LoopbackNetworkInterfaceKtor {
|
||||
|
||||
val serverLoopbackSocketFactoryKtor by lazy { ServerLoopbackSocketFactoryKtor() }
|
||||
val clientLoopbackSocketFactoryKtor by lazy { ClientLoopbackSocketFactoryKtor() }
|
||||
|
||||
@KtorExperimentalAPI
|
||||
val selectorMgr = ActorSelectorManager(Dispatchers.IO)
|
||||
|
||||
class ServerLoopbackSocketFactoryKtor : Serializable {
|
||||
@@ -30,6 +31,7 @@ object LoopbackNetworkInterfaceKtor {
|
||||
override fun hashCode(): Int = super.hashCode()
|
||||
|
||||
@Throws(IOException::class)
|
||||
@OptIn(KtorExperimentalAPI::class)
|
||||
fun createServerSocket(port: Int) =
|
||||
aSocket(selectorMgr)
|
||||
.tcp()
|
||||
@@ -37,6 +39,7 @@ object LoopbackNetworkInterfaceKtor {
|
||||
}
|
||||
|
||||
class ClientLoopbackSocketFactoryKtor : LoopbackNetworkInterface.AbstractClientLoopbackSocketFactory<io.ktor.network.sockets.Socket>() {
|
||||
@OptIn(KtorExperimentalAPI::class)
|
||||
override fun socketCreate(host: String, port: Int): io.ktor.network.sockets.Socket =
|
||||
runBlocking { aSocket(selectorMgr).tcp().connect(InetSocketAddress(host, port)) }
|
||||
}
|
||||
@@ -63,4 +66,4 @@ fun findPortForSocket(attempts: Int, portRangeStart: Int, portRangeEnd: Int): Se
|
||||
}
|
||||
}
|
||||
throw IllegalStateException("Cannot find free socketPort in $attempts attempts", lastException)
|
||||
}
|
||||
}
|
||||
|
||||
+6
@@ -1,3 +1,8 @@
|
||||
/*
|
||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.daemon.common.experimental.socketInfrastructure
|
||||
|
||||
import io.ktor.network.sockets.Socket
|
||||
@@ -114,6 +119,7 @@ abstract class DefaultAuthorizableClient<ServerType : ServerBase>(
|
||||
return actualResult as T
|
||||
}
|
||||
|
||||
@OptIn(ObsoleteCoroutinesApi::class, ExperimentalCoroutinesApi::class)
|
||||
override suspend fun connectToServer() {
|
||||
|
||||
writeActor = GlobalScope.actor(capacity = Channel.UNLIMITED) {
|
||||
|
||||
+5
@@ -1,3 +1,8 @@
|
||||
/*
|
||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.daemon.common.experimental.socketInfrastructure
|
||||
|
||||
import io.ktor.network.sockets.ServerSocket
|
||||
|
||||
+12
-4
@@ -1,9 +1,15 @@
|
||||
/*
|
||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.daemon.common.experimental.socketInfrastructure
|
||||
|
||||
import io.ktor.network.sockets.Socket
|
||||
import io.ktor.network.sockets.openReadChannel
|
||||
import io.ktor.network.sockets.openWriteChannel
|
||||
import kotlinx.coroutines.*
|
||||
import io.ktor.network.sockets.*
|
||||
import kotlinx.coroutines.CompletableDeferred
|
||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
import kotlinx.coroutines.ObsoleteCoroutinesApi
|
||||
import kotlinx.coroutines.channels.Channel
|
||||
import kotlinx.coroutines.channels.actor
|
||||
import kotlinx.coroutines.channels.consumeEach
|
||||
@@ -45,6 +51,7 @@ class ByteReadChannelWrapper(readChannel: ByteReadChannel, private val log: Logg
|
||||
}
|
||||
|
||||
// TODO : replace GlobalScope with something more explicit here and below.
|
||||
@OptIn(ObsoleteCoroutinesApi::class, ExperimentalCoroutinesApi::class)
|
||||
private val readActor = GlobalScope.actor<ReadQuery>(capacity = Channel.UNLIMITED) {
|
||||
consumeEach { message ->
|
||||
if (!readChannel.isClosedForRead) {
|
||||
@@ -145,6 +152,7 @@ class ByteWriteChannelWrapper(writeChannel: ByteWriteChannel, private val log: L
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(ObsoleteCoroutinesApi::class, ExperimentalCoroutinesApi::class)
|
||||
private val writeActor = GlobalScope.actor<WriteActorQuery>(capacity = Channel.UNLIMITED) {
|
||||
consumeEach { message ->
|
||||
if (!writeChannel.isClosedForWrite) {
|
||||
|
||||
+2
@@ -6,6 +6,7 @@
|
||||
package org.jetbrains.kotlin.daemon.experimental.unit
|
||||
|
||||
import io.ktor.network.sockets.aSocket
|
||||
import io.ktor.util.*
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
import kotlinx.coroutines.async
|
||||
import kotlinx.coroutines.runBlocking
|
||||
@@ -24,6 +25,7 @@ import java.io.ObjectOutputStream
|
||||
import java.net.InetSocketAddress
|
||||
import java.util.logging.Logger
|
||||
|
||||
@OptIn(KtorExperimentalAPI::class)
|
||||
class TestServer(val serverPort: Int = 6999) {
|
||||
private val serverSocket = aSocket(selectorMgr).tcp().bind(InetSocketAddress(serverPort))
|
||||
private val log = Logger.getLogger("TestServer")
|
||||
|
||||
+6
-10
@@ -10,15 +10,13 @@ package org.jetbrains.kotlin.daemon.experimental
|
||||
import com.intellij.openapi.util.Disposer
|
||||
import com.intellij.openapi.vfs.impl.ZipHandler
|
||||
import com.intellij.openapi.vfs.impl.jar.CoreJarFileSystem
|
||||
import io.ktor.network.sockets.*
|
||||
import kotlinx.coroutines.*
|
||||
import kotlinx.coroutines.channels.Channel
|
||||
import kotlinx.coroutines.channels.actor
|
||||
import kotlinx.coroutines.channels.consumeEach
|
||||
import org.jetbrains.kotlin.cli.common.CLICompiler
|
||||
import org.jetbrains.kotlin.cli.common.ExitCode
|
||||
import org.jetbrains.kotlin.cli.common.arguments.K2JSCompilerArguments
|
||||
import org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments
|
||||
import org.jetbrains.kotlin.cli.common.messages.MessageCollector
|
||||
import org.jetbrains.kotlin.cli.common.KOTLIN_COMPILER_ENVIRONMENT_KEEPALIVE_PROPERTY
|
||||
import org.jetbrains.kotlin.cli.common.repl.ReplCheckResult
|
||||
import org.jetbrains.kotlin.cli.common.repl.ReplCodeLine
|
||||
import org.jetbrains.kotlin.cli.common.repl.ReplCompileResult
|
||||
@@ -29,7 +27,10 @@ import org.jetbrains.kotlin.cli.metadata.K2MetadataCompiler
|
||||
import org.jetbrains.kotlin.config.Services
|
||||
import org.jetbrains.kotlin.daemon.CompileServiceImplBase
|
||||
import org.jetbrains.kotlin.daemon.CompilerSelector
|
||||
import org.jetbrains.kotlin.daemon.EventManager
|
||||
import org.jetbrains.kotlin.daemon.common.*
|
||||
import org.jetbrains.kotlin.daemon.common.experimental.*
|
||||
import org.jetbrains.kotlin.daemon.common.experimental.socketInfrastructure.*
|
||||
import org.jetbrains.kotlin.daemon.experimental.CompileServiceTaskScheduler.*
|
||||
import org.jetbrains.kotlin.daemon.nowSeconds
|
||||
import org.jetbrains.kotlin.daemon.report.experimental.CompileServicesFacadeMessageCollector
|
||||
@@ -45,12 +46,6 @@ import java.util.concurrent.TimeUnit
|
||||
import java.util.logging.Level
|
||||
import java.util.logging.Logger
|
||||
import kotlin.concurrent.schedule
|
||||
import org.jetbrains.kotlin.daemon.common.experimental.socketInfrastructure.*
|
||||
import org.jetbrains.kotlin.daemon.common.experimental.*
|
||||
import io.ktor.network.sockets.*
|
||||
import org.jetbrains.kotlin.cli.common.KOTLIN_COMPILER_ENVIRONMENT_KEEPALIVE_PROPERTY
|
||||
import org.jetbrains.kotlin.daemon.EventManager
|
||||
import org.jetbrains.kotlin.daemon.report.DaemonMessageReporter
|
||||
|
||||
// TODO: this classes should replace their non-experimental versions eventually.
|
||||
|
||||
@@ -79,6 +74,7 @@ private class CompileServiceTaskScheduler(log: Logger) {
|
||||
|
||||
fun isShutdownActionInProgress() = shutdownActionInProgress
|
||||
|
||||
@OptIn(ObsoleteCoroutinesApi::class, ExperimentalCoroutinesApi::class)
|
||||
private val queriesActor = GlobalScope.actor<CompileServiceTask>(capacity = Channel.UNLIMITED) {
|
||||
var currentTaskId = 0
|
||||
var shutdownTask: ExclusiveTask? = null
|
||||
|
||||
@@ -71,6 +71,7 @@ class ConeIntegerLiteralTypeImpl : ConeIntegerLiteralType {
|
||||
return approximatedType.withNullability(nullability)
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalUnsignedTypes::class)
|
||||
companion object {
|
||||
fun createType(classId: ClassId): ConeClassLikeType {
|
||||
return ConeClassLikeTypeImpl(ConeClassLikeLookupTagImpl(classId), emptyArray(), false)
|
||||
|
||||
+2
@@ -201,6 +201,7 @@ internal class UIntProgressionType(symbols: Symbols<CommonBackendContext>) :
|
||||
unsignedType = symbols.uInt!!.defaultType,
|
||||
unsignedConversionFunction = symbols.toUIntByExtensionReceiver.getValue(symbols.int)
|
||||
) {
|
||||
@OptIn(ExperimentalUnsignedTypes::class)
|
||||
override fun DeclarationIrBuilder.minValueExpression() = irInt(UInt.MIN_VALUE.toInt())
|
||||
|
||||
override fun DeclarationIrBuilder.zeroStepExpression() = irInt(0)
|
||||
@@ -218,6 +219,7 @@ internal class ULongProgressionType(symbols: Symbols<CommonBackendContext>) :
|
||||
unsignedType = symbols.uLong!!.defaultType,
|
||||
unsignedConversionFunction = symbols.toULongByExtensionReceiver.getValue(symbols.long)
|
||||
) {
|
||||
@OptIn(ExperimentalUnsignedTypes::class)
|
||||
override fun DeclarationIrBuilder.minValueExpression() = irLong(ULong.MIN_VALUE.toLong())
|
||||
|
||||
override fun DeclarationIrBuilder.zeroStepExpression() = irLong(0)
|
||||
|
||||
+1
@@ -222,6 +222,7 @@ class FoldConstantLowering(
|
||||
}
|
||||
|
||||
if (const.type.isUnsigned()) {
|
||||
@OptIn(ExperimentalUnsignedTypes::class)
|
||||
when (val kind = const.kind) {
|
||||
is IrConstKind.Byte ->
|
||||
return kind.valueOf(const).toUByte().toString()
|
||||
|
||||
+3
-2
@@ -210,5 +210,6 @@ public fun cityHash64(s: ByteArray, pos: Int = 0, len: Int = s.size): ULong {
|
||||
)
|
||||
}
|
||||
|
||||
fun String.cityHash64() = cityHash64(this.toByteArray()).toLong()
|
||||
|
||||
@OptIn(ExperimentalUnsignedTypes::class)
|
||||
fun String.cityHash64(): Long =
|
||||
cityHash64(this.toByteArray()).toLong()
|
||||
|
||||
@@ -23,7 +23,7 @@ internal fun KotlinType.minValue(): Long {
|
||||
}
|
||||
}
|
||||
|
||||
@ExperimentalUnsignedTypes
|
||||
@OptIn(ExperimentalUnsignedTypes::class)
|
||||
internal fun KotlinType.maxValue(): Long {
|
||||
return when {
|
||||
KotlinBuiltIns.isByte(this) -> Byte.MAX_VALUE.toLong()
|
||||
@@ -63,4 +63,4 @@ internal val ModuleDescriptor.allUnsignedLiteralTypes: Collection<KotlinType>
|
||||
)
|
||||
} else {
|
||||
emptyList()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,6 +47,7 @@ compileKotlin {
|
||||
"-Xnormalize-constructor-calls=enable",
|
||||
"-Xno-optimized-callable-references",
|
||||
"-Xno-kotlin-nothing-value-exception",
|
||||
"-Xopt-in=kotlin.RequiresOptIn",
|
||||
"-module-name", "kotlin-reflection"]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -436,10 +436,10 @@ internal class MapBuilder<K, V> private constructor(
|
||||
private const val INITIAL_MAX_PROBE_DISTANCE = 2
|
||||
private const val TOMBSTONE = -1
|
||||
|
||||
@UseExperimental(ExperimentalStdlibApi::class)
|
||||
@OptIn(ExperimentalStdlibApi::class)
|
||||
private fun computeHashSize(capacity: Int): Int = (capacity.coerceAtLeast(1) * 3).takeHighestOneBit()
|
||||
|
||||
@UseExperimental(ExperimentalStdlibApi::class)
|
||||
@OptIn(ExperimentalStdlibApi::class)
|
||||
private fun computeShift(hashSize: Int): Int = hashSize.countLeadingZeroBits() + 1
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user