From 73313c30151271d0d18c09715aab3af19e201d6e Mon Sep 17 00:00:00 2001 From: Shai Barack Date: Sat, 11 Mar 2023 00:01:15 +0000 Subject: [PATCH] Suppress inline warning Without this suppression, building the code prints: ``` frameworks/base/packages/SystemUI/src/com/android/systemui/util/kotlin/nullability.kt:29:1: warning: expected performance impact from inlining is insignificant. Inlining works best for functions with parameters of functional types inline fun Optional.getOrNull(): T? = orElse(null) ^ ``` Reviewing the documentation here: https://kotlinlang.org/docs/inline-functions.html It seems that the inline warning fires if there are no inlinable function parameters and no reified type parameters, as is the case here. However the original author of the code still thinks this is a reasonable target for inlining as a short method and a common utility, and I don't disagree. I'm suppressing the warning because it seems to be unhelpful, and because build warnings are considered tech debt as per: go/battledroids#clean-up-build-warnings Test: built, warning no longer appears Bug: 217776569 Change-Id: Ic94f4e7d1612679c67e7aaaa46dc884f2f60b7d4 --- .../SystemUI/src/com/android/systemui/util/kotlin/nullability.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/SystemUI/src/com/android/systemui/util/kotlin/nullability.kt b/packages/SystemUI/src/com/android/systemui/util/kotlin/nullability.kt index f3b7e0d24a6ea..298dacde81280 100644 --- a/packages/SystemUI/src/com/android/systemui/util/kotlin/nullability.kt +++ b/packages/SystemUI/src/com/android/systemui/util/kotlin/nullability.kt @@ -26,4 +26,5 @@ inline fun transform(value: T?, block: (T) -> R): R? = value?.let(b /** * Assists type-checking to unpack a Java Optional into T? */ +@Suppress("NOTHING_TO_INLINE") inline fun Optional.getOrNull(): T? = orElse(null)