Skip to content

Commit 46b28b1

Browse files
demiurg906Space Cloud
authored andcommitted
[Parcelize] Don't use lookup predicate for matching parcelable classes
After previous commits, any class referenced by lookup predicate is considered as dirty for the incremental compilation. Since parcelize actually doesn't need to find all parcelable classes, but either needs just to check if something is parcelable, it's better to use `DeclarationPredicate` for that, so the IC won't be affected. The need of this change was found thanks to the following test: `Kapt4AndroidIncrementalWithoutPreciseBackupIT.testAndroidDaggerIC` ^KT-75864
1 parent 8064fcc commit 46b28b1

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

plugins/parcelize/parcelize-compiler/parcelize.k2/src/org/jetbrains/kotlin/parcelize/fir/FirParcelizeDeclarationGenerator.kt

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import org.jetbrains.kotlin.fir.declarations.utils.modality
1414
import org.jetbrains.kotlin.fir.extensions.FirDeclarationGenerationExtension
1515
import org.jetbrains.kotlin.fir.extensions.FirDeclarationPredicateRegistrar
1616
import org.jetbrains.kotlin.fir.extensions.MemberGenerationContext
17-
import org.jetbrains.kotlin.fir.extensions.predicate.LookupPredicate
17+
import org.jetbrains.kotlin.fir.extensions.predicate.DeclarationPredicate
1818
import org.jetbrains.kotlin.fir.extensions.predicateBasedProvider
1919
import org.jetbrains.kotlin.fir.plugin.SimpleFunctionBuildingContext
2020
import org.jetbrains.kotlin.fir.plugin.createConeType
@@ -44,17 +44,11 @@ class FirParcelizeDeclarationGenerator(
4444
private val parcelizeMethodsNames = setOf(DESCRIBE_CONTENTS_NAME, WRITE_TO_PARCEL_NAME)
4545
}
4646

47-
private val predicate = LookupPredicate.create { annotated(annotations) }
48-
49-
private val matchedClasses by lazy {
50-
session.predicateBasedProvider.getSymbolsByPredicate(predicate)
51-
.filterIsInstance<FirRegularClassSymbol>()
52-
}
47+
private val predicate = DeclarationPredicate.create { annotated(annotations) }
5348

5449
override fun generateFunctions(callableId: CallableId, context: MemberGenerationContext?): List<FirNamedFunctionSymbol> {
55-
val owner = context?.owner ?: return emptyList()
56-
if (!checkParcelizeClassSymbols(owner, session) { it in matchedClasses }) return emptyList()
57-
require(owner is FirRegularClassSymbol)
50+
val owner = context?.owner as? FirRegularClassSymbol ?: return emptyList()
51+
if (!checkParcelizeClassSymbols(owner, session) { session.predicateBasedProvider.matches(predicate, it) }) return emptyList()
5852
val function = when (callableId.callableName) {
5953
DESCRIBE_CONTENTS_NAME -> {
6054
val hasDescribeContentImplementation = owner.hasDescribeContentsImplementation() ||

0 commit comments

Comments
 (0)