@@ -11,6 +11,7 @@ import org.jetbrains.kotlin.builtins.functions.BuiltInFunctionArity
11
11
import org.jetbrains.kotlin.config.JvmAnalysisFlags
12
12
import org.jetbrains.kotlin.descriptors.*
13
13
import org.jetbrains.kotlin.descriptors.java.JavaVisibilities
14
+ import org.jetbrains.kotlin.load.kotlin.FacadeClassSource
14
15
import org.jetbrains.kotlin.ir.IrElement
15
16
import org.jetbrains.kotlin.ir.IrStatement
16
17
import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI
@@ -2154,7 +2155,7 @@ open class KotlinFileExtractor(
2154
2155
if (overriddenCallTarget.isLocalFunction()) {
2155
2156
extractTypeAccess(getLocallyVisibleFunctionLabels(overriddenCallTarget).type, locId, id, - 1 , enclosingCallable, enclosingStmt)
2156
2157
} else {
2157
- extractStaticTypeAccessQualifierUnchecked(overriddenCallTarget.parent , id, locId, enclosingCallable, enclosingStmt)
2158
+ extractStaticTypeAccessQualifierUnchecked(overriddenCallTarget, id, locId, enclosingCallable, enclosingStmt)
2158
2159
}
2159
2160
2160
2161
extractDefaultsCallArguments(id, overriddenCallTarget, enclosingCallable, enclosingStmt, valueArguments, dispatchReceiver, extensionReceiver)
@@ -2380,8 +2381,29 @@ open class KotlinFileExtractor(
2380
2381
extractValueArguments(argParent, idxOffset)
2381
2382
}
2382
2383
2383
- private fun extractStaticTypeAccessQualifierUnchecked (parent : IrDeclarationParent , parentExpr : Label <out DbExprparent >, locId : Label <DbLocation >, enclosingCallable : Label <out DbCallable >? , enclosingStmt : Label <out DbStmt >? ) {
2384
- if (parent is IrClass ) {
2384
+ private fun extractStaticTypeAccessQualifierUnchecked (target : IrDeclaration , parentExpr : Label <out DbExprparent >, locId : Label <DbLocation >, enclosingCallable : Label <out DbCallable >? , enclosingStmt : Label <out DbStmt >? ) {
2385
+ val parent = target.parent
2386
+ if (parent is IrExternalPackageFragment ) {
2387
+ // This is in a file class.
2388
+ // Get the name in a similar way to the compiler's ExternalPackageParentPatcherLowering
2389
+ // visitMemberAccess/generateOrGetFacadeClass.
2390
+ if (target is IrMemberWithContainerSource ) {
2391
+ val containerSource = target.containerSource
2392
+ if (containerSource is FacadeClassSource ) {
2393
+ val facadeClassName = containerSource.facadeClassName
2394
+ if (facadeClassName != null ) {
2395
+ // TODO: This is really a multifile-class rather than a file-class
2396
+ extractTypeAccess(useFileClassType(facadeClassName.fqNameForTopLevelClassMaybeWithDollars), locId, parentExpr, - 1 , enclosingCallable, enclosingStmt)
2397
+ } else {
2398
+ extractTypeAccess(useFileClassType(containerSource.className.fqNameForTopLevelClassMaybeWithDollars), locId, parentExpr, - 1 , enclosingCallable, enclosingStmt)
2399
+ }
2400
+ } else {
2401
+ logger.warnElement(" Unexpected container source ${containerSource?.javaClass} " , target)
2402
+ }
2403
+ } else {
2404
+ logger.warnElement(" Element in external package fragment without container source ${target.javaClass} " , target)
2405
+ }
2406
+ } else if (parent is IrClass ) {
2385
2407
extractTypeAccessRecursive(parent.toRawType(), locId, parentExpr, - 1 , enclosingCallable, enclosingStmt)
2386
2408
} else if (parent is IrFile ) {
2387
2409
extractTypeAccess(useFileClassType(parent), locId, parentExpr, - 1 , enclosingCallable, enclosingStmt)
@@ -2392,7 +2414,7 @@ open class KotlinFileExtractor(
2392
2414
2393
2415
private fun extractStaticTypeAccessQualifier (target : IrDeclaration , parentExpr : Label <out DbExprparent >, locId : Label <DbLocation >, enclosingCallable : Label <out DbCallable >? , enclosingStmt : Label <out DbStmt >? ) {
2394
2416
if (target.shouldExtractAsStatic) {
2395
- extractStaticTypeAccessQualifierUnchecked(target.parent , parentExpr, locId, enclosingCallable, enclosingStmt)
2417
+ extractStaticTypeAccessQualifierUnchecked(target, parentExpr, locId, enclosingCallable, enclosingStmt)
2396
2418
}
2397
2419
}
2398
2420
0 commit comments