Skip to content

fix(notifications): Kotlin Function block return type for openSettings#21

Merged
teslashibe merged 1 commit intomainfrom
fix/notification-capture-kotlin-build
Apr 22, 2026
Merged

fix(notifications): Kotlin Function block return type for openSettings#21
teslashibe merged 1 commit intomainfrom
fix/notification-capture-kotlin-build

Conversation

@teslashibe
Copy link
Copy Markdown
Owner

Summary

EAS Android build for v0.8.0 failed in `:notification-capture:compileReleaseKotlin`:

```
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.

Test plan

  • Surrounding Function blocks audited — no other early-return patterns
  • EAS preview build succeeds: `eas build --platform android --profile preview`

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.
@teslashibe teslashibe merged commit 086b52b into main Apr 22, 2026
1 check passed
@teslashibe teslashibe deleted the fix/notification-capture-kotlin-build branch April 22, 2026 23:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant