Cleanup compiler warnings in IR-related modules

This commit is contained in:
Alexander Udalov
2019-08-28 12:41:53 +02:00
parent 406462d422
commit bf5ca2ed84
8 changed files with 11 additions and 18 deletions
@@ -9,7 +9,6 @@ import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor
import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptorImpl import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptorImpl
import org.jetbrains.kotlin.descriptors.annotations.Annotations import org.jetbrains.kotlin.descriptors.annotations.Annotations
import org.jetbrains.kotlin.descriptors.impl.ReceiverParameterDescriptorImpl
import org.jetbrains.kotlin.descriptors.impl.TypeAliasConstructorDescriptor import org.jetbrains.kotlin.descriptors.impl.TypeAliasConstructorDescriptor
import org.jetbrains.kotlin.ir.IrElement import org.jetbrains.kotlin.ir.IrElement
import org.jetbrains.kotlin.ir.declarations.* import org.jetbrains.kotlin.ir.declarations.*
@@ -25,7 +24,6 @@ import org.jetbrains.kotlin.resolve.descriptorUtil.module
import org.jetbrains.kotlin.resolve.scopes.LazyScopeAdapter import org.jetbrains.kotlin.resolve.scopes.LazyScopeAdapter
import org.jetbrains.kotlin.resolve.scopes.MemberScope import org.jetbrains.kotlin.resolve.scopes.MemberScope
import org.jetbrains.kotlin.resolve.scopes.TypeIntersectionScope import org.jetbrains.kotlin.resolve.scopes.TypeIntersectionScope
import org.jetbrains.kotlin.resolve.scopes.receivers.ExtensionReceiver
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DescriptorWithContainerSource import org.jetbrains.kotlin.serialization.deserialization.descriptors.DescriptorWithContainerSource
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedContainerSource import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedContainerSource
@@ -1023,10 +1021,10 @@ open class WrappedFieldDescriptor(
override fun getContainingDeclaration() = (owner.parent as IrSymbolOwner).symbol.descriptor override fun getContainingDeclaration() = (owner.parent as IrSymbolOwner).symbol.descriptor
override fun isLateInit() = owner.correspondingProperty?.isLateinit ?: false override fun isLateInit() = owner.correspondingPropertySymbol?.owner?.isLateinit ?: false
override fun getExtensionReceiverParameter(): ReceiverParameterDescriptor? = override fun getExtensionReceiverParameter(): ReceiverParameterDescriptor? =
owner.correspondingProperty?.descriptor?.extensionReceiverParameter owner.correspondingPropertySymbol?.owner?.descriptor?.extensionReceiverParameter
override fun isExternal() = owner.isExternal override fun isExternal() = owner.isExternal
@@ -594,7 +594,6 @@ abstract class AbstractSuspendFunctionsLowering<C : CommonBackendContext>(val co
stateMachineFunction: IrSimpleFunction, stateMachineFunction: IrSimpleFunction,
coroutineClass: IrClass coroutineClass: IrClass
): IrSimpleFunction { ): IrSimpleFunction {
val originalBody = irFunction.body!!
val function = WrappedSimpleFunctionDescriptor().let { d -> val function = WrappedSimpleFunctionDescriptor().let { d ->
IrFunctionImpl( IrFunctionImpl(
startOffset, endOffset, startOffset, endOffset,
@@ -359,7 +359,6 @@ open class DefaultParameterInjector(
) )
} }
if (expression.symbol is IrConstructorSymbol) { if (expression.symbol is IrConstructorSymbol) {
val defaultArgumentMarker = context.ir.symbols.defaultConstructorMarker
params += markerParameterDeclaration(realFunction) to params += markerParameterDeclaration(realFunction) to
IrConstImpl.constNull(startOffset, endOffset, context.irBuiltIns.nothingNType) IrConstImpl.constNull(startOffset, endOffset, context.irBuiltIns.nothingNType)
} else if (context.ir.shouldGenerateHandlerParameterForDefaultBodyFun()) { } else if (context.ir.shouldGenerateHandlerParameterForDefaultBodyFun()) {
@@ -52,7 +52,7 @@ private class KCallableNamePropertyTransformer(val lower: KCallableNamePropertyL
//TODO rewrite checking //TODO rewrite checking
val directMember = expression.symbol.owner.let { val directMember = expression.symbol.owner.let {
(it as? IrSimpleFunction)?.correspondingProperty ?: it (it as? IrSimpleFunction)?.correspondingPropertySymbol?.owner ?: it
} }
val irClass = directMember.parent as? IrClass ?: return expression val irClass = directMember.parent as? IrClass ?: return expression
if (!irClass.isSubclassOf(lower.context.irBuiltIns.kCallableClass.owner)) return expression if (!irClass.isSubclassOf(lower.context.irBuiltIns.kCallableClass.owner)) return expression
@@ -45,12 +45,9 @@ class PrimitiveCompanionLowering(val context: JsIrBackendContext) : FileLowering
val actualCompanion = getActualPrimitiveCompanion(companion) val actualCompanion = getActualPrimitiveCompanion(companion)
?: return null ?: return null
val actualFunction = return actualCompanion.declarations
actualCompanion.declarations .filterIsInstance<IrSimpleFunction>()
.filterIsInstance<IrSimpleFunction>() .single { it.name == function.name }
.single { it.name == function.name }
return actualFunction!!
} }
override fun lower(irFile: IrFile) { override fun lower(irFile: IrFile) {
@@ -20,7 +20,6 @@ import org.jetbrains.kotlin.descriptors.Visibility
import org.jetbrains.kotlin.ir.declarations.* import org.jetbrains.kotlin.ir.declarations.*
import org.jetbrains.kotlin.ir.expressions.IrBody import org.jetbrains.kotlin.ir.expressions.IrBody
import org.jetbrains.kotlin.ir.types.IrType import org.jetbrains.kotlin.ir.types.IrType
import org.jetbrains.kotlin.ir.types.impl.IrUninitializedType
import org.jetbrains.kotlin.ir.util.transform import org.jetbrains.kotlin.ir.util.transform
import org.jetbrains.kotlin.ir.visitors.IrElementTransformer import org.jetbrains.kotlin.ir.visitors.IrElementTransformer
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
@@ -40,8 +39,9 @@ abstract class IrFunctionBase(
IrDeclarationBase(startOffset, endOffset, origin), IrDeclarationBase(startOffset, endOffset, origin),
IrFunction { IrFunction {
@Suppress("DEPRECATION")
final override var returnType: IrType = returnType final override var returnType: IrType = returnType
get() = if (field === IrUninitializedType) { get() = if (field === org.jetbrains.kotlin.ir.types.impl.IrUninitializedType) {
error("Return type is not initialized") error("Return type is not initialized")
} else { } else {
field field
@@ -247,7 +247,7 @@ open class IrFileSerializer(
is IrReturnableBlockSymbol -> is IrReturnableBlockSymbol ->
ProtoSymbolKind.RETURNABLE_BLOCK_SYMBOL ProtoSymbolKind.RETURNABLE_BLOCK_SYMBOL
is IrFieldSymbol -> is IrFieldSymbol ->
if (symbol.owner.correspondingProperty.let { it == null || it.isDelegated }) if (symbol.owner.correspondingPropertySymbol?.owner.let { it == null || it.isDelegated })
ProtoSymbolKind.STANDALONE_FIELD_SYMBOL ProtoSymbolKind.STANDALONE_FIELD_SYMBOL
else else
ProtoSymbolKind.FIELD_SYMBOL ProtoSymbolKind.FIELD_SYMBOL
@@ -250,7 +250,7 @@ interface IrBuilderExtension {
irProperty.parent = propertyParent irProperty.parent = propertyParent
irProperty.backingField = generatePropertyBackingField(propertyDescriptor, irProperty).apply { irProperty.backingField = generatePropertyBackingField(propertyDescriptor, irProperty).apply {
parent = propertyParent parent = propertyParent
correspondingProperty = irProperty correspondingPropertySymbol = irProperty.symbol
} }
val fieldSymbol = irProperty.backingField!!.symbol val fieldSymbol = irProperty.backingField!!.symbol
irProperty.getter = propertyDescriptor.getter?.let { generatePropertyAccessor(it, fieldSymbol) } irProperty.getter = propertyDescriptor.getter?.let { generatePropertyAccessor(it, fieldSymbol) }