-
Notifications
You must be signed in to change notification settings - Fork 61
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
Add custom implementations for toString, equals and hashCode #1480
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. I left some minor comments here and there.
@@ -58,48 +50,6 @@ class RealmModelSyntheticCompanionExtension : SyntheticResolveExtension { | |||
} | |||
} | |||
|
|||
override fun addSyntheticSupertypes( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure that these are safe to delete. I think it was added because the default
implementation is no longer part of the interface (aka related to the changed jvm-default
mode) in https://github.com/realm/realm-kotlin/pull/1163/files. But maybe ok now that we compile against 1.8+ which we also run against 🤔 ... I guess it should be safe.
packages/library-base/src/commonMain/kotlin/io/realm/kotlin/internal/RealmObjectHelper.kt
Outdated
Show resolved
Hide resolved
@Suppress("unused", "MagicNumber") // Called from generated code | ||
// Inlining this functions somehow break the IntelliJ debugger, unclear why? | ||
internal fun realmHashCode(obj: BaseRealmObject): Int { | ||
// This code assumes no race conditions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we put some notes about the side effects of this: Not thread safe on live objects or something like that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We probably should, but not sure where it would make sense?
Closes #1097
This PR adds custom
toString
,equals
, andhashCode
implementations to Realm Object subclasses. If these methods already exist, nothing will be generated.TODO