From 5831758c0fdce4711b2e119a8a58cb435ea84dfd Mon Sep 17 00:00:00 2001 From: teslashibe <34052452+teslashibe@users.noreply.github.com> Date: Wed, 22 Apr 2026 16:30:22 -0700 Subject: [PATCH] fix(notifications): Kotlin Function block return type for openSettings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit EAS Android build for v0.8.0 failed in :notification-capture:compileReleaseKotlin with: e: NotificationCaptureModule.kt:51:50 Return type mismatch: expected 'Any?', actual 'Unit'. The Expo Modules `Function` DSL infers its return type from the lambda body. Single-expression bodies that evaluate to Unit (e.g. setEnabled, setAllowlist) compile fine because Kotlin promotes Unit to Any?. But openSettings used an early `return@Function` (no value) followed by a tail Unit expression, which forced the inferred return type to Unit and clashed with the DSL's Any? overload selection. Fix: replace the early-return idiom with a `?.let { ... }` scope so the lambda has a single tail expression (the let returns Unit?, which the compiler happily widens to Any?). Pure compile fix — no behavioural change. Verified by a clean local re-read of the surrounding Function blocks; no other early-return patterns in the module. Re-trigger EAS build after merge. --- .../notificationcapture/NotificationCaptureModule.kt | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/mobile/modules/notification-capture/android/src/main/java/expo/modules/notificationcapture/NotificationCaptureModule.kt b/mobile/modules/notification-capture/android/src/main/java/expo/modules/notificationcapture/NotificationCaptureModule.kt index 3848c74..6e3a2e9 100644 --- a/mobile/modules/notification-capture/android/src/main/java/expo/modules/notificationcapture/NotificationCaptureModule.kt +++ b/mobile/modules/notification-capture/android/src/main/java/expo/modules/notificationcapture/NotificationCaptureModule.kt @@ -48,11 +48,12 @@ class NotificationCaptureModule : Module() { } Function("openSettings") { - val ctx = appContext.reactContext ?: return@Function - val intent = Intent(Settings.ACTION_NOTIFICATION_LISTENER_SETTINGS).apply { - addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) + appContext.reactContext?.let { ctx -> + val intent = Intent(Settings.ACTION_NOTIFICATION_LISTENER_SETTINGS).apply { + addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) + } + ctx.startActivity(intent) } - ctx.startActivity(intent) } Function("isEnabled") { store.isEnabled() }