Fix minor compile warnings

This commit is contained in:
Dmitry Gridin
2019-04-17 17:48:26 +07:00
parent 79793a4bda
commit 37c856290f
226 changed files with 618 additions and 479 deletions
@@ -121,7 +121,7 @@ abstract class IrElementVisitorVoidWithContext : IrElementVisitorVoid {
}
override final fun visitField(declaration: IrField) {
val isDelegated = declaration.descriptor.isDelegated
@Suppress("DEPRECATION") val isDelegated = declaration.descriptor.isDelegated
if (isDelegated) scopeStack.push(ScopeWithIr(Scope(declaration.symbol), declaration))
visitFieldNew(declaration)
if (isDelegated) scopeStack.pop()
@@ -19,7 +19,9 @@ package org.jetbrains.kotlin.backend.common.ir
import org.jetbrains.kotlin.backend.common.DumpIrTreeWithDescriptorsVisitor
import org.jetbrains.kotlin.backend.common.deepCopyWithVariables
import org.jetbrains.kotlin.backend.common.descriptors.*
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.descriptors.ClassKind
import org.jetbrains.kotlin.descriptors.Modality
import org.jetbrains.kotlin.descriptors.Visibilities
import org.jetbrains.kotlin.ir.IrElement
import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET
import org.jetbrains.kotlin.ir.builders.Scope
@@ -43,7 +45,6 @@ import org.jetbrains.kotlin.ir.types.impl.IrSimpleTypeImpl
import org.jetbrains.kotlin.ir.types.impl.makeTypeProjection
import org.jetbrains.kotlin.ir.util.*
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.name.Name
import java.io.StringWriter
@@ -160,7 +161,6 @@ fun IrTypeParameter.copyToWithoutSuperTypes(
shift: Int = 0,
origin: IrDeclarationOrigin = this.origin
): IrTypeParameter {
val source = parent as IrTypeParametersContainer
val descriptor = WrappedTypeParameterDescriptor(symbol.descriptor.annotations, symbol.descriptor.source)
val symbol = IrTypeParameterSymbolImpl(descriptor)
return IrTypeParameterImpl(startOffset, endOffset, origin, symbol, name, shift + index, isReified, variance).also { copied ->
@@ -240,7 +240,8 @@ fun IrFunction.copyValueParametersToStatic(
)
)
}
source.valueParameters.forEachIndexed { i, oldValueParameter ->
for (oldValueParameter in source.valueParameters) {
target.valueParameters.add(
oldValueParameter.copyTo(
target,
@@ -345,6 +346,7 @@ fun IrClass.createImplicitParameterDeclarationWithWrappedDescriptor() {
assert(descriptor.declaredTypeParameters.isEmpty())
}
@Suppress("UNCHECKED_CAST")
fun isElseBranch(branch: IrBranch) = branch is IrElseBranch || ((branch.condition as? IrConst<Boolean>)?.value == true)
fun IrSimpleFunction.isMethodOfAny() =
@@ -183,31 +183,35 @@ class InlineClassLowering(val context: BackendContext) {
override fun lower(irFile: IrFile) {
irFile.transformChildrenVoid(object : IrElementTransformerVoid() {
override fun visitCall(call: IrCall): IrExpression {
call.transformChildrenVoid(this)
val function = call.symbol.owner
override fun visitCall(expression: IrCall): IrExpression {
expression.transformChildrenVoid(this)
val function = expression.symbol.owner
if (function.parent !is IrClass ||
function.isStaticMethodOfClass ||
!function.parentAsClass.isInline ||
(function is IrSimpleFunction && !function.isReal) ||
(function is IrConstructor && function.isPrimary)
) {
return call
return expression
}
return irCall(call, getOrCreateStaticMethod(function), dispatchReceiverAsFirstArgument = (function is IrSimpleFunction))
return irCall(
expression,
getOrCreateStaticMethod(function),
dispatchReceiverAsFirstArgument = (function is IrSimpleFunction)
)
}
override fun visitDelegatingConstructorCall(call: IrDelegatingConstructorCall): IrExpression {
call.transformChildrenVoid(this)
val function = call.symbol.owner
override fun visitDelegatingConstructorCall(expression: IrDelegatingConstructorCall): IrExpression {
expression.transformChildrenVoid(this)
val function = expression.symbol.owner
val klass = function.parentAsClass
return when {
!klass.isInline -> call
function.isPrimary -> irCall(call, function)
else -> irCall(call, getOrCreateStaticMethod(function)).apply {
(0 until call.valueArgumentsCount).forEach {
putValueArgument(it, call.getValueArgument(it)!!)
!klass.isInline -> expression
function.isPrimary -> irCall(expression, function)
else -> irCall(expression, getOrCreateStaticMethod(function)).apply {
(0 until expression.valueArgumentsCount).forEach {
putValueArgument(it, expression.getValueArgument(it)!!)
}
}
}
@@ -78,6 +78,7 @@ abstract class AbstractNamedPhaseWrapper<in Context : CommonBackendContext, Inpu
if (this is SameTypeCompilerPhase<*, *> &&
this !in phaseConfig.enabled
) {
@Suppress("UNCHECKED_CAST")
return input as Output
}
@@ -121,7 +122,7 @@ abstract class AbstractNamedPhaseWrapper<in Context : CommonBackendContext, Inpu
for (post in postconditions) post(output)
for (post in stickyPostconditions) post(output)
if (phaseConfig.checkStickyConditions && this is SameTypeCompilerPhase<*, *>) {
val phaserStateO = phaserState as PhaserState<Output>
@Suppress("UNCHECKED_CAST") val phaserStateO = phaserState as PhaserState<Output>
for (post in phaserStateO.stickyPostconditions) post(output)
}
}
@@ -17,7 +17,7 @@ private class CompositePhase<Context : CommonBackendContext, Input, Output>(
) : CompilerPhase<Context, Input, Output> {
override fun invoke(phaseConfig: PhaseConfig, phaserState: PhaserState<Input>, context: Context, input: Input): Output {
var currentState = phaserState as PhaserState<Any?>
@Suppress("UNCHECKED_CAST") var currentState = phaserState as PhaserState<Any?>
var result = phases.first().invoke(phaseConfig, currentState, context, input)
for ((previous, next) in phases.zip(phases.drop(1))) {
if (next !is SameTypeCompilerPhase<*, *>) {
@@ -27,6 +27,7 @@ private class CompositePhase<Context : CommonBackendContext, Input, Output>(
currentState.stickyPostconditions.addAll(previous.stickyPostconditions)
result = next.invoke(phaseConfig, currentState, context, result)
}
@Suppress("UNCHECKED_CAST")
return result as Output
}
@@ -36,6 +37,7 @@ private class CompositePhase<Context : CommonBackendContext, Input, Output>(
override val stickyPostconditions get() = phases.last().stickyPostconditions
}
@Suppress("UNCHECKED_CAST")
infix fun <Context : CommonBackendContext, Input, Mid, Output> CompilerPhase<Context, Input, Mid>.then(
other: CompilerPhase<Context, Mid, Output>
): CompilerPhase<Context, Input, Output> {