You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you investigate the documentable model for a class with a companion object, DClass.companion and DClass.classlikes.single() are different by reference. They represent the same object, and have the the same values in every field, recursively.
However, they are also different by value, because .equals() on the data class DClass recurses into DClass.sources.values.single().descriptor.equals(), which is (in K1) a non-data-class org.jetbrains.kotlin.resolve.lazy.descriptors.LazyClassDescriptor which compares by reference instead of by value. I would guess that the K2 implementation of DocumentableSource similarly recurses into a problematic upstream object.
a) Please make sure that only one DObject is created for each companion object. Not only should this (slightly) help performance, it will help avoid running into issues like this when trying to check if a companion object is contained within a list of objects.
b) Please make Documentables compare by value correctly. Avoiding sources entirely in an overridden .equals()/.hashCode would maintain correctness IMO, but making the upstream objects inside all implementations of DocumentableSources compare by value would probably be more correct, though skipping them in .equals()/.hashCode implementations probably can be made correct.
The text was updated successfully, but these errors were encountered:
Due to Kotlin/dokka#4022, we can only use
either .classlikes or .companion in dackka, and .companion cannot
address all of our use cases.
Test: internal refactor, no effect/test diff means success
Change-Id: I7c0039b6c039f87453859b816160544905871a7d
If you investigate the documentable model for a class with a
companion object
,DClass.companion
andDClass.classlikes.single()
are different by reference. They represent the same object, and have the the same values in every field, recursively.However, they are also different by value, because
.equals()
on the data classDClass
recurses intoDClass.sources.values.single().descriptor.equals()
, which is (in K1) a non-data-classorg.jetbrains.kotlin.resolve.lazy.descriptors.LazyClassDescriptor
which compares by reference instead of by value. I would guess that the K2 implementation ofDocumentableSource
similarly recurses into a problematic upstream object.a) Please make sure that only one
DObject
is created for each companion object. Not only should this (slightly) help performance, it will help avoid running into issues like this when trying to check if a companion object is contained within a list of objects.b) Please make
Documentable
s compare by value correctly. Avoidingsources
entirely in an overridden.equals()
/.hashCode
would maintain correctness IMO, but making the upstream objects inside all implementations ofDocumentableSources
compare by value would probably be more correct, though skipping them in.equals()
/.hashCode
implementations probably can be made correct.The text was updated successfully, but these errors were encountered: