Skip to content

fix(nitrogen): avoid impossible type check for RecyclableView on Kotlin 2.4 - #2011

Open
guettonenrique wants to merge 1 commit into
margelo:mainfrom
guettonenrique:fix/kotlin-2.4-view-manager-recycle
Open

guettonenrique wants to merge 1 commit into
margelo:mainfrom
guettonenrique:fix/kotlin-2.4-view-manager-recycle

Conversation

@guettonenrique

Copy link
Copy Markdown

Summary

Fixes a fatal Android compilation error when building Nitro Hybrid Views with Kotlin 2.4+.

Problem

Under Kotlin 2.4.0 (KTLC-365: "Prohibit always-false is checks for definitely incompatible types"), statically impossible is checks between final classes and unrelated interfaces were upgraded from compiler warnings to fatal compilation errors.

When a Kotlin HybridView implementation class does not implement RecyclableView, Nitrogen's generated ViewManager contains:

@Suppress("USELESS_IS_CHECK")
if (hybridView is RecyclableView) { ... }

Because hybridView is a final class that doesn't implement RecyclableView, this fails compilation on Kotlin 2.4+ with:

Check for instance is always 'false'.

Because this is now a fatal compilation error in Kotlin 2.4, @Suppress("USELESS_IS_CHECK") can no longer suppress it.

Solution

  • Upcast hybridView through Any first (val recyclableView = (hybridView as Any) as? RecyclableView). This satisfies Kotlin 2.4's static type checker while remaining fully compatible with earlier Kotlin versions and preserving exact runtime semantics.
  • Called bun specs to regenerate and update the committed test fixture bindings in tests/react-native/.

Test plan

1. Monorepo Build & Typecheck

  • Ran: bun run build and bun typecheck
    • Result: Both completed with exit code 0 across all workspaces.

2. Nitrogen Output Verification

  • Ran: bun specs
    • Result: Successfully regenerated all Nitrogen bindings and updated tests/react-native/ test fixtures with no unexpected diffs.

3. Real-World Android Build

  • Ran: Android build on an Expo SDK 58 project with Kotlin 2.4.0.
    • Result: View managers compiled and assembled cleanly (BUILD SUCCESSFUL), eliminating the fatal Check for instance is always 'false' error.

Checklist

  • Ran bun run build and bun typecheck
  • Ran bun specs and committed all generated fixture updates

@vercel

vercel Bot commented Oct 25, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
nitro-docs Skipped Skipped Oct 25, 2026 11:49am UTC

Request Review

This branch was previously deployed

1 inactive deployment
Preview — 21950bad Deployed Oct 25, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant