Fix "Should be replaced with Kotlin function" warnings
This commit is contained in:
+2
-1
@@ -34,6 +34,7 @@ import org.jetbrains.org.objectweb.asm.tree.*
|
||||
import org.jetbrains.org.objectweb.asm.tree.analysis.Frame
|
||||
import org.jetbrains.org.objectweb.asm.tree.analysis.SourceInterpreter
|
||||
import org.jetbrains.org.objectweb.asm.tree.analysis.SourceValue
|
||||
import kotlin.math.max
|
||||
|
||||
private const val COROUTINES_DEBUG_METADATA_VERSION = 1
|
||||
|
||||
@@ -628,7 +629,7 @@ class CoroutineTransformerMethodVisitor(
|
||||
spilledToVariableMapping.add(spilledToVariable)
|
||||
|
||||
varsCountByType.forEach {
|
||||
maxVarsCountByType[it.key] = Math.max(maxVarsCountByType[it.key] ?: 0, it.value)
|
||||
maxVarsCountByType[it.key] = max(maxVarsCountByType[it.key] ?: 0, it.value)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -27,6 +27,7 @@ import org.jetbrains.org.objectweb.asm.tree.*
|
||||
import org.jetbrains.org.objectweb.asm.tree.analysis.BasicValue
|
||||
import org.jetbrains.org.objectweb.asm.tree.analysis.Frame
|
||||
import org.jetbrains.org.objectweb.asm.tree.analysis.Interpreter
|
||||
import kotlin.math.max
|
||||
|
||||
/**
|
||||
* In cases like:
|
||||
@@ -135,7 +136,7 @@ class UninitializedStoresProcessor(
|
||||
nextVarIndex += type.size
|
||||
storedTypes.add(type)
|
||||
}
|
||||
methodNode.maxLocals = Math.max(methodNode.maxLocals, nextVarIndex)
|
||||
methodNode.maxLocals = max(methodNode.maxLocals, nextVarIndex)
|
||||
|
||||
methodNode.instructions.insertBefore(insn, insnListOf(
|
||||
TypeInsnNode(Opcodes.NEW, newInsn.desc),
|
||||
|
||||
+2
-1
@@ -22,6 +22,7 @@ import org.jetbrains.org.objectweb.asm.tree.*
|
||||
import java.util.*
|
||||
import kotlin.collections.HashSet
|
||||
import kotlin.collections.LinkedHashSet
|
||||
import kotlin.math.max
|
||||
|
||||
abstract class CoveringTryCatchNodeProcessor(parameterSize: Int) {
|
||||
val tryBlocksMetaInfo: IntervalMetaInfo<TryCatchBlockNodeInfo> = IntervalMetaInfo(this)
|
||||
@@ -42,7 +43,7 @@ abstract class CoveringTryCatchNodeProcessor(parameterSize: Int) {
|
||||
if (curInstr is VarInsnNode || curInstr is IincInsnNode) {
|
||||
val argSize = getLoadStoreArgSize(curInstr.opcode)
|
||||
val varIndex = if (curInstr is VarInsnNode) curInstr.`var` else (curInstr as IincInsnNode).`var`
|
||||
nextFreeLocalIndex = Math.max(nextFreeLocalIndex, varIndex + argSize)
|
||||
nextFreeLocalIndex = max(nextFreeLocalIndex, varIndex + argSize)
|
||||
}
|
||||
|
||||
if (curInstr is LabelNode) {
|
||||
|
||||
@@ -51,6 +51,7 @@ import org.jetbrains.org.objectweb.asm.commons.Method
|
||||
import org.jetbrains.org.objectweb.asm.tree.*
|
||||
import java.util.*
|
||||
import kotlin.collections.HashSet
|
||||
import kotlin.math.max
|
||||
|
||||
abstract class InlineCodegen<out T : BaseExpressionCodegen>(
|
||||
protected val codegen: T,
|
||||
@@ -340,9 +341,9 @@ abstract class InlineCodegen<out T : BaseExpressionCodegen>(
|
||||
var marker = -1
|
||||
val intervals = processor.localVarsMetaInfo.currentIntervals
|
||||
for (interval in intervals) {
|
||||
marker = Math.max(interval.node.index + 1, marker)
|
||||
marker = max(interval.node.index + 1, marker)
|
||||
}
|
||||
while (frameMap.currentSize < Math.max(processor.nextFreeLocalIndex, offsetForFinallyLocalVar + marker)) {
|
||||
while (frameMap.currentSize < max(processor.nextFreeLocalIndex, offsetForFinallyLocalVar + marker)) {
|
||||
frameMap.enterTemp(Type.INT_TYPE)
|
||||
}
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@ import org.jetbrains.org.objectweb.asm.tree.*
|
||||
import org.jetbrains.org.objectweb.asm.tree.analysis.*
|
||||
import org.jetbrains.org.objectweb.asm.util.Printer
|
||||
import java.util.*
|
||||
import kotlin.math.max
|
||||
|
||||
class MethodInliner(
|
||||
private val node: MethodNode,
|
||||
@@ -259,7 +260,7 @@ class MethodInliner(
|
||||
val erasedInvokeFunction = ClosureCodegen.getErasedInvokeFunction(actualInvokeDescriptor)
|
||||
val invokeParameters = erasedInvokeFunction.valueParameters
|
||||
|
||||
val valueParamShift = Math.max(nextLocalIndex, markerShift)//NB: don't inline cause it changes
|
||||
val valueParamShift = max(nextLocalIndex, markerShift)//NB: don't inline cause it changes
|
||||
putStackValuesIntoLocalsForLambdaOnInvoke(
|
||||
listOf(*info.invokeMethod.argumentTypes), valueParameters, invokeParameters, valueParamShift, this, coroutineDesc
|
||||
)
|
||||
|
||||
@@ -32,6 +32,7 @@ import org.jetbrains.org.objectweb.asm.Opcodes
|
||||
import org.jetbrains.org.objectweb.asm.Type
|
||||
import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter
|
||||
import org.jetbrains.org.objectweb.asm.tree.*
|
||||
import kotlin.math.max
|
||||
|
||||
class ReificationArgument(
|
||||
val parameterName: String, val nullable: Boolean, private val arrayDepth: Int
|
||||
@@ -194,7 +195,7 @@ class ReifiedTypeInliner(
|
||||
instructions.remove(stubCheckcast)
|
||||
|
||||
// TODO: refine max stack calculation (it's not always as big as +4)
|
||||
maxStackSize = Math.max(maxStackSize, 4)
|
||||
maxStackSize = max(maxStackSize, 4)
|
||||
|
||||
return true
|
||||
}
|
||||
@@ -214,7 +215,7 @@ class ReifiedTypeInliner(
|
||||
instructions.remove(stubInstanceOf)
|
||||
|
||||
// TODO: refine max stack calculation (it's not always as big as +2)
|
||||
maxStackSize = Math.max(maxStackSize, 2)
|
||||
maxStackSize = max(maxStackSize, 2)
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -229,7 +230,7 @@ class ReifiedTypeInliner(
|
||||
instructions.insert(insn, newMethodNode.instructions)
|
||||
instructions.remove(stubConstNull)
|
||||
|
||||
maxStackSize = Math.max(maxStackSize, stackSize)
|
||||
maxStackSize = max(maxStackSize, stackSize)
|
||||
return true
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ import org.jetbrains.kotlin.codegen.inline.SMAP.Companion.FILE_SECTION
|
||||
import org.jetbrains.kotlin.codegen.inline.SMAP.Companion.LINE_SECTION
|
||||
import org.jetbrains.kotlin.codegen.inline.SMAP.Companion.STRATA_SECTION
|
||||
import java.util.*
|
||||
import kotlin.math.max
|
||||
|
||||
const val KOTLIN_STRATA_NAME = "Kotlin"
|
||||
const val KOTLIN_DEBUG_STRATA_NAME = "KotlinDebug"
|
||||
@@ -217,7 +218,7 @@ open class DefaultSourceMapper(val sourceInfo: SourceInfo) : SourceMapper {
|
||||
val newFileMapping = getOrRegisterNewSource(fileMapping.name, fileMapping.path)
|
||||
fileMapping.lineMappings.forEach {
|
||||
newFileMapping.mapNewInterval(it.source, it.dest, it.range)
|
||||
maxUsedValue = Math.max(it.maxDest, maxUsedValue)
|
||||
maxUsedValue = max(it.maxDest, maxUsedValue)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,6 +47,8 @@ import org.jetbrains.org.objectweb.asm.util.Textifier
|
||||
import org.jetbrains.org.objectweb.asm.util.TraceMethodVisitor
|
||||
import java.io.PrintWriter
|
||||
import java.io.StringWriter
|
||||
import kotlin.math.max
|
||||
import kotlin.math.min
|
||||
|
||||
const val GENERATE_SMAP = true
|
||||
const val NUMBERED_FUNCTION_PREFIX = "kotlin/jvm/functions/Function"
|
||||
@@ -121,8 +123,8 @@ internal fun getMethodNode(
|
||||
return object : MethodNode(Opcodes.API_VERSION, access, name, desc, signature, exceptions) {
|
||||
override fun visitLineNumber(line: Int, start: Label) {
|
||||
super.visitLineNumber(line, start)
|
||||
lines[0] = Math.min(lines[0], line)
|
||||
lines[1] = Math.max(lines[1], line)
|
||||
lines[0] = min(lines[0], line)
|
||||
lines[1] = max(lines[1], line)
|
||||
}
|
||||
}.also {
|
||||
node = it
|
||||
@@ -509,7 +511,7 @@ private fun getIndexAfterLastMarker(node: MethodNode): Int {
|
||||
var result = -1
|
||||
for (variable in node.localVariables) {
|
||||
if (isFakeLocalVariableForInline(variable.name)) {
|
||||
result = Math.max(result, variable.index + 1)
|
||||
result = max(result, variable.index + 1)
|
||||
}
|
||||
}
|
||||
return result
|
||||
|
||||
+2
-1
@@ -31,6 +31,7 @@ import org.jetbrains.org.objectweb.asm.tree.MethodNode
|
||||
import org.jetbrains.org.objectweb.asm.tree.analysis.BasicValue
|
||||
import org.jetbrains.org.objectweb.asm.tree.analysis.Frame
|
||||
import org.jetbrains.org.objectweb.asm.tree.analysis.Interpreter
|
||||
import kotlin.math.max
|
||||
|
||||
internal class FixStackAnalyzer(
|
||||
owner: String,
|
||||
@@ -133,7 +134,7 @@ internal class FixStackAnalyzer(
|
||||
super.push(value)
|
||||
} else {
|
||||
extraStack.add(value)
|
||||
maxExtraStackSize = Math.max(maxExtraStackSize, extraStack.size)
|
||||
maxExtraStackSize = max(maxExtraStackSize, extraStack.size)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+3
-2
@@ -19,6 +19,7 @@ package org.jetbrains.kotlin.codegen.optimization.fixStack
|
||||
import org.jetbrains.org.objectweb.asm.tree.AbstractInsnNode
|
||||
import org.jetbrains.org.objectweb.asm.tree.MethodNode
|
||||
import org.jetbrains.org.objectweb.asm.tree.analysis.BasicValue
|
||||
import kotlin.math.max
|
||||
|
||||
internal class LocalVariablesManager(val context: FixStackContext, val methodNode: MethodNode) {
|
||||
private class AllocatedHandle(val savedStackDescriptor: SavedStackDescriptor, var numRestoreMarkers: Int) {
|
||||
@@ -35,7 +36,7 @@ internal class LocalVariablesManager(val context: FixStackContext, val methodNod
|
||||
private val allocatedHandles = hashMapOf<AbstractInsnNode, AllocatedHandle>()
|
||||
|
||||
private fun updateMaxLocals(newValue: Int) {
|
||||
methodNode.maxLocals = Math.max(methodNode.maxLocals, newValue)
|
||||
methodNode.maxLocals = max(methodNode.maxLocals, newValue)
|
||||
}
|
||||
|
||||
fun allocateVariablesForSaveStackMarker(saveStackMarker: AbstractInsnNode, savedStackValues: List<BasicValue>): SavedStackDescriptor {
|
||||
@@ -67,7 +68,7 @@ internal class LocalVariablesManager(val context: FixStackContext, val methodNod
|
||||
|
||||
private fun getFirstUnusedLocalVariableIndex(): Int =
|
||||
allocatedHandles.values.fold(initialMaxLocals) { index, handle ->
|
||||
Math.max(index, handle.savedStackDescriptor.firstUnusedLocalVarIndex)
|
||||
max(index, handle.savedStackDescriptor.firstUnusedLocalVarIndex)
|
||||
}
|
||||
|
||||
fun markRestoreStackMarkerEmitted(restoreStackMarker: AbstractInsnNode) {
|
||||
|
||||
@@ -20,6 +20,7 @@ import java.io.File
|
||||
import java.io.FileNotFoundException
|
||||
import java.net.URL
|
||||
import java.util.*
|
||||
import kotlin.system.exitProcess
|
||||
|
||||
object Main {
|
||||
private val KOTLIN_HOME: File
|
||||
@@ -28,7 +29,7 @@ object Main {
|
||||
val home = System.getProperty("kotlin.home")
|
||||
if (home == null) {
|
||||
System.err.println("error: no kotlin.home system property was passed")
|
||||
System.exit(1)
|
||||
exitProcess(1)
|
||||
}
|
||||
KOTLIN_HOME = File(home)
|
||||
}
|
||||
@@ -120,7 +121,7 @@ object Main {
|
||||
}
|
||||
catch (e: RunnerException) {
|
||||
System.err.println("error: " + e.message)
|
||||
System.exit(1)
|
||||
exitProcess(1)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -143,7 +144,7 @@ where command may be one of:
|
||||
-version Display Kotlin version
|
||||
-help (-h) Print a synopsis of options
|
||||
""")
|
||||
System.exit(0)
|
||||
exitProcess(0)
|
||||
}
|
||||
|
||||
private fun printVersionAndExit() {
|
||||
@@ -155,6 +156,6 @@ where command may be one of:
|
||||
}
|
||||
|
||||
println("Kotlin version " + version + " (JRE " + System.getProperty("java.runtime.version") + ")")
|
||||
System.exit(0)
|
||||
exitProcess(0)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ import java.io.PrintStream
|
||||
import java.net.URL
|
||||
import java.net.URLConnection
|
||||
import java.util.function.Predicate
|
||||
import kotlin.system.exitProcess
|
||||
|
||||
abstract class CLITool<A : CommonToolArguments> {
|
||||
fun exec(errStream: PrintStream, vararg args: String): ExitCode {
|
||||
@@ -205,7 +206,7 @@ abstract class CLITool<A : CommonToolArguments> {
|
||||
}
|
||||
val exitCode = doMainNoExit(compiler, args)
|
||||
if (exitCode != ExitCode.OK) {
|
||||
System.exit(exitCode.code)
|
||||
exitProcess(exitCode.code)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ import org.jetbrains.kotlin.js.sourceMap.SourceMap3Builder
|
||||
import org.jetbrains.kotlin.js.util.TextOutputImpl
|
||||
import java.io.File
|
||||
import java.io.StringReader
|
||||
import kotlin.system.exitProcess
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
val outputFile = File(args[0])
|
||||
@@ -55,7 +56,7 @@ private fun mergeStdlibParts(outputFile: File, wrapperFile: File, baseDir: File,
|
||||
when (sourceMapParse) {
|
||||
is SourceMapError -> {
|
||||
System.err.println("Error parsing source map file $sourceMapFile: ${sourceMapParse.message}")
|
||||
System.exit(1)
|
||||
exitProcess(1)
|
||||
}
|
||||
is SourceMapSuccess -> {
|
||||
val sourceMap = sourceMapParse.value
|
||||
|
||||
@@ -33,6 +33,7 @@ import java.util.*
|
||||
import java.util.jar.Manifest
|
||||
import java.util.logging.*
|
||||
import kotlin.concurrent.schedule
|
||||
import kotlin.system.exitProcess
|
||||
|
||||
val DAEMON_PERIODIC_CHECK_INTERVAL_MS = 1000L
|
||||
val DAEMON_PERIODIC_SELDOM_CHECK_INTERVAL_MS = 60000L
|
||||
@@ -153,7 +154,7 @@ object KotlinCompileDaemon {
|
||||
timer.schedule(daemonOptions.forceShutdownTimeoutMilliseconds) {
|
||||
cancel()
|
||||
log.info("force JVM shutdown")
|
||||
System.exit(0)
|
||||
exitProcess(0)
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
+1
-1
@@ -48,7 +48,7 @@ class ConditionalJumpInstruction(
|
||||
}
|
||||
|
||||
override val nextInstructions: Collection<Instruction>
|
||||
get() = Arrays.asList(nextOnFalse, nextOnTrue)
|
||||
get() = listOf(nextOnFalse, nextOnTrue)
|
||||
|
||||
override val inputValues: List<PseudoValue>
|
||||
get() = listOfNotNull(conditionValue)
|
||||
|
||||
@@ -56,6 +56,7 @@ import org.jetbrains.kotlin.types.typeUtil.containsTypeAliasParameters
|
||||
import org.jetbrains.kotlin.types.typeUtil.containsTypeAliases
|
||||
import org.jetbrains.kotlin.types.typeUtil.isArrayOfNothing
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.safeAs
|
||||
import kotlin.math.min
|
||||
|
||||
class TypeResolver(
|
||||
private val annotationResolver: AnnotationResolver,
|
||||
@@ -699,7 +700,7 @@ class TypeResolver(
|
||||
var wasStatic = false
|
||||
val result = SmartList<KtTypeProjection>()
|
||||
|
||||
val classifierChainLastIndex = Math.min(classifierDescriptorChain.size, reversedQualifierParts.size) - 1
|
||||
val classifierChainLastIndex = min(classifierDescriptorChain.size, reversedQualifierParts.size) - 1
|
||||
|
||||
for (index in 0..classifierChainLastIndex) {
|
||||
val qualifierPart = reversedQualifierParts[index]
|
||||
@@ -729,7 +730,7 @@ class TypeResolver(
|
||||
|
||||
val nonClassQualifierParts =
|
||||
reversedQualifierParts.subList(
|
||||
Math.min(classifierChainLastIndex + 1, reversedQualifierParts.size),
|
||||
min(classifierChainLastIndex + 1, reversedQualifierParts.size),
|
||||
reversedQualifierParts.size
|
||||
)
|
||||
|
||||
|
||||
@@ -45,6 +45,7 @@ import org.jetbrains.kotlin.types.expressions.DoubleColonExpressionResolver
|
||||
import org.jetbrains.kotlin.types.typeUtil.containsTypeProjectionsInTopLevelArguments
|
||||
import org.jetbrains.kotlin.types.typeUtil.makeNotNullable
|
||||
import java.util.*
|
||||
import kotlin.math.min
|
||||
|
||||
class CandidateResolver(
|
||||
private val argumentTypeResolver: ArgumentTypeResolver,
|
||||
@@ -591,7 +592,7 @@ class CandidateResolver(
|
||||
}
|
||||
|
||||
val typeParameters = functionDescriptor.typeParameters
|
||||
for (i in 0..Math.min(typeParameters.size, ktTypeArguments.size) - 1) {
|
||||
for (i in 0..min(typeParameters.size, ktTypeArguments.size) - 1) {
|
||||
val typeParameterDescriptor = typeParameters[i]
|
||||
val typeArgument = typeArguments[i]
|
||||
val typeReference = ktTypeArguments[i].typeReference
|
||||
@@ -686,7 +687,7 @@ class CandidateResolver(
|
||||
// TODO do not perform substitution for type arguments multiple times
|
||||
val substitutedTypeArguments = typeAliasParametersSubstitutor.safeSubstitute(unsubstitutedType, Variance.INVARIANT).arguments
|
||||
|
||||
for (i in 0..Math.min(typeParameters.size, substitutedTypeArguments.size) - 1) {
|
||||
for (i in 0..min(typeParameters.size, substitutedTypeArguments.size) - 1) {
|
||||
val substitutedTypeProjection = substitutedTypeArguments[i]
|
||||
if (substitutedTypeProjection.isStarProjection) continue
|
||||
|
||||
|
||||
+4
-2
@@ -42,6 +42,8 @@ import org.jetbrains.kotlin.resolve.calls.model.*
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.*
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.types.TypeSubstitutor
|
||||
import kotlin.math.max
|
||||
import kotlin.math.min
|
||||
|
||||
fun StatementGenerator.generateReceiverOrNull(ktDefaultElement: KtElement, receiver: ReceiverValue?): IntermediateValue? =
|
||||
receiver?.let { generateReceiver(ktDefaultElement, receiver) }
|
||||
@@ -220,10 +222,10 @@ fun StatementGenerator.generateVarargExpressionUsing(
|
||||
}
|
||||
|
||||
val varargStartOffset = varargArgument.arguments.fold(Int.MAX_VALUE) { minStartOffset, argument ->
|
||||
Math.min(minStartOffset, argument.asElement().startOffsetSkippingComments)
|
||||
min(minStartOffset, argument.asElement().startOffsetSkippingComments)
|
||||
}
|
||||
val varargEndOffset = varargArgument.arguments.fold(Int.MIN_VALUE) { maxEndOffset, argument ->
|
||||
Math.max(maxEndOffset, argument.asElement().endOffset)
|
||||
max(maxEndOffset, argument.asElement().endOffset)
|
||||
}
|
||||
|
||||
val varargElementType =
|
||||
|
||||
@@ -21,6 +21,7 @@ import com.intellij.psi.LiteralTextEscaper
|
||||
import gnu.trove.TIntArrayList
|
||||
import org.jetbrains.kotlin.psi.psiUtil.getContentRange
|
||||
import org.jetbrains.kotlin.psi.psiUtil.isSingleQuoted
|
||||
import kotlin.math.min
|
||||
|
||||
class KotlinStringLiteralTextEscaper(host: KtStringTemplateExpression) : LiteralTextEscaper<KtStringTemplateExpression>(host) {
|
||||
private var sourceOffsets: IntArray? = null
|
||||
@@ -70,7 +71,7 @@ class KotlinStringLiteralTextEscaper(host: KtStringTemplateExpression) : Literal
|
||||
override fun getOffsetInHost(offsetInDecoded: Int, rangeInsideHost: TextRange): Int {
|
||||
val offsets = sourceOffsets
|
||||
if (offsets == null || offsetInDecoded >= offsets.size) return -1
|
||||
return Math.min(offsets[offsetInDecoded], rangeInsideHost.length) + rangeInsideHost.startOffset
|
||||
return min(offsets[offsetInDecoded], rangeInsideHost.length) + rangeInsideHost.startOffset
|
||||
}
|
||||
|
||||
override fun getRelevantTextRange(): TextRange {
|
||||
|
||||
@@ -33,7 +33,7 @@ class KtClassBody : KtElementImplStub<KotlinPlaceHolderStub<KtClassBody>>, KtDec
|
||||
|
||||
override fun getParent() = parentByStub
|
||||
|
||||
override fun getDeclarations() = Arrays.asList(*getStubOrPsiChildren(DECLARATION_TYPES, KtDeclaration.ARRAY_FACTORY))
|
||||
override fun getDeclarations() = listOf(*getStubOrPsiChildren(DECLARATION_TYPES, KtDeclaration.ARRAY_FACTORY))
|
||||
|
||||
override fun <R, D> accept(visitor: KtVisitor<R, D>, data: D) = visitor.visitClassBody(this, data)
|
||||
|
||||
|
||||
+2
-1
@@ -25,6 +25,7 @@ import org.jetbrains.kotlin.types.*
|
||||
import org.jetbrains.kotlin.types.checker.NewCapturedType
|
||||
import org.jetbrains.kotlin.types.model.*
|
||||
import java.util.*
|
||||
import kotlin.math.max
|
||||
|
||||
class ConstraintInjector(val constraintIncorporator: ConstraintIncorporator, val typeApproximator: TypeApproximator) {
|
||||
private val ALLOWED_DEPTH_DELTA_FOR_INCORPORATION = 1
|
||||
@@ -85,7 +86,7 @@ class ConstraintInjector(val constraintIncorporator: ConstraintIncorporator, val
|
||||
}
|
||||
|
||||
private fun updateAllowedTypeDepth(c: Context, initialType: KotlinTypeMarker) = with(c) {
|
||||
c.maxTypeDepthFromInitialConstraints = Math.max(c.maxTypeDepthFromInitialConstraints, initialType.typeDepth())
|
||||
c.maxTypeDepthFromInitialConstraints = max(c.maxTypeDepthFromInitialConstraints, initialType.typeDepth())
|
||||
}
|
||||
|
||||
private fun Context.shouldWeSkipConstraint(typeVariable: TypeVariableMarker, constraint: Constraint): Boolean {
|
||||
|
||||
+2
-1
@@ -21,6 +21,7 @@ import org.jetbrains.kotlin.types.checker.NewCapturedTypeConstructor
|
||||
import org.jetbrains.kotlin.types.model.*
|
||||
import org.jetbrains.kotlin.utils.SmartList
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.cast
|
||||
import kotlin.math.max
|
||||
|
||||
class NewConstraintSystemImpl(
|
||||
private val constraintInjector: ConstraintInjector,
|
||||
@@ -173,7 +174,7 @@ class NewConstraintSystemImpl(
|
||||
}
|
||||
storage.initialConstraints.addAll(otherSystem.initialConstraints)
|
||||
storage.maxTypeDepthFromInitialConstraints =
|
||||
Math.max(storage.maxTypeDepthFromInitialConstraints, otherSystem.maxTypeDepthFromInitialConstraints)
|
||||
max(storage.maxTypeDepthFromInitialConstraints, otherSystem.maxTypeDepthFromInitialConstraints)
|
||||
storage.errors.addAll(otherSystem.errors)
|
||||
storage.fixedTypeVariables.putAll(otherSystem.fixedTypeVariables)
|
||||
storage.postponedTypeVariables.addAll(otherSystem.postponedTypeVariables)
|
||||
|
||||
@@ -23,8 +23,8 @@ private val BEGIN_MARKER = "<~BEGIN~>"
|
||||
private val END_MARKER = "<~END~>"
|
||||
|
||||
fun CharSequence.substringWithContext(beginIndex: Int, endIndex: Int, range: Int): String {
|
||||
val start = Math.max(0, beginIndex - range)
|
||||
val end = Math.min(this.length, endIndex + range)
|
||||
val start = kotlin.math.max(0, beginIndex - range)
|
||||
val end = kotlin.math.min(this.length, endIndex + range)
|
||||
|
||||
val notFromBegin = start != 0
|
||||
val notToEnd = end != this.length
|
||||
|
||||
Reference in New Issue
Block a user