From df4cadc126690ff09ea653b2d02874b892e897f2 Mon Sep 17 00:00:00 2001 From: Nicola Corti Date: Mon, 8 Jun 2026 10:01:26 -0700 Subject: [PATCH] Make CustomEventNamesResolver a fun interface for SAM conversion (#57112) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/57112 `UIManagerModule` was recently converted from Java to Kotlin. The nested `CustomEventNamesResolver` interface has a single abstract method, but was declared as a regular `interface` rather than `fun interface`. In Java, single-method interfaces support SAM (Single Abstract Method) conversion in Kotlin callers. After the Kotlin conversion, SAM conversion no longer works unless the interface is declared as `fun interface`. This breaks downstream libraries like `react-native-reanimated` that use lambda syntax to instantiate `CustomEventNamesResolver`: ``` UIManagerModule.CustomEventNamesResolver { eventName -> ... } ``` Adding `fun` restores SAM conversion support. This is backward compatible — existing `object : CustomEventNamesResolver { ... }` code continues to work. Reviewed By: cipolleschi Differential Revision: D107891295 fbshipit-source-id: da3f76aad4716a9646fd3841df3e13f610642453 --- .../main/java/com/facebook/react/uimanager/UIManagerModule.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModule.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModule.kt index 923f9ea0dd6..e2da958fb23 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModule.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModule.kt @@ -85,7 +85,7 @@ import java.util.concurrent.CopyOnWriteArrayList public open class UIManagerModule : ReactContextBaseJavaModule, LifecycleEventListener, UIManager { /** Resolves a name coming from native side to a name of the event that is exposed to JS. */ - public interface CustomEventNamesResolver { + public fun interface CustomEventNamesResolver { /** Returns custom event name by the provided event name. */ public fun resolveCustomEventName(eventName: String): String? }