Skip to content

Add reflective fallback for useK2 to support Kotlin 2.3.0+#95

Merged
ZacSweers merged 2 commits intoZacSweers:mainfrom
jstewart5000:js_getUseK2_method_vanished
Dec 5, 2025
Merged

Add reflective fallback for useK2 to support Kotlin 2.3.0+#95
ZacSweers merged 2 commits intoZacSweers:mainfrom
jstewart5000:js_getUseK2_method_vanished

Conversation

@jstewart5000
Copy link

@jstewart5000 jstewart5000 commented Dec 5, 2025

Summary

This PR adds a defensive getUseK2Value helper to handle the removal of useK2 in Kotlin 2.3.0+.
In newer Kotlin versions, the getUseK2() property no longer exists, causing reflective lookups to fail.
To ensure forward compatibility, the new method attempts to read useK2 via reflection when available, and safely falls back to the Kotlin 2.3.0+ default behavior (useK2 = true) when the property or its provider cannot be accessed.

  • Uses reflection to read useK2 only when the property exists (older Kotlin versions).
  • If reflection fails, logs the reason and defaults to true.
  • Prevents crashes related to missing getUseK2() in Kotlin 2.3.0+.

@ZacSweers ZacSweers merged commit 72f48cf into ZacSweers:main Dec 5, 2025
15 checks passed
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.

2 participants