IR: fix compiler warnings

This commit is contained in:
Alexander Udalov
2020-08-14 12:34:20 +02:00
parent be53467bee
commit a810dbb41b
34 changed files with 83 additions and 95 deletions
@@ -11,13 +11,12 @@ dependencies {
compile(project(":compiler:serialization"))
compile(project(":kotlin-util-klib"))
compile(project(":kotlin-util-klib-metadata"))
compile(project(":compiler:util"))
compile(project(":compiler:ir.psi2ir"))
compile(project(":compiler:ir.backend.common"))
compileOnly(project(":kotlin-reflect-api"))
compileOnly(intellijCoreDep()) { includeJars("intellij-core") }
}
sourceSets {
@@ -29,7 +28,7 @@ tasks {
val compileKotlin by existing(org.jetbrains.kotlin.gradle.tasks.KotlinCompile::class) {
kotlinOptions {
freeCompilerArgs += "-Xopt-in=org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI"
freeCompilerArgs += "-Xinline-classes"
}
}
}
@@ -100,6 +100,7 @@ class IrOverridingUtil(
fun buildFakeOverridesForClass(clazz: IrClass) {
val superTypes = allPublicApiSuperTypesOrAny(clazz)
@Suppress("UNCHECKED_CAST")
val fromCurrent = clazz.declarations.filter { it is IrOverridableMember && it.symbol.isPublicApi } as List<IrOverridableMember>
val allFromSuper = superTypes.flatMap { superType ->
@@ -190,10 +191,7 @@ class IrOverridingUtil(
}
}
private fun filterVisibleFakeOverrides(
current: IrClass,
toFilter: Collection<IrOverridableMember>
): Collection<IrOverridableMember> {
private fun filterVisibleFakeOverrides(toFilter: Collection<IrOverridableMember>): Collection<IrOverridableMember> {
return toFilter.filter { member: IrOverridableMember ->
!Visibilities.isPrivate(member.visibility)
}
@@ -296,7 +294,7 @@ class IrOverridingUtil(
overridables: Collection<IrOverridableMember>,
current: IrClass
) {
val effectiveOverridden = filterVisibleFakeOverrides(current, overridables)
val effectiveOverridden = filterVisibleFakeOverrides(overridables)
// The descriptor based algorithm goes further building invisible fakes here,
// but we don't use invisible fakes in IR
@@ -1,18 +1,19 @@
/*
* 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.backend.common.overrides
import org.jetbrains.kotlin.backend.common.lower.parents
import org.jetbrains.kotlin.descriptors.Visibilities
import org.jetbrains.kotlin.ir.declarations.IrDeclaration
import org.jetbrains.kotlin.ir.declarations.IrDeclarationWithVisibility
import org.jetbrains.kotlin.ir.declarations.IrOverridableMember
import org.jetbrains.kotlin.ir.util.module
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue
// The contents of this file is from VisibilityUtil.kt adapted to IR.
// TODO: The code would better be commonized for descriptors, ir and fir.
fun isVisibleForOverride(
overriding: IrOverridableMember,
@Suppress("UNUSED_PARAMETER") overriding: IrOverridableMember,
fromSuper: IrOverridableMember
): Boolean {
return !Visibilities.isPrivate((fromSuper as IrDeclarationWithVisibility).visibility)
@@ -4,6 +4,7 @@
*/
@file:OptIn(ExperimentalUnsignedTypes::class)
@file:Suppress("NAME_SHADOWING")
package org.jetbrains.kotlin.backend.common.serialization
@@ -106,9 +106,9 @@ class ExpectActualTable(val expectDescriptorToSymbol: MutableMap<DeclarationDesc
}
val expects: List<MemberDescriptor> = if (descriptor is ClassConstructorDescriptor && descriptor.isPrimary) {
(descriptor.containingDeclaration.findExpects() as List<ClassDescriptor>).map {
it.unsubstitutedPrimaryConstructor
}.filterNotNull()
descriptor.containingDeclaration.findExpects().mapNotNull {
(it as ClassDescriptor).unsubstitutedPrimaryConstructor
}
} else {
descriptor.findExpects()
}
@@ -435,7 +435,6 @@ abstract class IrFileDeserializer(
proto: ProtoEnumConstructorCall,
start: Int,
end: Int,
type: IrType
): IrEnumConstructorCall {
val symbol = deserializeIrSymbolAndRemap(proto.symbol) as IrConstructorSymbol
val call = IrEnumConstructorCallImpl(
@@ -587,7 +586,7 @@ abstract class IrFileDeserializer(
return callable
}
private fun deserializeReturn(proto: ProtoReturn, start: Int, end: Int, type: IrType): IrReturn {
private fun deserializeReturn(proto: ProtoReturn, start: Int, end: Int): IrReturn {
val symbol = deserializeIrSymbolAndRemap(proto.returnTarget) as IrReturnTargetSymbol
val value = deserializeExpression(proto.value)
return IrReturnImpl(start, end, builtIns.nothingType, symbol, value)
@@ -631,7 +630,7 @@ abstract class IrFileDeserializer(
return IrStringConcatenationImpl(start, end, type, arguments)
}
private fun deserializeThrow(proto: ProtoThrow, start: Int, end: Int, type: IrType): IrThrowImpl {
private fun deserializeThrow(proto: ProtoThrow, start: Int, end: Int): IrThrowImpl {
return IrThrowImpl(start, end, builtIns.nothingType, deserializeExpression(proto.value))
}
@@ -868,7 +867,7 @@ abstract class IrFileDeserializer(
CONTINUE -> deserializeContinue(proto.`continue`, start, end, type)
DELEGATING_CONSTRUCTOR_CALL -> deserializeDelegatingConstructorCall(proto.delegatingConstructorCall, start, end)
DO_WHILE -> deserializeDoWhile(proto.doWhile, start, end, type)
ENUM_CONSTRUCTOR_CALL -> deserializeEnumConstructorCall(proto.enumConstructorCall, start, end, type)
ENUM_CONSTRUCTOR_CALL -> deserializeEnumConstructorCall(proto.enumConstructorCall, start, end)
FUNCTION_REFERENCE -> deserializeFunctionReference(proto.functionReference, start, end, type)
GET_ENUM_VALUE -> deserializeGetEnumValue(proto.getEnumValue, start, end, type)
GET_CLASS -> deserializeGetClass(proto.getClass, start, end, type)
@@ -878,11 +877,11 @@ abstract class IrFileDeserializer(
LOCAL_DELEGATED_PROPERTY_REFERENCE -> deserializeIrLocalDelegatedPropertyReference(proto.localDelegatedPropertyReference, start, end, type)
INSTANCE_INITIALIZER_CALL -> deserializeInstanceInitializerCall(proto.instanceInitializerCall, start, end)
PROPERTY_REFERENCE -> deserializePropertyReference(proto.propertyReference, start, end, type)
RETURN -> deserializeReturn(proto.`return`, start, end, type)
RETURN -> deserializeReturn(proto.`return`, start, end)
SET_FIELD -> deserializeSetField(proto.setField, start, end)
SET_VARIABLE -> deserializeSetVariable(proto.setVariable, start, end)
STRING_CONCAT -> deserializeStringConcat(proto.stringConcat, start, end, type)
THROW -> deserializeThrow(proto.`throw`, start, end, type)
THROW -> deserializeThrow(proto.`throw`, start, end)
TRY -> deserializeTry(proto.`try`, start, end, type)
TYPE_OP -> deserializeTypeOp(proto.typeOp, start, end, type)
VARARG -> deserializeVararg(proto.vararg, start, end, type)
@@ -145,12 +145,12 @@ abstract class KlibMetadataSerializer(
protected fun serializeDescriptors(
fqName: FqName,
classifierDescriptors: List<DeclarationDescriptor>,
topLevelDescriptors: List<DeclarationDescriptor>
allClassifierDescriptors: List<DeclarationDescriptor>,
allTopLevelDescriptors: List<DeclarationDescriptor>
): List<ProtoBuf.PackageFragment> {
val classifierDescriptors = classifierDescriptors.filterOutExpects()
val topLevelDescriptors = topLevelDescriptors.filterOutExpects()
val classifierDescriptors = allClassifierDescriptors.filterOutExpects()
val topLevelDescriptors = allTopLevelDescriptors.filterOutExpects()
if (TOP_LEVEL_CLASS_DECLARATION_COUNT_PER_FILE == null &&
TOP_LEVEL_DECLARATION_COUNT_PER_FILE == null) {