[go: nahoru, domu]

Add a lint check to the UI Module

This adds a lint check to ensure that check and require
methods always specify a lazyMessage param.

When we read user-supplied logs, the line numbers are
sometimes not sufficient to determine the cause of a bug.
Inline functions can also make it hard to determine which
file threw an exception, so this lint check will ensure
that we write an error message, and not rely on the line
number provided along with the stacktrace.

Bug: 280941088
Test: Added a new test ExceptionMessageDetectorTest
Change-Id: I81f0d91cd8c6012b15a0ec22ce7e59e1157a71e2
diff --git a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/selection/SelectionManager.kt b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/selection/SelectionManager.kt
index bb0671b..62e6c4b 100644
--- a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/selection/SelectionManager.kt
+++ b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/selection/SelectionManager.kt
@@ -371,8 +371,8 @@
      */
     internal fun requireContainerCoordinates(): LayoutCoordinates {
         val coordinates = containerLayoutCoordinates
-        require(coordinates != null)
-        require(coordinates.isAttached)
+        requireNotNull(coordinates) { "null coordinates" }
+        require(coordinates.isAttached) { "unattached coordinates" }
         return coordinates
     }