Skip to content

Commit 2ab4a72

Browse files
authored
Merge pull request #69 from skydoves/fix/extract-properties-getter
Fix extracting raw FQ name from the property's getter
2 parents 9c56914 + ef56f28 commit 2ab4a72

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

stability-compiler/src/main/kotlin/com/skydoves/compose/stability/compiler/lower/StabilityAnalyzerTransformer.kt

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,29 @@ public class StabilityAnalyzerTransformer(
6161
private val analyzingTypes = ThreadLocal.withInitial { mutableSetOf<String>() }
6262

6363
override fun visitFunctionNew(declaration: IrFunction): IrStatement {
64-
val functionName = declaration.name.asString()
65-
val fqName = declaration.kotlinFqName.asString()
64+
// Handle property getters - extract actual property name
65+
// Property getters have names like "<get-propertyName>"
66+
val rawFunctionName = declaration.name.asString()
67+
val rawFqName = declaration.kotlinFqName.asString()
68+
69+
val nameAndFqn = if (rawFunctionName.startsWith("<get-") && rawFunctionName.endsWith(">")) {
70+
// This is a property getter - extract property name
71+
val propertyName = rawFunctionName.substring(5, rawFunctionName.length - 1)
72+
73+
// Build proper FQN by replacing <get-xxx> with property name
74+
val propertyFqName = if (rawFqName.contains("<get-")) {
75+
rawFqName.replace(Regex("<get-([^>]+)>"), "$1")
76+
} else {
77+
rawFqName
78+
}
79+
80+
Pair(propertyName, propertyFqName)
81+
} else {
82+
Pair(rawFunctionName, rawFqName)
83+
}
84+
85+
val functionName = nameAndFqn.first
86+
val fqName = nameAndFqn.second
6687

6788
// Check if function has @TraceRecomposition annotation
6889
val hasTraceRecomposition = declaration.hasAnnotation(traceRecompositionFqName)

0 commit comments

Comments
 (0)