[Invariant Fix] Fix equality for NewCapturedTypeConstructor after refinement
This commit is contained in:
committed by
Dmitry Savvinov
parent
471134d31e
commit
c49791f8bb
@@ -152,7 +152,11 @@ class NewCapturedType(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
class NewCapturedTypeConstructor(override val projection: TypeProjection, private var supertypes: List<UnwrappedType>? = null) :
|
class NewCapturedTypeConstructor(
|
||||||
|
override val projection: TypeProjection,
|
||||||
|
private var supertypes: List<UnwrappedType>? = null,
|
||||||
|
private val original: NewCapturedTypeConstructor? = null
|
||||||
|
) :
|
||||||
CapturedTypeConstructor {
|
CapturedTypeConstructor {
|
||||||
fun initializeSupertypes(supertypes: List<UnwrappedType>) {
|
fun initializeSupertypes(supertypes: List<UnwrappedType>) {
|
||||||
assert(this.supertypes == null) {
|
assert(this.supertypes == null) {
|
||||||
@@ -171,7 +175,21 @@ class NewCapturedTypeConstructor(override val projection: TypeProjection, privat
|
|||||||
|
|
||||||
@TypeRefinement
|
@TypeRefinement
|
||||||
override fun refine(kotlinTypeRefiner: KotlinTypeRefiner) =
|
override fun refine(kotlinTypeRefiner: KotlinTypeRefiner) =
|
||||||
NewCapturedTypeConstructor(projection.refine(kotlinTypeRefiner), supertypes?.map { it.refine(kotlinTypeRefiner) })
|
NewCapturedTypeConstructor(
|
||||||
|
projection.refine(kotlinTypeRefiner),
|
||||||
|
supertypes?.map { it.refine(kotlinTypeRefiner) },
|
||||||
|
original ?: this
|
||||||
|
)
|
||||||
|
|
||||||
|
override fun equals(other: Any?): Boolean {
|
||||||
|
if (this === other) return true
|
||||||
|
if (javaClass != other?.javaClass) return false
|
||||||
|
|
||||||
|
other as NewCapturedTypeConstructor
|
||||||
|
|
||||||
|
return (original ?: this) === (other.original ?: other)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun hashCode(): Int = original?.hashCode() ?: super.hashCode()
|
||||||
override fun toString() = "CapturedType($projection)"
|
override fun toString() = "CapturedType($projection)"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user