Skip to content

Commit

Permalink
Remove stack from AddHiddenFromObjCLowering
Browse files Browse the repository at this point in the history
The stack is not needed since the compiler traverses classes recursively, and we can rely on the traversal order to restore previous values.

Change-Id: Ib992842a69799cc4b9f9be98592003ec0c584d01 ( https://android-review.googlesource.com/q/Ib992842a69799cc4b9f9be98592003ec0c584d01 )

Moved from: androidx/androidx@80dcd61
  • Loading branch information
ShikaSD authored and Space Cloud committed Apr 23, 2024
1 parent a070287 commit 51e1eaf
Showing 1 changed file with 2 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ import androidx.compose.compiler.plugins.kotlin.lower.ComposableSymbolRemapper
import androidx.compose.compiler.plugins.kotlin.lower.containsComposableAnnotation
import androidx.compose.compiler.plugins.kotlin.lower.needsComposableRemapping
import org.jetbrains.kotlin.backend.common.extensions.IrPluginContext
import org.jetbrains.kotlin.backend.common.pop
import org.jetbrains.kotlin.backend.common.push
import org.jetbrains.kotlin.descriptors.DescriptorVisibilities
import org.jetbrains.kotlin.ir.IrStatement
import org.jetbrains.kotlin.ir.declarations.IrClass
Expand Down Expand Up @@ -58,7 +56,6 @@ class AddHiddenFromObjCLowering(
getTopLevelClass(ClassId.fromString("kotlin/native/HiddenFromObjC"))
}

private val shouldAnnotateClass = ArrayDeque<Boolean>()
private var currentShouldAnnotateClass = false

override fun lower(module: IrModuleFragment) {
Expand All @@ -73,7 +70,7 @@ class AddHiddenFromObjCLowering(
* after the issue is resolved, `visitClass` could be removed entirely
*/
override fun visitClass(declaration: IrClass): IrStatement {
shouldAnnotateClass.push(currentShouldAnnotateClass)
val previousShouldAnnotateClass = currentShouldAnnotateClass
currentShouldAnnotateClass = false

val cls = super.visitClass(declaration) as IrClass
Expand All @@ -86,7 +83,7 @@ class AddHiddenFromObjCLowering(
hideFromObjCDeclarationsSet?.add(cls)
}

currentShouldAnnotateClass = shouldAnnotateClass.pop()
currentShouldAnnotateClass = previousShouldAnnotateClass
return cls
}

Expand Down

0 comments on commit 51e1eaf

Please sign in to comment.