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.AnnotationDescriptorImpl
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.ir.IrElement
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.MemberScope
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.serialization.deserialization.descriptors.DescriptorWithContainerSource
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 isLateInit() = owner.correspondingProperty?.isLateinit ?: false
override fun isLateInit() = owner.correspondingPropertySymbol?.owner?.isLateinit ?: false
override fun getExtensionReceiverParameter(): ReceiverParameterDescriptor? =
owner.correspondingProperty?.descriptor?.extensionReceiverParameter
owner.correspondingPropertySymbol?.owner?.descriptor?.extensionReceiverParameter
override fun isExternal() = owner.isExternal
@@ -594,7 +594,6 @@ abstract class AbstractSuspendFunctionsLowering<C : CommonBackendContext>(val co
stateMachineFunction: IrSimpleFunction,
coroutineClass: IrClass
): IrSimpleFunction {
val originalBody = irFunction.body!!
val function = WrappedSimpleFunctionDescriptor().let { d ->
IrFunctionImpl(
startOffset, endOffset,
@@ -359,7 +359,6 @@ open class DefaultParameterInjector(
)
}
if (expression.symbol is IrConstructorSymbol) {
val defaultArgumentMarker = context.ir.symbols.defaultConstructorMarker
params += markerParameterDeclaration(realFunction) to
IrConstImpl.constNull(startOffset, endOffset, context.irBuiltIns.nothingNType)
} else if (context.ir.shouldGenerateHandlerParameterForDefaultBodyFun()) {
@@ -52,7 +52,7 @@ private class KCallableNamePropertyTransformer(val lower: KCallableNamePropertyL
//TODO rewrite checking
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
if (!irClass.isSubclassOf(lower.context.irBuiltIns.kCallableClass.owner)) return expression
@@ -45,12 +45,9 @@ class PrimitiveCompanionLowering(val context: JsIrBackendContext) : FileLowering
val actualCompanion = getActualPrimitiveCompanion(companion)
?: return null
val actualFunction =
actualCompanion.declarations
.filterIsInstance<IrSimpleFunction>()
.single { it.name == function.name }
return actualFunction!!
return actualCompanion.declarations
.filterIsInstance<IrSimpleFunction>()
.single { it.name == function.name }
}
override fun lower(irFile: IrFile) {
@@ -78,4 +75,4 @@ class PrimitiveCompanionLowering(val context: JsIrBackendContext) : FileLowering
}
})
}
}
}
@@ -20,7 +20,6 @@ import org.jetbrains.kotlin.descriptors.Visibility
import org.jetbrains.kotlin.ir.declarations.*
import org.jetbrains.kotlin.ir.expressions.IrBody
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.visitors.IrElementTransformer
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
@@ -40,8 +39,9 @@ abstract class IrFunctionBase(
IrDeclarationBase(startOffset, endOffset, origin),
IrFunction {
@Suppress("DEPRECATION")
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")
} else {
field
@@ -247,7 +247,7 @@ open class IrFileSerializer(
is IrReturnableBlockSymbol ->
ProtoSymbolKind.RETURNABLE_BLOCK_SYMBOL
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
else
ProtoSymbolKind.FIELD_SYMBOL
@@ -250,7 +250,7 @@ interface IrBuilderExtension {
irProperty.parent = propertyParent
irProperty.backingField = generatePropertyBackingField(propertyDescriptor, irProperty).apply {
parent = propertyParent
correspondingProperty = irProperty
correspondingPropertySymbol = irProperty.symbol
}
val fieldSymbol = irProperty.backingField!!.symbol
irProperty.getter = propertyDescriptor.getter?.let { generatePropertyAccessor(it, fieldSymbol) }