diff --git a/android/src/main/java/com/facebook/flipper/plugins/uidebugger/core/AttributeEditor.kt b/android/src/main/java/com/facebook/flipper/plugins/uidebugger/core/AttributeEditor.kt index 48c9751060e..9cb5074bdbb 100644 --- a/android/src/main/java/com/facebook/flipper/plugins/uidebugger/core/AttributeEditor.kt +++ b/android/src/main/java/com/facebook/flipper/plugins/uidebugger/core/AttributeEditor.kt @@ -54,7 +54,8 @@ class AttributeEditor( val stack = mutableListOf(applicationRef) while (stack.isNotEmpty()) { - val curNode = stack.removeLast() + // Workaround for a JDK21/Kotlin bug, see KT-66044 + val curNode = checkNotNull(stack.removeLastOrNull()) val curDescriptor = descriptorRegister.descriptorForClassUnsafe(curNode.javaClass) if (curDescriptor.getId(curNode) == nodeId) { return curNode diff --git a/android/src/main/java/com/facebook/flipper/plugins/uidebugger/core/BitmapPool.kt b/android/src/main/java/com/facebook/flipper/plugins/uidebugger/core/BitmapPool.kt index 7d2dd19b830..560b6d85520 100644 --- a/android/src/main/java/com/facebook/flipper/plugins/uidebugger/core/BitmapPool.kt +++ b/android/src/main/java/com/facebook/flipper/plugins/uidebugger/core/BitmapPool.kt @@ -48,7 +48,8 @@ class BitmapPool(private val config: Bitmap.Config = Bitmap.Config.RGB_565) { return if (bitmaps == null || bitmaps.isEmpty()) { LeasedBitmap(Bitmap.createBitmap(width, height, config)) } else { - LeasedBitmap(bitmaps.removeLast()) + // Workaround for a JDK21/Kotlin bug, see KT-66044 + LeasedBitmap(checkNotNull(bitmaps.removeLastOrNull())) } } diff --git a/android/src/main/java/com/facebook/flipper/plugins/uidebugger/core/LayoutTraversal.kt b/android/src/main/java/com/facebook/flipper/plugins/uidebugger/core/LayoutTraversal.kt index 1361ca17190..8af64610b4a 100644 --- a/android/src/main/java/com/facebook/flipper/plugins/uidebugger/core/LayoutTraversal.kt +++ b/android/src/main/java/com/facebook/flipper/plugins/uidebugger/core/LayoutTraversal.kt @@ -41,7 +41,8 @@ class LayoutTraversal( val shallow = mutableSetOf() while (stack.isNotEmpty()) { - val (node, parentId) = stack.removeLast() + // Workaround for a JDK21/Kotlin bug, see KT-66044 + val (node, parentId) = checkNotNull(stack.removeLastOrNull()) try {