File tree Expand file tree Collapse file tree 1 file changed +21
-6
lines changed
java/kotlin-extractor/src/main/kotlin Expand file tree Collapse file tree 1 file changed +21
-6
lines changed Original file line number Diff line number Diff line change @@ -308,15 +308,30 @@ open class KotlinUsesExtractor(
308
308
c.hasEqualFqName(FqName (" java.lang.Object" )))
309
309
return c
310
310
return globalExtensionState.syntheticToRealClassMap.getOrPut(c) {
311
- val result = c.fqNameWhenAvailable?.let {
312
- pluginContext.referenceClass(it)?.owner
311
+ val qualifiedName = c.fqNameWhenAvailable
312
+ if (qualifiedName == null ) {
313
+ logger.warn(" Failed to replace synthetic class ${c.name} because it has no fully qualified name" )
314
+ return @getOrPut null
313
315
}
314
- if (result == null ) {
315
- logger.warn( " Failed to replace synthetic class ${c.name} " )
316
- } else {
316
+
317
+ val result = pluginContext.referenceClass(qualifiedName)?.owner
318
+ if (result != null ) {
317
319
logger.info(" Replaced synthetic class ${c.name} with its real equivalent" )
320
+ return @getOrPut result
318
321
}
319
- result
322
+
323
+ // The above doesn't work for (some) generated nested classes, such as R$id, which should be R.id
324
+ val fqn = qualifiedName.asString()
325
+ if (fqn.indexOf(' $' ) >= 0 ) {
326
+ val nested = pluginContext.referenceClass(FqName (fqn.replace(' $' , ' .' )))?.owner
327
+ if (nested != null ) {
328
+ logger.info(" Replaced synthetic nested class ${c.name} with its real equivalent" )
329
+ return @getOrPut nested
330
+ }
331
+ }
332
+
333
+ logger.warn(" Failed to replace synthetic class ${c.name} " )
334
+ return @getOrPut null
320
335
} ? : c
321
336
}
322
337
You can’t perform that action at this time.
0 commit comments