-
Notifications
You must be signed in to change notification settings - Fork 25.1k
Fix FieldsBelowInit and KotlinGenericsCast: Move properties above init block #55357
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
Conversation
a81d387 to
bbe4541
Compare
bbe4541 to
55e62b5
Compare
cortinico
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review automatically exported from Phabricator review in Meta.
Summary: **Lint Issue:** ANDROIDLINT FieldsBelowInit warning on line 347. The `nativeModules` property was declared below the init block. The lint warns that fields declared after init blocks can lead to initialization order issues in Kotlin, where the field might not be available during the init block execution. **Fix:** Moved the `nativeModules` computed property declaration to before the init block, alongside other property declarations. Since this is a computed property (getter only), there's no actual initialization order issue, but placing it before the init block follows Kotlin best practices and avoids confusion. Differential Revision: D91709480
Summary: **Lint Issue:** ANDROIDLINT FieldsBelowInit warning on line 480. The `eventDispatcher` property was declared below the init block. The lint warns that fields declared after init blocks can lead to initialization order issues in Kotlin, where the field might not be available during the init block execution. **Fix:** Moved the `eventDispatcher` computed property declaration to before the init block, alongside other property declarations. Since this is a computed property (getter only) that returns `fabricUIManager.eventDispatcher`, there's no actual initialization order issue, but placing it before the init block follows Kotlin best practices and avoids confusion. Differential Revision: D91709482
Summary:
**Lint Issue:** ANDROIDLINT KotlinGenericsCast warning on line 361.
The `getNativeModule` function casts `turboModuleManager.getModule(nativeModuleName)` to generic type `T?`. The lint warns that casts to erased Kotlin generic type references are only checked at compile time, and at runtime, casts to type arguments of a generic function are unchecked due to type erasure.
**Fix:** Added `SuppressLint("KotlinGenericsCast")` annotation to the function. The existing `Suppress("UNCHECKED_CAST")` only suppresses the Kotlin compiler warning, not the AndroidLint warning. This cast is intentional and unavoidable given the API design where callers specify the expected return type.
Differential Revision: D91709481
Summary: Fixed EmptyCatchBlock lint error in BridgelessAtomicRef.kt. Added a comment explaining that the InterruptedException is intentionally caught to record the interrupt status, which is then restored after the wait loop completes. This is a standard pattern for proper interrupt handling. changelog: [internal] internal Differential Revision: D91728772
cortinico
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review automatically exported from Phabricator review in Meta.
Summary: Fixed UnsafeDereference lint errors in BridgelessCatalystInstance.kt. Replaced unsafe !! operator with requireNotNull() for: - javaScriptContextHolder - jsCallInvokerHolder - reactQueueConfiguration This provides better error messages when null values are encountered. changelog: [internal] internal Differential Revision: D91731458
…t block 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
55e62b5 to
57befce
Compare
…t 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
…t 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
…t 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
|
This pull request has been merged in c9d1e05. |
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