Skip to content

Commit

Permalink
compose-compiler: fix HiddenFromObjC name clash
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
shishkin-pavel committed May 10, 2024
1 parent af148c7 commit 6c3fb21
Showing 1 changed file with 6 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI
import org.jetbrains.kotlin.ir.declarations.IrClass
import org.jetbrains.kotlin.ir.declarations.IrFunction
import org.jetbrains.kotlin.ir.declarations.IrProperty
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe

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

private val set = mutableSetOf<FqName>()
private val declarationsSet = mutableSetOf<DeclarationDescriptor>()

fun add(function: IrFunction) {
set.add(function.descriptor.fqNameSafe)
declarationsSet.add(function.descriptor)
}

fun add(property: IrProperty) {
set.add(property.descriptor.fqNameSafe)
declarationsSet.add(property.descriptor)
}

fun add(cls: IrClass) {
set.add(cls.descriptor.fqNameSafe)
declarationsSet.add(cls.descriptor)
}

operator fun contains(item: DeclarationDescriptor): Boolean {
return set.contains(item.fqNameSafe)
operator fun contains(descriptor: DeclarationDescriptor): Boolean {
return declarationsSet.contains(descriptor)
}
}

0 comments on commit 6c3fb21

Please sign in to comment.