mirror of
https://github.com/github/codeql.git
synced 2026-02-11 20:51:06 +01:00
Kotlin: Address detections from kotin internal queries
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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))
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user