diff --git a/packages/react-native/ReactAndroid/api/ReactAndroid.api b/packages/react-native/ReactAndroid/api/ReactAndroid.api index 489dae1d463d7f..db7aa76a43c6a2 100644 --- a/packages/react-native/ReactAndroid/api/ReactAndroid.api +++ b/packages/react-native/ReactAndroid/api/ReactAndroid.api @@ -4040,6 +4040,8 @@ public abstract class com/facebook/react/uimanager/BaseViewManager : com/faceboo public abstract class com/facebook/react/uimanager/BaseViewManagerDelegate : com/facebook/react/uimanager/ViewManagerDelegate { protected final field mViewManager Lcom/facebook/react/uimanager/BaseViewManager; public fun (Lcom/facebook/react/uimanager/BaseViewManager;)V + public synthetic fun kotlinCompat$receiveCommand (Landroid/view/View;Ljava/lang/String;Lcom/facebook/react/bridge/ReadableArray;)V + public synthetic fun kotlinCompat$setProperty (Landroid/view/View;Ljava/lang/String;Ljava/lang/Object;)V public fun receiveCommand (Landroid/view/View;Ljava/lang/String;Lcom/facebook/react/bridge/ReadableArray;)V public fun setProperty (Landroid/view/View;Ljava/lang/String;Ljava/lang/Object;)V } @@ -5230,8 +5232,10 @@ public abstract class com/facebook/react/uimanager/ViewManager : com/facebook/re } public abstract interface class com/facebook/react/uimanager/ViewManagerDelegate { - public abstract fun receiveCommand (Landroid/view/View;Ljava/lang/String;Lcom/facebook/react/bridge/ReadableArray;)V - public abstract fun setProperty (Landroid/view/View;Ljava/lang/String;Ljava/lang/Object;)V + public abstract synthetic fun kotlinCompat$receiveCommand (Landroid/view/View;Ljava/lang/String;Lcom/facebook/react/bridge/ReadableArray;)V + public abstract synthetic fun kotlinCompat$setProperty (Landroid/view/View;Ljava/lang/String;Ljava/lang/Object;)V + public fun receiveCommand (Landroid/view/View;Ljava/lang/String;Lcom/facebook/react/bridge/ReadableArray;)V + public fun setProperty (Landroid/view/View;Ljava/lang/String;Ljava/lang/Object;)V } public class com/facebook/react/uimanager/ViewManagerPropertyUpdater { diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/BaseViewManagerDelegate.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/BaseViewManagerDelegate.kt index 8c2a95fedb66e9..6c0c24890d874c 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/BaseViewManagerDelegate.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/BaseViewManagerDelegate.kt @@ -23,8 +23,8 @@ public abstract class BaseViewManagerDelegate< T : View, U : BaseViewManager>( @Suppress("NoHungarianNotation") @JvmField protected val mViewManager: U ) : ViewManagerDelegate { - @Suppress("DEPRECATION") - override public fun setProperty(view: T, propName: String?, value: Any?) { + @Suppress("ACCIDENTAL_OVERRIDE", "DEPRECATION") + override public fun setProperty(view: T, propName: String, value: Any?) { when (propName) { ViewProps.ACCESSIBILITY_ACTIONS -> mViewManager.setAccessibilityActions(view, value as ReadableArray?) @@ -146,6 +146,7 @@ public abstract class BaseViewManagerDelegate< } } - override public fun receiveCommand(view: T, commandName: String?, args: ReadableArray?): Unit = + @Suppress("ACCIDENTAL_OVERRIDE") + override public fun receiveCommand(view: T, commandName: String, args: ReadableArray?): Unit = Unit } diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewManagerDelegate.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewManagerDelegate.kt index 534384b0ecedf9..f6feec147db2b8 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewManagerDelegate.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewManagerDelegate.kt @@ -22,20 +22,38 @@ public interface ViewManagerDelegate { /** * Sets a property on a view managed by this view manager. * + * We mark this method as synthetic / hide it from JVM so Java callers will call the deprecated + * version and overrides work correctly. + * * @param view the view to set the property on - * @param propName the name of the property to set (NOTE: should be `String` but is kept as - * `String?` to avoid breaking changes) + * @param propName the name of the property to set * @param value the value to set the property to */ - public fun setProperty(view: T, propName: String?, value: Any?) + @Suppress("INAPPLICABLE_JVM_NAME") + @JvmName("kotlinCompat\$setProperty") + @JvmSynthetic + public fun setProperty(view: T, propName: String, value: Any?) + + @Deprecated(message = "propName is not nullable, please update your method signature") + public fun setProperty(view: T, propName: String?, value: Any?): Unit = + setProperty(view, checkNotNull(propName), value) /** * Executes a command from JS to the view * + * We mark this method as synthetic / hide it from JVM so Java callers will call the deprecated + * version and overrides work correctly. + * * @param view the view to execute the command on - * @param commandName the name of the command to execute (NOTE: should be `String` but is kept as - * `String?` to avoid breaking changes) + * @param commandName the name of the command to execute * @param args the arguments to pass to the command */ - public fun receiveCommand(view: T, commandName: String?, args: ReadableArray?) + @Suppress("INAPPLICABLE_JVM_NAME") + @JvmName("kotlinCompat\$receiveCommand") + @JvmSynthetic + public fun receiveCommand(view: T, commandName: String, args: ReadableArray?) + + @Deprecated(message = "commandName is not nullable, please update your method signature") + public fun receiveCommand(view: T, commandName: String?, args: ReadableArray?): Unit = + receiveCommand(view, checkNotNull(commandName), args) }