-
Notifications
You must be signed in to change notification settings - Fork 25.1k
Fix UnsafeDereference: Replace !! with requireNotNull #55356
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
Closed
+20
−10
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
723f6e1 to
856e93c
Compare
856e93c to
2cb1445
Compare
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 Reviewed By: alanleedev Differential Revision: D91731458
2cb1445 to
523dd03
Compare
mdvacca
added a commit
to mdvacca/react-native
that referenced
this pull request
Jan 29, 2026
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 Reviewed By: alanleedev Differential Revision: D91731458
mdvacca
added a commit
to mdvacca/react-native
that referenced
this pull request
Jan 29, 2026
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 Reviewed By: alanleedev Differential Revision: D91731458
mdvacca
added a commit
to mdvacca/react-native
that referenced
this pull request
Jan 29, 2026
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 Reviewed By: alanleedev Differential Revision: D91731458
|
This pull request has been merged in 4db3ca8. |
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 UnsafeDereference lint errors in BridgelessCatalystInstance.kt.
Replaced unsafe !! operator with requireNotNull() for:
This provides better error messages when null values are encountered.
changelog: [internal] internal
Reviewed By: alanleedev
Differential Revision: D91731458