Skip to content

Commit de5b37e

Browse files
mdvaccafacebook-github-bot
authored andcommitted
Fix FieldsBelowInit and KotlinGenericsCast: Move properties above init block (facebook#55357)
Summary: 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
1 parent 264eba3 commit de5b37e

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

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)