Skip to content

Commit 6c3fb21

Browse files
compose-compiler: fix HiddenFromObjC name clash
fixes JetBrains/compose-multiplatform#4777 `fqName` were used before, but they aren't unique for example, we can have class, several functions and property with the same fqName, so descriptors should be used (they are guaranteed to be unique for current compilation set/module) Test: tested against Compose Multiplatform testsuite Change-Id: I44a56c52267e548639a08a949b3e9447422b0533 Signed-off-by: Pavel Shishkin <[email protected]>
1 parent af148c7 commit 6c3fb21

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

compose/compiler/compiler-hosted/src/main/java/androidx/compose/compiler/plugins/kotlin/lower/hiddenfromobjc/HideFromObjCDeclarationsSet.kt

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI
2121
import org.jetbrains.kotlin.ir.declarations.IrClass
2222
import org.jetbrains.kotlin.ir.declarations.IrFunction
2323
import org.jetbrains.kotlin.ir.declarations.IrProperty
24-
import org.jetbrains.kotlin.name.FqName
25-
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe
2624

2725
/**
2826
* Represents a set of declarations that should have
@@ -42,21 +40,21 @@ import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe
4240
@OptIn(ObsoleteDescriptorBasedAPI::class)
4341
class HideFromObjCDeclarationsSet {
4442

45-
private val set = mutableSetOf<FqName>()
43+
private val declarationsSet = mutableSetOf<DeclarationDescriptor>()
4644

4745
fun add(function: IrFunction) {
48-
set.add(function.descriptor.fqNameSafe)
46+
declarationsSet.add(function.descriptor)
4947
}
5048

5149
fun add(property: IrProperty) {
52-
set.add(property.descriptor.fqNameSafe)
50+
declarationsSet.add(property.descriptor)
5351
}
5452

5553
fun add(cls: IrClass) {
56-
set.add(cls.descriptor.fqNameSafe)
54+
declarationsSet.add(cls.descriptor)
5755
}
5856

59-
operator fun contains(item: DeclarationDescriptor): Boolean {
60-
return set.contains(item.fqNameSafe)
57+
operator fun contains(descriptor: DeclarationDescriptor): Boolean {
58+
return declarationsSet.contains(descriptor)
6159
}
6260
}

0 commit comments

Comments
 (0)