@@ -1231,7 +1231,7 @@ open class KotlinFileExtractor(
12311231 if (dispatchReceiver != null ) {
12321232 extractExpressionExpr(dispatchReceiver, enclosingCallable, id, - 1 , enclosingStmt)
12331233 } else if (isStaticFunction(callTarget)) {
1234- extractStaticCallTypeAccessQualifier (callTarget, id, locId, enclosingCallable, enclosingStmt)
1234+ extractStaticTypeAccessQualifier (callTarget, id, locId, enclosingCallable, enclosingStmt)
12351235 }
12361236 }
12371237
@@ -1250,14 +1250,26 @@ open class KotlinFileExtractor(
12501250 extractCallValueArguments(argParent, valueArguments, enclosingStmt, enclosingCallable, idxOffset)
12511251 }
12521252
1253- private fun extractStaticCallTypeAccessQualifier (target : IrFunction , parentExpr : Label <out DbExprparent >, locId : Label <DbLocation >, enclosingCallable : Label <out DbCallable >, enclosingStmt : Label <out DbStmt >) {
1254- if (target.isStaticMethodOfClass ) {
1253+ private fun extractStaticTypeAccessQualifier (target : IrDeclaration , parentExpr : Label <out DbExprparent >, locId : Label <DbLocation >, enclosingCallable : Label <out DbCallable >, enclosingStmt : Label <out DbStmt >) {
1254+ if (target.isStaticOfClass ) {
12551255 extractTypeAccessRecursive(target.parentAsClass.toRawType(), locId, parentExpr, - 1 , enclosingCallable, enclosingStmt)
1256- } else if (target is IrSimpleFunction && target.dispatchReceiverParameter == null && target.parent is IrFile ) {
1256+ } else if (target.isStaticOfFile ) {
12571257 extractTypeAccess(useFileClassType(target.parent as IrFile ), locId, parentExpr, - 1 , enclosingCallable, enclosingStmt)
12581258 }
12591259 }
12601260
1261+ private val IrDeclaration .isStaticOfClass: Boolean
1262+ get() = this .isStatic && parent is IrClass
1263+
1264+ private val IrDeclaration .isStaticOfFile: Boolean
1265+ get() = this .isStatic && parent is IrFile
1266+
1267+ private val IrDeclaration .isStatic: Boolean
1268+ get() = this is IrSimpleFunction && dispatchReceiverParameter == null ||
1269+ this is IrField && this .isStatic ||
1270+ this is IrEnumEntry
1271+
1272+
12611273 private fun extractCallValueArguments (callId : Label <out DbExprparent >, call : IrFunctionAccessExpression , enclosingStmt : Label <out DbStmt >, enclosingCallable : Label <out DbCallable >, idxOffset : Int ) =
12621274 extractCallValueArguments(callId, (0 until call.valueArgumentsCount).map { call.getValueArgument(it) }, enclosingStmt, enclosingCallable, idxOffset)
12631275
@@ -2487,7 +2499,7 @@ open class KotlinFileExtractor(
24872499 if (receiver != null ) {
24882500 extractExpressionExpr(receiver, callable, id, - 1 , exprParent.enclosingStmt)
24892501 } else if (owner.isStatic) {
2490- extractTypeAccessRecursive (owner.parentAsClass.toRawType(), locId, id, - 1 , callable, exprParent.enclosingStmt)
2502+ extractStaticTypeAccessQualifier (owner, id, locId , callable, exprParent.enclosingStmt)
24912503 }
24922504 }
24932505 is IrGetEnumValue -> {
@@ -2514,7 +2526,7 @@ open class KotlinFileExtractor(
25142526 val vId = useEnumEntry(owner)
25152527 tw.writeVariableBinding(id, vId)
25162528
2517- extractTypeAccessRecursive(e.type, locId, id, - 1 , callable, exprParent.enclosingStmt)
2529+ extractStaticTypeAccessQualifier(owner, id, locId , callable, exprParent.enclosingStmt)
25182530 }
25192531 is IrSetValue ,
25202532 is IrSetField -> {
@@ -2576,7 +2588,7 @@ open class KotlinFileExtractor(
25762588 if (receiver != null ) {
25772589 extractExpressionExpr(receiver, callable, lhsId, - 1 , exprParent.enclosingStmt)
25782590 } else if (realField.isStatic) {
2579- extractTypeAccessRecursive (realField.parentAsClass.toRawType(), lhsLocId, lhsId, - 1 , callable, exprParent.enclosingStmt)
2591+ extractStaticTypeAccessQualifier (realField, lhsId, lhsLocId , callable, exprParent.enclosingStmt)
25802592 }
25812593 }
25822594 else -> {
@@ -2988,7 +3000,7 @@ open class KotlinFileExtractor(
29883000 useFirstArgAsDispatch = target.owner.dispatchReceiverParameter != null
29893001
29903002 if (isStaticFunction(target.owner)) {
2991- extractStaticCallTypeAccessQualifier (target.owner, callId, locId, labels.methodId, retId)
3003+ extractStaticTypeAccessQualifier (target.owner, callId, locId, labels.methodId, retId)
29923004 }
29933005 }
29943006 }
0 commit comments