Skip to content

Kotlin: Fix findTopLevelPropertyOrWarn for K2 compiler - #21915

Merged
andersfugmann merged 1 commit into
github:mainfrom
david-allison:kotlin-dropped-class
Sep 10, 2026
Merged

andersfugmann merged 1 commit into
github:mainfrom
david-allison:kotlin-dropped-class

Conversation

@david-allison

@david-allison david-allison commented May 30, 2026

Copy link
Copy Markdown
Contributor

Note

Assisted-by: Claude Opus 4.8 - diagnostics & initial fix


Receiver::class.java resolves differently from K1:

  • K1: getJavaClass(KClass) - value argument
  • K2: KClass.<get-java>() - property receiver

This caused the lookup to fail, so Intent(context, Receiver::class.java) dropped the second argument.

"Couldn't find JVM intrinsic property kotlin.jvm java in kotlin.jvm.JvmClassMappingKt"

This caused false positives in java/android/implicit-pendingintents

@andersfugmann andersfugmann left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for submitting
The approach and solution is sound and looks good. Also thanks for adding tests.

I added one comment on making the filter slightly more readable.

If you could address that comment and rebase on latest main, this will be good to merge.

@david-allison

Copy link
Copy Markdown
Contributor Author

I added one comment on making the filter slightly more readable.

Hi @andersfugmann, thanks for the review. I don't see your comment in the GitHub UI, could you send a link? (Presumably for KotlinFileExtractor.kt‎, but I'd want to be certain).

I'll try and get to this before the weekend. Thanks again

Comment thread java/kotlin-extractor/src/main/kotlin/KotlinFileExtractor.kt
@andersfugmann

Copy link
Copy Markdown
Contributor

My bad. Forgot to submit the comment :-)

`Receiver::class.java` resolves differently from K1:

K1: getJavaClass(KClass) - value argument
K2: KClass.<get-java>() - property receiver

This caused the lookup to fail, so
`Intent(context, Receiver::class.java)` dropped the second argument.

log:
"Couldn't find JVM intrinsic property kotlin.jvm java in kotlin.jvm.JvmClassMappingKt"

This caused false positives in `java/android/implicit-pendingintents`

The fix mirrors 5c36e63

Fixes github#20153
Assisted-by: Claude Opus 4.8 - diagnostics & initial fix
Assisted-by: Claude Fable 5.1 - convert to 'when'; re-review
@andersfugmann

Copy link
Copy Markdown
Contributor

Internal tests shows no blockers to merge; small reduction in alerts on java/android/implicit-pendingintents and java/local-variable-is-never-read and an increase in alerts on java/jdk-internal-api-access as a result of improved flow.

@andersfugmann

Copy link
Copy Markdown
Contributor

Thanks for addressing the comments. All tests looks good.
Thank you for your contribution.

@andersfugmann
andersfugmann merged commit 3736516 into github:main Sep 10, 2026
19 checks passed
@david-allison
david-allison deleted the kotlin-dropped-class branch September 10, 2026 17:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

False positive "use of implicit PendingIntents" alert

2 participants