Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix nullability of ViewManagerDelegate method args #48602

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions packages/react-native/ReactAndroid/api/ReactAndroid.api
Original file line number Diff line number Diff line change
Expand Up @@ -4041,6 +4041,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 <init> (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
}
Expand Down Expand Up @@ -5231,8 +5233,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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ public abstract class BaseViewManagerDelegate<
T : View, U : BaseViewManager<T, out LayoutShadowNode>>(
@Suppress("NoHungarianNotation") @JvmField protected val mViewManager: U
) : ViewManagerDelegate<T> {
@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?)
Expand Down Expand Up @@ -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
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,42 @@ public interface ViewManagerDelegate<T : View> {
/**
* 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?)

@Suppress("INAPPLICABLE_JVM_NAME")
@Deprecated(message = "propName is not nullable, please update your method signature")
@JvmName("setProperty")
public fun javaCompat_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?)

@Suppress("INAPPLICABLE_JVM_NAME")
@Deprecated(message = "commandName is not nullable, please update your method signature")
@JvmName("receiveCommand")
public fun javaCompat_receiveCommand(view: T, commandName: String?, args: ReadableArray?): Unit =
receiveCommand(view, checkNotNull(commandName), args)
}
Loading