Kotlin: Address detections from kotin internal queries

This commit is contained in:
Anders Fugmann
2026-01-23 11:46:05 +01:00
parent 31867a56fb
commit 2320d502db
3 changed files with 14 additions and 29 deletions

View File

@@ -2978,9 +2978,7 @@ open class KotlinFileExtractor(
// For Kotlin < 2.3, s.delegate is not-nullable. Cast to be nullable,
// as a workaround to silence warnings for kotlin < 2.3 about the elvis
// operator being redundant.
// For Kotlin >= 2.3, the cast is redundant, so we need to silence that warning
@Suppress("USELESS_CAST")
val delegate = s.delegate as IrVariable?
val delegate: IrVariable? = cast(s.delegate)
val propId = tw.getFreshIdLabel<DbKt_property>()
if (delegate == null) {

View File

@@ -12,44 +12,28 @@ fun getClassByFqName(pluginContext: IrPluginContext, fqName: FqName): IrClassSym
return getClassByClassId(pluginContext, id)
}
fun getClassByFqName(pluginContext: IrPluginContext, fqName: String): IrClassSymbol? {
return getClassByFqName(pluginContext, FqName(fqName))
}
fun getClassByClassId(pluginContext: IrPluginContext, id: ClassId): IrClassSymbol? {
return pluginContext.referenceClass(id)
}
fun getFunctionsByFqName(
pluginContext: IrPluginContext,
pkgName: FqName,
name: Name
pkgName: String,
name: String
): Collection<IrSimpleFunctionSymbol> {
val id = CallableId(pkgName, name)
val id = CallableId(FqName(pkgName), Name.identifier(name))
return pluginContext.referenceFunctions(id)
}
fun getPropertiesByFqName(
pluginContext: IrPluginContext,
pkgName: FqName,
name: Name
pkgName: String,
name: String
): Collection<IrPropertySymbol> {
val id = CallableId(pkgName, name)
val id = CallableId(FqName(pkgName), Name.identifier(name))
return pluginContext.referenceProperties(id)
}
fun getClassByFqName(pluginContext: IrPluginContext, fqName: String): IrClassSymbol? {
return getClassByFqName(pluginContext, FqName(fqName))
}
fun getFunctionsByFqName(
pluginContext: IrPluginContext,
pkgName: String,
name: String
): Collection<IrSimpleFunctionSymbol> {
return getFunctionsByFqName(pluginContext, FqName(pkgName), Name.identifier(name))
}
fun getPropertiesByFqName(
pluginContext: IrPluginContext,
pkgName: String,
name: String
): Collection<IrPropertySymbol> {
return getPropertiesByFqName(pluginContext, FqName(pkgName), Name.identifier(name))
}

View File

@@ -11,3 +11,6 @@ fun IrFunction.isLocalFunction(): Boolean {
val IrClass.isInterfaceLike
get() = kind == ClassKind.INTERFACE || kind == ClassKind.ANNOTATION_CLASS
@Suppress("UNCHECKED_CAST")
fun <T> cast(value: Any?): T = value as T