[FIR2IR] Convert data class properties of type dynamic for hashCode
Properties of type dynamic within a data class cause compilation to fail when converting FIR to IR. This is because dynamic types do not have a proper backing class for symbol lookup. However, dynamic types can just be considered of type Any for hashCode calculations. ^KT-63094 Fixed
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
data class Some {
|
||||
constructor(a: String, b: dynamic) /* primary */ {
|
||||
super/*Any*/()
|
||||
/* <init>() */
|
||||
|
||||
}
|
||||
|
||||
val a: String
|
||||
field = a
|
||||
get
|
||||
|
||||
val b: dynamic
|
||||
field = b
|
||||
get
|
||||
|
||||
operator fun component1(): String {
|
||||
return <this>.#a
|
||||
}
|
||||
|
||||
operator fun component2(): dynamic {
|
||||
return <this>.#b
|
||||
}
|
||||
|
||||
fun copy(a: String = <this>.#a, b: dynamic = <this>.#b): Some {
|
||||
return Some(a = a, b = b)
|
||||
}
|
||||
|
||||
override fun toString(): String {
|
||||
return "Some(" + "a=" + <this>.#a + ", " + "b=" + <this>.#b + ")"
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
var result: Int = <this>.#a.hashCode()
|
||||
result = result.times(other = 31).plus(other = when {
|
||||
EQEQ(arg0 = <this>.#b, arg1 = null) -> 0
|
||||
else -> <this>.#b.hashCode()
|
||||
})
|
||||
return result
|
||||
}
|
||||
|
||||
override operator fun equals(other: Any?): Boolean {
|
||||
when {
|
||||
EQEQEQ(arg0 = <this>, arg1 = other) -> return true
|
||||
}
|
||||
when {
|
||||
other !is Some -> return false
|
||||
}
|
||||
val tmp_0: Some = other as Some
|
||||
when {
|
||||
EQEQ(arg0 = <this>.#a, arg1 = tmp_0.#a).not() -> return false
|
||||
}
|
||||
when {
|
||||
EQEQ(arg0 = <this>.#b, arg1 = tmp_0.#b).not() -> return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val event: Some = Some(a = "O", b = "K")
|
||||
event.hashCode() /*~> Unit */
|
||||
return "OK"
|
||||
}
|
||||
Reference in New Issue
Block a user