Extract container of adapter function as compiler generated

This commit is contained in:
Tamas Vajk
2022-04-04 16:42:43 +02:00
committed by Ian Lynagh
parent 7f94495601
commit cdc7ed0e14
5 changed files with 17 additions and 1 deletions

View File

@@ -943,6 +943,10 @@ open class KotlinFileExtractor(
extractLocalTypeDeclStmt(classId, s, callable, parent, idx) extractLocalTypeDeclStmt(classId, s, callable, parent, idx)
val ids = getLocallyVisibleFunctionLabels(s) val ids = getLocallyVisibleFunctionLabels(s)
tw.writeKtLocalFunction(ids.function) tw.writeKtLocalFunction(ids.function)
if (s.origin == IrDeclarationOrigin.ADAPTER_FOR_CALLABLE_REFERENCE) {
tw.writeCompiler_generated(classId, 1)
}
} else { } else {
logger.errorElement("Expected to find local function", s) logger.errorElement("Expected to find local function", s)
} }

View File

@@ -1222,3 +1222,9 @@ ktPropertyDelegates(
unique int id: @kt_property ref, unique int id: @kt_property ref,
unique int variableId: @variable ref unique int variableId: @variable ref
) )
compiler_generated(
unique int id: @top ref,
int kind: int ref
// 1: Kotlin declaring classes of adapter functions
);

View File

@@ -50,7 +50,9 @@ predicate dead(RefType dead) {
// Exclude classes that look like they may be reflectively constructed. // Exclude classes that look like they may be reflectively constructed.
not dead.getAnAnnotation() instanceof ReflectiveAccessAnnotation and not dead.getAnAnnotation() instanceof ReflectiveAccessAnnotation and
// Insist all source ancestors are dead as well. // Insist all source ancestors are dead as well.
forall(RefType t | t.fromSource() and t = getASuperTypePlus(dead) | dead(t)) forall(RefType t | t.fromSource() and t = getASuperTypePlus(dead) | dead(t)) and
// Exclude compiler generated classes (e.g. declaring type of adapter functions in Kotlin)
not compiler_generated(dead, _)
} }
from RefType t, string kind from RefType t, string kind

View File

@@ -228,3 +228,5 @@ modifiers
| reflection.kt:116:40:116:44 | ...::... | reflection.kt:116:40:116:44 | invoke | override | | reflection.kt:116:40:116:44 | ...::... | reflection.kt:116:40:116:44 | invoke | override |
| reflection.kt:116:40:116:44 | ...::... | reflection.kt:116:40:116:44 | invoke | public | | reflection.kt:116:40:116:44 | ...::... | reflection.kt:116:40:116:44 | invoke | public |
| reflection.kt:126:9:126:13 | ...::... | reflection.kt:126:9:126:13 | invoke | public | | reflection.kt:126:9:126:13 | ...::... | reflection.kt:126:9:126:13 | invoke | public |
compGenerated
| reflection.kt:126:9:126:13 | | 1 |

View File

@@ -86,3 +86,5 @@ query predicate modifiers(ClassInstanceExpr e, Method m, string modifier) {
e.getAnonymousClass().getAMethod() = m and e.getAnonymousClass().getAMethod() = m and
m.hasModifier(modifier) m.hasModifier(modifier)
} }
query predicate compGenerated(Top t, int i) { compiler_generated(t, i) }