Skip to content

Commit c9d1e05

Browse files
mdvaccameta-codesync[bot]
authored andcommitted
Fix FieldsBelowInit and KotlinGenericsCast: Move properties above init block (#55357)
Summary: Pull Request resolved: #55357 Fixed FieldsBelowInit lint errors in BridgelessReactContext.kt. Moved property declarations (devSupportManager, defaultHardwareBackBtnHandler) above the init block to ensure proper initialization order. Also added Suppress for KotlinGenericsCast warning on the generic cast that is necessary for the proxy implementation. changelog: [internal] internal Reviewed By: cortinico Differential Revision: D91731938 fbshipit-source-id: 194fa6ae5d484d353b553bc0b42cf5a37c15877c
1 parent 4db3ca8 commit c9d1e05

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/BridgelessReactContext.kt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@ internal class BridgelessReactContext(context: Context, private val reactHost: R
4949
private val sourceURLRef = AtomicReference<String>()
5050
private val TAG: String = this.javaClass.simpleName
5151

52+
val devSupportManager: DevSupportManager
53+
get() = reactHost.devSupportManager
54+
55+
val defaultHardwareBackBtnHandler: DefaultHardwareBackBtnHandler
56+
get() = reactHost.defaultBackButtonHandler
57+
5258
init {
5359
if (ReactNativeNewArchitectureFeatureFlags.useFabricInterop()) {
5460
initializeInteropModules()
@@ -103,9 +109,6 @@ internal class BridgelessReactContext(context: Context, private val reactHost: R
103109

104110
override fun destroy() = Unit
105111

106-
val devSupportManager: DevSupportManager
107-
get() = reactHost.devSupportManager
108-
109112
override fun registerSegment(segmentId: Int, path: String, callback: Callback) {
110113
reactHost.registerSegment(segmentId, path, callback)
111114
}
@@ -145,7 +148,7 @@ internal class BridgelessReactContext(context: Context, private val reactHost: R
145148
arrayOf<Class<*>>(jsInterface),
146149
BridgelessJSModuleInvocationHandler(reactHost, jsInterface),
147150
) as JavaScriptModule
148-
@Suppress("UNCHECKED_CAST")
151+
@Suppress("UNCHECKED_CAST", "KotlinGenericsCast")
149152
return interfaceProxy as? T
150153
}
151154

@@ -178,7 +181,4 @@ internal class BridgelessReactContext(context: Context, private val reactHost: R
178181
}
179182

180183
override fun getJSCallInvokerHolder(): CallInvokerHolder? = reactHost.jsCallInvokerHolder
181-
182-
val defaultHardwareBackBtnHandler: DefaultHardwareBackBtnHandler
183-
get() = reactHost.defaultBackButtonHandler
184184
}

0 commit comments

Comments
 (0)