Skip to content

Commit 3459e5e

Browse files
committed
Kotlin: Refactor extractStaticTypeAccessQualifier
Avoids a cast
1 parent f5d43b8 commit 3459e5e

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

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

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1544,19 +1544,18 @@ open class KotlinFileExtractor(
15441544
}
15451545

15461546
private fun extractStaticTypeAccessQualifier(target: IrDeclaration, parentExpr: Label<out DbExprparent>, locId: Label<DbLocation>, enclosingCallable: Label<out DbCallable>, enclosingStmt: Label<out DbStmt>) {
1547-
if (target.shouldExtractAsStaticMemberOfClass) {
1548-
extractTypeAccessRecursive(target.parentAsClass.toRawType(), locId, parentExpr, -1, enclosingCallable, enclosingStmt)
1549-
} else if (target.shouldExtractAsStaticMemberOfFile) {
1550-
extractTypeAccess(useFileClassType(target.parent as IrFile), locId, parentExpr, -1, enclosingCallable, enclosingStmt)
1547+
if (target.shouldExtractAsStatic) {
1548+
val parent = target.parent
1549+
if (parent is IrClass) {
1550+
extractTypeAccessRecursive(parent.toRawType(), locId, parentExpr, -1, enclosingCallable, enclosingStmt)
1551+
} else if (parent is IrFile) {
1552+
extractTypeAccess(useFileClassType(parent), locId, parentExpr, -1, enclosingCallable, enclosingStmt)
1553+
} else {
1554+
logger.warnElement("Unexpected static type access qualifer ${parent.javaClass}", target)
1555+
}
15511556
}
15521557
}
15531558

1554-
private val IrDeclaration.shouldExtractAsStaticMemberOfClass: Boolean
1555-
get() = this.shouldExtractAsStatic && parent is IrClass
1556-
1557-
private val IrDeclaration.shouldExtractAsStaticMemberOfFile: Boolean
1558-
get() = this.shouldExtractAsStatic && parent is IrFile
1559-
15601559
private fun isStaticAnnotatedNonCompanionMember(f: IrSimpleFunction) =
15611560
f.parentClassOrNull?.isNonCompanionObject == true &&
15621561
(f.hasAnnotation(jvmStaticFqName) || f.correspondingPropertySymbol?.owner?.hasAnnotation(jvmStaticFqName) == true)

0 commit comments

Comments
 (0)