From 8203a8c3073c3d90277ba92dda23e5377186f7ca Mon Sep 17 00:00:00 2001 From: Jake Wharton Date: Fri, 13 Oct 2023 04:56:19 -0400 Subject: [PATCH] Fix a generic type reference (#1587) We used the wrong one here, and it ends up removing the need to do two unchecked casts. --- .../kotlin/app/cash/redwood/compose/WidgetApplier.kt | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/redwood-compose/src/commonMain/kotlin/app/cash/redwood/compose/WidgetApplier.kt b/redwood-compose/src/commonMain/kotlin/app/cash/redwood/compose/WidgetApplier.kt index e7b209c748..17db89fb0a 100644 --- a/redwood-compose/src/commonMain/kotlin/app/cash/redwood/compose/WidgetApplier.kt +++ b/redwood-compose/src/commonMain/kotlin/app/cash/redwood/compose/WidgetApplier.kt @@ -84,7 +84,6 @@ internal class NodeApplier( // traversing down the tree. This ensures we can add widget nodes to children nodes in // bottom-up order. if (instance is ChildrenNode) { - @Suppress("UNCHECKED_CAST") // Guaranteed by generated code. val widgetNode = current as WidgetNode, W> instance.attachTo(widgetNode.widget) } @@ -96,7 +95,6 @@ internal class NodeApplier( // We only attach widgets to their parent node's children when traversing back up the tree. // This ensures that the initial properties of the widget have been set before it is attached. if (instance is WidgetNode<*, *>) { - @Suppress("UNCHECKED_CAST") // Guaranteed by generated code. val widgetNode = instance as WidgetNode, W> val current = current as ChildrenNode val children = current.children @@ -141,10 +139,10 @@ public sealed interface Node * @suppress For generated code usage only. */ @RedwoodCodegenApi -public class WidgetNode, V : Any>( +public class WidgetNode, V : Any>( private val applier: RedwoodApplier, public val widget: W, -) : Node { +) : Node { public fun recordChanged() { applier.recordChanged(widget) }