Skip to content

Commit 1e9864d

Browse files
committed
Kotlin: Address detections from kotin internal queries
1 parent aa9dd59 commit 1e9864d

File tree

3 files changed

+12
-27
lines changed

3 files changed

+12
-27
lines changed

java/kotlin-extractor/src/main/kotlin/KotlinFileExtractor.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2978,9 +2978,7 @@ open class KotlinFileExtractor(
29782978
// For Kotlin < 2.3, s.delegate is not-nullable. Cast to be nullable,
29792979
// as a workaround to silence warnings for kotlin < 2.3 about the elvis
29802980
// operator being redundant.
2981-
// For Kotlin >= 2.3, the cast is redundant, so we need to silence that warning
2982-
@Suppress("USELESS_CAST")
2983-
val delegate = s.delegate as IrVariable?
2981+
val delegate: IrVariable? = cast(s.delegate)
29842982
val propId = tw.getFreshIdLabel<DbKt_property>()
29852983

29862984
if (delegate == null) {

java/kotlin-extractor/src/main/kotlin/utils/GetByFqName.kt

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -12,44 +12,28 @@ fun getClassByFqName(pluginContext: IrPluginContext, fqName: FqName): IrClassSym
1212
return getClassByClassId(pluginContext, id)
1313
}
1414

15-
fun getClassByClassId(pluginContext: IrPluginContext, id: ClassId): IrClassSymbol? {
16-
return pluginContext.referenceClass(id)
17-
}
18-
19-
fun getFunctionsByFqName(
20-
pluginContext: IrPluginContext,
21-
pkgName: FqName,
22-
name: Name
23-
): Collection<IrSimpleFunctionSymbol> {
24-
val id = CallableId(pkgName, name)
25-
return pluginContext.referenceFunctions(id)
26-
}
27-
28-
fun getPropertiesByFqName(
29-
pluginContext: IrPluginContext,
30-
pkgName: FqName,
31-
name: Name
32-
): Collection<IrPropertySymbol> {
33-
val id = CallableId(pkgName, name)
34-
return pluginContext.referenceProperties(id)
35-
}
36-
3715
fun getClassByFqName(pluginContext: IrPluginContext, fqName: String): IrClassSymbol? {
3816
return getClassByFqName(pluginContext, FqName(fqName))
3917
}
4018

19+
fun getClassByClassId(pluginContext: IrPluginContext, id: ClassId): IrClassSymbol? {
20+
return pluginContext.referenceClass(id)
21+
}
22+
4123
fun getFunctionsByFqName(
4224
pluginContext: IrPluginContext,
4325
pkgName: String,
4426
name: String
4527
): Collection<IrSimpleFunctionSymbol> {
46-
return getFunctionsByFqName(pluginContext, FqName(pkgName), Name.identifier(name))
28+
val id = CallableId(FqName(pkgName), Name.identifier(name))
29+
return pluginContext.referenceFunctions(id)
4730
}
4831

4932
fun getPropertiesByFqName(
5033
pluginContext: IrPluginContext,
5134
pkgName: String,
5235
name: String
5336
): Collection<IrPropertySymbol> {
54-
return getPropertiesByFqName(pluginContext, FqName(pkgName), Name.identifier(name))
37+
val id = CallableId(FqName(pkgName), Name.identifier(name))
38+
return pluginContext.referenceProperties(id)
5539
}

java/kotlin-extractor/src/main/kotlin/utils/Helpers.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,6 @@ fun IrFunction.isLocalFunction(): Boolean {
1111

1212
val IrClass.isInterfaceLike
1313
get() = kind == ClassKind.INTERFACE || kind == ClassKind.ANNOTATION_CLASS
14+
15+
@Suppress("UNCHECKED_CAST")
16+
fun <T> cast(value: Any?): T = value as T

0 commit comments

Comments
 (0)