Skip to content

Commit

Permalink
[GH] Replace usage of java.lang.Class with kotlin.reflect.KClass
Browse files Browse the repository at this point in the history
When generating an `equals` method from `commonMain` code, Studio suggests the usage of `if (other == null || this::class != other::class) return false` instead of `if (javaClass != other?.javaClass) return false`. I'm just calling this out because of the following line:

https://github.com/androidx/androidx/blob/88877d72f62df51fc9dd040da322c9046aa81f67/paging/paging-common/src/main/kotlin/androidx/paging/TransformablePage.kt#L90-L93

Test: ./gradlew test connectedCheck
Bug: 270612487

This is an imported pull request from androidx#557.

Resolves #557
Github-Pr-Head-Sha: 46f0a47
GitOrigin-RevId: 6174fc5
Change-Id: I3cea473d5c722a3f4e4a212e36db253de976670e
  • Loading branch information
veyndan authored and copybara-github committed Jun 12, 2023
1 parent fae19fa commit 696203d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public class CombinedLoadStates(

override fun equals(other: Any?): Boolean {
if (this === other) return true
if (javaClass != other?.javaClass) return false
if (other == null || this::class != other::class) return false

other as CombinedLoadStates

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ internal data class TransformablePage<T : Any>(
// for IntArray.
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (javaClass != other?.javaClass) return false
if (other == null || this::class != other::class) return false

other as TransformablePage<*>

Expand Down

0 comments on commit 696203d

Please sign in to comment.