-
Notifications
You must be signed in to change notification settings - Fork 25.1k
Fix FieldsBelowInit: Move viewportOffset property above init block #55358
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
Closed
+41
−31
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10e10bf to
daa8ead
Compare
daa8ead to
6610dfe
Compare
cortinico
approved these changes
Jan 29, 2026
Contributor
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
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 Differential Revision: D91731938
Summary: Fixed FieldsBelowInit lint error in ReactSurfaceView.kt. Moved the viewportOffset property declaration above the init block to ensure proper initialization order and satisfy Kotlin best practices for property declarations. changelog: [internal] internal Reviewed By: cortinico Differential Revision: D91732184
6610dfe to
c7d24e1
Compare
mdvacca
added a commit
to mdvacca/react-native
that referenced
this pull request
Jan 29, 2026
…acebook#55358) Summary: Fixed FieldsBelowInit lint error in ReactSurfaceView.kt. Moved the viewportOffset property declaration above the init block to ensure proper initialization order and satisfy Kotlin best practices for property declarations. changelog: [internal] internal Reviewed By: cortinico Differential Revision: D91732184
mdvacca
added a commit
to mdvacca/react-native
that referenced
this pull request
Jan 29, 2026
…acebook#55358) Summary: Fixed FieldsBelowInit lint error in ReactSurfaceView.kt. Moved the viewportOffset property declaration above the init block to ensure proper initialization order and satisfy Kotlin best practices for property declarations. changelog: [internal] internal Reviewed By: cortinico Differential Revision: D91732184
mdvacca
added a commit
to mdvacca/react-native
that referenced
this pull request
Jan 29, 2026
…acebook#55358) Summary: Fixed FieldsBelowInit lint error in ReactSurfaceView.kt. Moved the viewportOffset property declaration above the init block to ensure proper initialization order and satisfy Kotlin best practices for property declarations. changelog: [internal] internal Reviewed By: cortinico Differential Revision: D91732184
mdvacca
added a commit
to mdvacca/react-native
that referenced
this pull request
Jan 29, 2026
…acebook#55358) Summary: Fixed FieldsBelowInit lint error in ReactSurfaceView.kt. Moved the viewportOffset property declaration above the init block to ensure proper initialization order and satisfy Kotlin best practices for property declarations. changelog: [internal] internal Reviewed By: cortinico Differential Revision: D91732184
|
This pull request has been merged in 41057d0. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
CLA Signed
This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
fb-exported
Merged
This PR has been merged.
meta-exported
Shared with Meta
Applied via automation to indicate that an Issue or Pull Request has been shared with the team.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary:
Fixed FieldsBelowInit lint error in ReactSurfaceView.kt.
Moved the viewportOffset property declaration above the init block to ensure proper initialization order and satisfy Kotlin best practices for property declarations.
changelog: [internal] internal
Reviewed By: cortinico
Differential Revision: D91732184