Suppress K2 specific warnings in the codebase

^KT-62472
This commit is contained in:
Dmitriy Novozhilov
2023-10-10 14:32:35 +03:00
committed by Space Team
parent 9e66a7b999
commit 704e2ef5c5
43 changed files with 58 additions and 8 deletions
@@ -73,6 +73,7 @@ abstract class InventNamesForLocalClasses(
val isLocal = parent is IrFile && declaration.isAnonymousObject
if (!isLocal) return processClass(declaration, data)
@Suppress("USELESS_CAST") // K2 warning suppression, TODO: KT-62472
val enclosingName = (parent as IrFile).name.removeSuffix(".kt").plus("Kt").capitalizeAsciiOnly()
processClass(declaration, data.copy(enclosingName = enclosingName, isLocal = true))
}
@@ -105,6 +105,7 @@ abstract class UsefulDeclarationProcessor(
addReachabilityInfoIfNeeded(from, this, description, isContagiousOverridableDeclaration)
if (isContagiousOverridableDeclaration) {
@Suppress("USELESS_CAST") // K2 warning suppression, TODO: KT-62472
contagiousReachableDeclarations.add(this as IrOverridableDeclaration<*>)
}
@@ -52,6 +52,7 @@ open class KotlinSourceFileMap<out T>(files: Map<KotlinLibraryFile, Map<KotlinSo
operator fun get(libFile: KotlinLibraryFile, sourceFile: KotlinSourceFile): T? = get(libFile)?.get(sourceFile)
}
@Suppress("DELEGATED_MEMBER_HIDES_SUPERTYPE_OVERRIDE") // K2 warning suppression, TODO: KT-62472
class KotlinSourceFileMutableMap<T>(
private val files: MutableMap<KotlinLibraryFile, MutableMap<KotlinSourceFile, T>> = hashMapOf()
) : KotlinSourceFileMap<T>(files) {
@@ -262,6 +262,7 @@ private class AddContinuationLowering(context: JvmBackendContext) : SuspendLower
var cursor = irFunction.parentAsClass.parent
while (cursor is IrClass) {
if (cursor == param.parent) return true
@Suppress("USELESS_CAST") // K2 warning suppression, TODO: KT-62472
cursor = (cursor as IrClass).parent
}
return false
@@ -350,6 +350,7 @@ val IrDeclaration.parentAsClass: IrClass
fun IrElement.getPackageFragment(): IrPackageFragment? =
this as? IrPackageFragment ?: (this as? IrDeclaration)?.getPackageFragment()
@Suppress("NO_TAIL_CALLS_FOUND", "NON_TAIL_RECURSIVE_CALL") // K2 warning suppression, TODO: KT-62472
tailrec fun IrDeclaration.getPackageFragment(): IrPackageFragment {
val parent = this.parent
return parent as? IrPackageFragment
@@ -1547,4 +1548,4 @@ private fun Any?.toIrConstOrNull(irType: IrType, startOffset: Int = SYNTHETIC_OF
fun Any?.toIrConst(irType: IrType, startOffset: Int = SYNTHETIC_OFFSET, endOffset: Int = SYNTHETIC_OFFSET): IrConst<*> =
toIrConstOrNull(irType, startOffset, endOffset)
?: throw UnsupportedOperationException("Unsupported const element type ${irType.makeNotNull().render()}")
?: throw UnsupportedOperationException("Unsupported const element type ${irType.makeNotNull().render()}")