[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:
+6
-5
@@ -132,7 +132,7 @@ class DataClassMembersGenerator(val components: Fir2IrComponents) : Fir2IrCompon
|
||||
get() {
|
||||
// Pick the (necessarily unique) non-interface upper bound if it exists
|
||||
for (type in bounds) {
|
||||
val klass = type.coneType.nothingToAny().toRegularClassSymbol(session)?.fir ?: continue
|
||||
val klass = type.coneType.coerceToAny().toRegularClassSymbol(session)?.fir ?: continue
|
||||
val kind = klass.classKind
|
||||
if (kind != ClassKind.INTERFACE && kind != ClassKind.ANNOTATION_CLASS) return klass
|
||||
}
|
||||
@@ -140,7 +140,7 @@ class DataClassMembersGenerator(val components: Fir2IrComponents) : Fir2IrCompon
|
||||
// Otherwise, choose either the first IrClass supertype or recurse.
|
||||
// In the first case, all supertypes are interface types and the choice was arbitrary.
|
||||
// In the second case, there is only a single supertype.
|
||||
val firstBoundType = bounds.first().coneType.fullyExpandedType(session).nothingToAny()
|
||||
val firstBoundType = bounds.first().coneType.fullyExpandedType(session).coerceToAny()
|
||||
return when (val firstSuper = firstBoundType.toSymbol(session)?.fir) {
|
||||
is FirRegularClass -> firstSuper
|
||||
is FirTypeParameter -> firstSuper.erasedUpperBound
|
||||
@@ -161,7 +161,7 @@ class DataClassMembersGenerator(val components: Fir2IrComponents) : Fir2IrCompon
|
||||
val symbol = when {
|
||||
type.isArrayOrPrimitiveArray(checkUnsignedArrays = false) -> context.irBuiltIns.dataClassArrayMemberHashCodeSymbol
|
||||
else -> {
|
||||
val classForType = when (val classifier = type.nothingToAny().toSymbol(session)?.fir) {
|
||||
val classForType = when (val classifier = type.coerceToAny().toSymbol(session)?.fir) {
|
||||
is FirRegularClass -> classifier
|
||||
is FirTypeParameter -> classifier.erasedUpperBound
|
||||
else -> error("Unknown classifier kind $classifier")
|
||||
@@ -176,11 +176,12 @@ class DataClassMembersGenerator(val components: Fir2IrComponents) : Fir2IrCompon
|
||||
}
|
||||
|
||||
/**
|
||||
* kotlin.Nothing has no members, so any function on property of type Nothing should be actually taken from kotlin.Any
|
||||
* Convert types which do not have members - kotlin.Nothing and `dynamic` - to kotlin.Any.
|
||||
*/
|
||||
private fun ConeKotlinType.nothingToAny(): ConeKotlinType {
|
||||
private fun ConeKotlinType.coerceToAny(): ConeKotlinType {
|
||||
return when {
|
||||
this.isNothingOrNullableNothing -> session.builtinTypes.anyType.type
|
||||
this is ConeDynamicType -> session.builtinTypes.anyType.type
|
||||
else -> this
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,157 @@
|
||||
FILE fqName:<root> fileName:/dynamicInDataClass.kt
|
||||
CLASS CLASS name:Some modality:FINAL visibility:public [data] superTypes:[kotlin.Any]
|
||||
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.Some
|
||||
CONSTRUCTOR visibility:public <> (a:kotlin.String, b:dynamic) returnType:<root>.Some [primary]
|
||||
VALUE_PARAMETER name:a index:0 type:kotlin.String
|
||||
VALUE_PARAMETER name:b index:1 type:dynamic
|
||||
BLOCK_BODY
|
||||
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () declared in kotlin.Any'
|
||||
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Some modality:FINAL visibility:public [data] superTypes:[kotlin.Any]'
|
||||
PROPERTY name:a visibility:public modality:FINAL [val]
|
||||
FIELD PROPERTY_BACKING_FIELD name:a type:kotlin.String visibility:private [final]
|
||||
EXPRESSION_BODY
|
||||
GET_VAR 'a: kotlin.String declared in <root>.Some.<init>' type=kotlin.String origin=INITIALIZE_PROPERTY_FROM_PARAMETER
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-a> visibility:public modality:FINAL <> ($this:<root>.Some) returnType:kotlin.String
|
||||
correspondingProperty: PROPERTY name:a visibility:public modality:FINAL [val]
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.Some
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-a> (): kotlin.String declared in <root>.Some'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:a type:kotlin.String visibility:private [final]' type=kotlin.String origin=null
|
||||
receiver: GET_VAR '<this>: <root>.Some declared in <root>.Some.<get-a>' type=<root>.Some origin=null
|
||||
PROPERTY name:b visibility:public modality:FINAL [val]
|
||||
FIELD PROPERTY_BACKING_FIELD name:b type:dynamic visibility:private [final]
|
||||
EXPRESSION_BODY
|
||||
GET_VAR 'b: dynamic declared in <root>.Some.<init>' type=dynamic origin=INITIALIZE_PROPERTY_FROM_PARAMETER
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-b> visibility:public modality:FINAL <> ($this:<root>.Some) returnType:dynamic
|
||||
correspondingProperty: PROPERTY name:b visibility:public modality:FINAL [val]
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.Some
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-b> (): dynamic declared in <root>.Some'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:b type:dynamic visibility:private [final]' type=dynamic origin=null
|
||||
receiver: GET_VAR '<this>: <root>.Some declared in <root>.Some.<get-b>' type=<root>.Some origin=null
|
||||
FUN GENERATED_DATA_CLASS_MEMBER name:component1 visibility:public modality:FINAL <> ($this:<root>.Some) returnType:kotlin.String [operator]
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.Some
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun component1 (): kotlin.String declared in <root>.Some'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:a type:kotlin.String visibility:private [final]' type=kotlin.String origin=null
|
||||
receiver: GET_VAR '<this>: <root>.Some declared in <root>.Some.component1' type=<root>.Some origin=null
|
||||
FUN GENERATED_DATA_CLASS_MEMBER name:component2 visibility:public modality:FINAL <> ($this:<root>.Some) returnType:dynamic [operator]
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.Some
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun component2 (): dynamic declared in <root>.Some'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:b type:dynamic visibility:private [final]' type=dynamic origin=null
|
||||
receiver: GET_VAR '<this>: <root>.Some declared in <root>.Some.component2' type=<root>.Some origin=null
|
||||
FUN GENERATED_DATA_CLASS_MEMBER name:copy visibility:public modality:FINAL <> ($this:<root>.Some, a:kotlin.String, b:dynamic) returnType:<root>.Some
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.Some
|
||||
VALUE_PARAMETER name:a index:0 type:kotlin.String
|
||||
EXPRESSION_BODY
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:a type:kotlin.String visibility:private [final]' type=kotlin.String origin=null
|
||||
receiver: GET_VAR '<this>: <root>.Some declared in <root>.Some.copy' type=<root>.Some origin=null
|
||||
VALUE_PARAMETER name:b index:1 type:dynamic
|
||||
EXPRESSION_BODY
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:b type:dynamic visibility:private [final]' type=dynamic origin=null
|
||||
receiver: GET_VAR '<this>: <root>.Some declared in <root>.Some.copy' type=<root>.Some origin=null
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun copy (a: kotlin.String, b: dynamic): <root>.Some declared in <root>.Some'
|
||||
CONSTRUCTOR_CALL 'public constructor <init> (a: kotlin.String, b: dynamic) declared in <root>.Some' type=<root>.Some origin=null
|
||||
a: GET_VAR 'a: kotlin.String declared in <root>.Some.copy' type=kotlin.String origin=null
|
||||
b: GET_VAR 'b: dynamic declared in <root>.Some.copy' type=dynamic origin=null
|
||||
FUN GENERATED_DATA_CLASS_MEMBER name:toString visibility:public modality:OPEN <> ($this:<root>.Some) returnType:kotlin.String
|
||||
overridden:
|
||||
public open fun toString (): kotlin.String declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.Some
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public open fun toString (): kotlin.String declared in <root>.Some'
|
||||
STRING_CONCATENATION type=kotlin.String
|
||||
CONST String type=kotlin.String value="Some("
|
||||
CONST String type=kotlin.String value="a="
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:a type:kotlin.String visibility:private [final]' type=kotlin.String origin=null
|
||||
receiver: GET_VAR '<this>: <root>.Some declared in <root>.Some.toString' type=<root>.Some origin=null
|
||||
CONST String type=kotlin.String value=", "
|
||||
CONST String type=kotlin.String value="b="
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:b type:dynamic visibility:private [final]' type=dynamic origin=null
|
||||
receiver: GET_VAR '<this>: <root>.Some declared in <root>.Some.toString' type=<root>.Some origin=null
|
||||
CONST String type=kotlin.String value=")"
|
||||
FUN GENERATED_DATA_CLASS_MEMBER name:hashCode visibility:public modality:OPEN <> ($this:<root>.Some) returnType:kotlin.Int
|
||||
overridden:
|
||||
public open fun hashCode (): kotlin.Int declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.Some
|
||||
BLOCK_BODY
|
||||
VAR name:result type:kotlin.Int [var]
|
||||
CALL 'public open fun hashCode (): kotlin.Int declared in kotlin.String' type=kotlin.Int origin=null
|
||||
$this: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:a type:kotlin.String visibility:private [final]' type=kotlin.String origin=null
|
||||
receiver: GET_VAR '<this>: <root>.Some declared in <root>.Some.hashCode' type=<root>.Some origin=null
|
||||
SET_VAR 'var result: kotlin.Int declared in <root>.Some.hashCode' type=kotlin.Unit origin=EQ
|
||||
CALL 'public final fun plus (other: kotlin.Int): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=null
|
||||
$this: CALL 'public final fun times (other: kotlin.Int): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=null
|
||||
$this: GET_VAR 'var result: kotlin.Int declared in <root>.Some.hashCode' type=kotlin.Int origin=null
|
||||
other: CONST Int type=kotlin.Int value=31
|
||||
other: WHEN type=kotlin.Int origin=null
|
||||
BRANCH
|
||||
if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ
|
||||
arg0: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:b type:dynamic visibility:private [final]' type=dynamic origin=null
|
||||
receiver: GET_VAR '<this>: <root>.Some declared in <root>.Some.hashCode' type=<root>.Some origin=null
|
||||
arg1: CONST Null type=kotlin.Nothing? value=null
|
||||
then: CONST Int type=kotlin.Int value=0
|
||||
BRANCH
|
||||
if: CONST Boolean type=kotlin.Boolean value=true
|
||||
then: CALL 'public open fun hashCode (): kotlin.Int declared in kotlin.Any' type=kotlin.Int origin=null
|
||||
$this: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:b type:dynamic visibility:private [final]' type=dynamic origin=null
|
||||
receiver: GET_VAR '<this>: <root>.Some declared in <root>.Some.hashCode' type=<root>.Some origin=null
|
||||
RETURN type=kotlin.Nothing from='public open fun hashCode (): kotlin.Int declared in <root>.Some'
|
||||
GET_VAR 'var result: kotlin.Int declared in <root>.Some.hashCode' type=kotlin.Int origin=null
|
||||
FUN GENERATED_DATA_CLASS_MEMBER name:equals visibility:public modality:OPEN <> ($this:<root>.Some, other:kotlin.Any?) returnType:kotlin.Boolean [operator]
|
||||
overridden:
|
||||
public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.Some
|
||||
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
|
||||
BLOCK_BODY
|
||||
WHEN type=kotlin.Unit origin=null
|
||||
BRANCH
|
||||
if: CALL 'public final fun EQEQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQEQ
|
||||
arg0: GET_VAR '<this>: <root>.Some declared in <root>.Some.equals' type=<root>.Some origin=null
|
||||
arg1: GET_VAR 'other: kotlin.Any? declared in <root>.Some.equals' type=kotlin.Any? origin=null
|
||||
then: RETURN type=kotlin.Nothing from='public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in <root>.Some'
|
||||
CONST Boolean type=kotlin.Boolean value=true
|
||||
WHEN type=kotlin.Unit origin=null
|
||||
BRANCH
|
||||
if: TYPE_OP type=kotlin.Boolean origin=NOT_INSTANCEOF typeOperand=<root>.Some
|
||||
GET_VAR 'other: kotlin.Any? declared in <root>.Some.equals' type=kotlin.Any? origin=null
|
||||
then: RETURN type=kotlin.Nothing from='public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in <root>.Some'
|
||||
CONST Boolean type=kotlin.Boolean value=false
|
||||
VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:<root>.Some [val]
|
||||
TYPE_OP type=<root>.Some origin=CAST typeOperand=<root>.Some
|
||||
GET_VAR 'other: kotlin.Any? declared in <root>.Some.equals' type=kotlin.Any? origin=null
|
||||
WHEN type=kotlin.Unit origin=null
|
||||
BRANCH
|
||||
if: CALL 'public final fun not (): kotlin.Boolean declared in kotlin.Boolean' type=kotlin.Boolean origin=EXCLEQ
|
||||
$this: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EXCLEQ
|
||||
arg0: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:a type:kotlin.String visibility:private [final]' type=kotlin.String origin=null
|
||||
receiver: GET_VAR '<this>: <root>.Some declared in <root>.Some.equals' type=<root>.Some origin=null
|
||||
arg1: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:a type:kotlin.String visibility:private [final]' type=kotlin.String origin=null
|
||||
receiver: GET_VAR 'val tmp_0: <root>.Some declared in <root>.Some.equals' type=<root>.Some origin=null
|
||||
then: RETURN type=kotlin.Nothing from='public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in <root>.Some'
|
||||
CONST Boolean type=kotlin.Boolean value=false
|
||||
WHEN type=kotlin.Unit origin=null
|
||||
BRANCH
|
||||
if: CALL 'public final fun not (): kotlin.Boolean declared in kotlin.Boolean' type=kotlin.Boolean origin=EXCLEQ
|
||||
$this: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EXCLEQ
|
||||
arg0: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:b type:dynamic visibility:private [final]' type=dynamic origin=null
|
||||
receiver: GET_VAR '<this>: <root>.Some declared in <root>.Some.equals' type=<root>.Some origin=null
|
||||
arg1: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:b type:dynamic visibility:private [final]' type=dynamic origin=null
|
||||
receiver: GET_VAR 'val tmp_0: <root>.Some declared in <root>.Some.equals' type=<root>.Some origin=null
|
||||
then: RETURN type=kotlin.Nothing from='public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in <root>.Some'
|
||||
CONST Boolean type=kotlin.Boolean value=false
|
||||
RETURN type=kotlin.Nothing from='public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in <root>.Some'
|
||||
CONST Boolean type=kotlin.Boolean value=true
|
||||
FUN name:box visibility:public modality:FINAL <> () returnType:kotlin.String
|
||||
BLOCK_BODY
|
||||
VAR name:event type:<root>.Some [val]
|
||||
CONSTRUCTOR_CALL 'public constructor <init> (a: kotlin.String, b: dynamic) declared in <root>.Some' type=<root>.Some origin=null
|
||||
a: CONST String type=kotlin.String value="O"
|
||||
b: CONST String type=kotlin.String value="K"
|
||||
TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
|
||||
CALL 'public open fun hashCode (): kotlin.Int declared in <root>.Some' type=kotlin.Int origin=null
|
||||
$this: GET_VAR 'val event: <root>.Some declared in <root>.box' type=<root>.Some origin=null
|
||||
RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in <root>'
|
||||
CONST String type=kotlin.String value="OK"
|
||||
@@ -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"
|
||||
}
|
||||
@@ -0,0 +1,158 @@
|
||||
FILE fqName:<root> fileName:/dynamicInDataClass.kt
|
||||
CLASS CLASS name:Some modality:FINAL visibility:public [data] superTypes:[kotlin.Any]
|
||||
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.Some
|
||||
CONSTRUCTOR visibility:public <> (a:kotlin.String, b:dynamic) returnType:<root>.Some [primary]
|
||||
VALUE_PARAMETER name:a index:0 type:kotlin.String
|
||||
VALUE_PARAMETER name:b index:1 type:dynamic
|
||||
BLOCK_BODY
|
||||
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () declared in kotlin.Any'
|
||||
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Some modality:FINAL visibility:public [data] superTypes:[kotlin.Any]'
|
||||
PROPERTY name:a visibility:public modality:FINAL [val]
|
||||
FIELD PROPERTY_BACKING_FIELD name:a type:kotlin.String visibility:private [final]
|
||||
EXPRESSION_BODY
|
||||
GET_VAR 'a: kotlin.String declared in <root>.Some.<init>' type=kotlin.String origin=INITIALIZE_PROPERTY_FROM_PARAMETER
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-a> visibility:public modality:FINAL <> ($this:<root>.Some) returnType:kotlin.String
|
||||
correspondingProperty: PROPERTY name:a visibility:public modality:FINAL [val]
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.Some
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-a> (): kotlin.String declared in <root>.Some'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:a type:kotlin.String visibility:private [final]' type=kotlin.String origin=null
|
||||
receiver: GET_VAR '<this>: <root>.Some declared in <root>.Some.<get-a>' type=<root>.Some origin=null
|
||||
PROPERTY name:b visibility:public modality:FINAL [val]
|
||||
FIELD PROPERTY_BACKING_FIELD name:b type:dynamic visibility:private [final]
|
||||
EXPRESSION_BODY
|
||||
GET_VAR 'b: dynamic declared in <root>.Some.<init>' type=dynamic origin=INITIALIZE_PROPERTY_FROM_PARAMETER
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-b> visibility:public modality:FINAL <> ($this:<root>.Some) returnType:dynamic
|
||||
correspondingProperty: PROPERTY name:b visibility:public modality:FINAL [val]
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.Some
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-b> (): dynamic declared in <root>.Some'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:b type:dynamic visibility:private [final]' type=dynamic origin=null
|
||||
receiver: GET_VAR '<this>: <root>.Some declared in <root>.Some.<get-b>' type=<root>.Some origin=null
|
||||
FUN GENERATED_DATA_CLASS_MEMBER name:component1 visibility:public modality:FINAL <> ($this:<root>.Some) returnType:kotlin.String [operator]
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.Some
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun component1 (): kotlin.String declared in <root>.Some'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:a type:kotlin.String visibility:private [final]' type=kotlin.String origin=null
|
||||
receiver: GET_VAR '<this>: <root>.Some declared in <root>.Some.component1' type=<root>.Some origin=null
|
||||
FUN GENERATED_DATA_CLASS_MEMBER name:component2 visibility:public modality:FINAL <> ($this:<root>.Some) returnType:dynamic [operator]
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.Some
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun component2 (): dynamic declared in <root>.Some'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:b type:dynamic visibility:private [final]' type=dynamic origin=null
|
||||
receiver: GET_VAR '<this>: <root>.Some declared in <root>.Some.component2' type=<root>.Some origin=null
|
||||
FUN GENERATED_DATA_CLASS_MEMBER name:copy visibility:public modality:FINAL <> ($this:<root>.Some, a:kotlin.String, b:dynamic) returnType:<root>.Some
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.Some
|
||||
VALUE_PARAMETER name:a index:0 type:kotlin.String
|
||||
EXPRESSION_BODY
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:a type:kotlin.String visibility:private [final]' type=kotlin.String origin=null
|
||||
receiver: GET_VAR '<this>: <root>.Some declared in <root>.Some.copy' type=<root>.Some origin=null
|
||||
VALUE_PARAMETER name:b index:1 type:dynamic
|
||||
EXPRESSION_BODY
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:b type:dynamic visibility:private [final]' type=dynamic origin=null
|
||||
receiver: GET_VAR '<this>: <root>.Some declared in <root>.Some.copy' type=<root>.Some origin=null
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun copy (a: kotlin.String, b: dynamic): <root>.Some declared in <root>.Some'
|
||||
CONSTRUCTOR_CALL 'public constructor <init> (a: kotlin.String, b: dynamic) declared in <root>.Some' type=<root>.Some origin=null
|
||||
a: GET_VAR 'a: kotlin.String declared in <root>.Some.copy' type=kotlin.String origin=null
|
||||
b: GET_VAR 'b: dynamic declared in <root>.Some.copy' type=dynamic origin=null
|
||||
FUN GENERATED_DATA_CLASS_MEMBER name:toString visibility:public modality:OPEN <> ($this:<root>.Some) returnType:kotlin.String
|
||||
overridden:
|
||||
public open fun toString (): kotlin.String declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.Some
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public open fun toString (): kotlin.String declared in <root>.Some'
|
||||
STRING_CONCATENATION type=kotlin.String
|
||||
CONST String type=kotlin.String value="Some("
|
||||
CONST String type=kotlin.String value="a="
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:a type:kotlin.String visibility:private [final]' type=kotlin.String origin=null
|
||||
receiver: GET_VAR '<this>: <root>.Some declared in <root>.Some.toString' type=<root>.Some origin=null
|
||||
CONST String type=kotlin.String value=", "
|
||||
CONST String type=kotlin.String value="b="
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:b type:dynamic visibility:private [final]' type=dynamic origin=null
|
||||
receiver: GET_VAR '<this>: <root>.Some declared in <root>.Some.toString' type=<root>.Some origin=null
|
||||
CONST String type=kotlin.String value=")"
|
||||
FUN GENERATED_DATA_CLASS_MEMBER name:hashCode visibility:public modality:OPEN <> ($this:<root>.Some) returnType:kotlin.Int
|
||||
overridden:
|
||||
public open fun hashCode (): kotlin.Int declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.Some
|
||||
BLOCK_BODY
|
||||
VAR name:result type:kotlin.Int [var]
|
||||
CALL 'public open fun hashCode (): kotlin.Int declared in kotlin.String' type=kotlin.Int origin=null
|
||||
$this: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:a type:kotlin.String visibility:private [final]' type=kotlin.String origin=null
|
||||
receiver: GET_VAR '<this>: <root>.Some declared in <root>.Some.hashCode' type=<root>.Some origin=null
|
||||
SET_VAR 'var result: kotlin.Int declared in <root>.Some.hashCode' type=kotlin.Unit origin=EQ
|
||||
CALL 'public final fun plus (other: kotlin.Int): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=null
|
||||
$this: CALL 'public final fun times (other: kotlin.Int): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=null
|
||||
$this: GET_VAR 'var result: kotlin.Int declared in <root>.Some.hashCode' type=kotlin.Int origin=null
|
||||
other: CONST Int type=kotlin.Int value=31
|
||||
other: WHEN type=kotlin.Int origin=null
|
||||
BRANCH
|
||||
if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ
|
||||
arg0: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:b type:dynamic visibility:private [final]' type=dynamic origin=null
|
||||
receiver: GET_VAR '<this>: <root>.Some declared in <root>.Some.hashCode' type=<root>.Some origin=null
|
||||
arg1: CONST Null type=kotlin.Nothing? value=null
|
||||
then: CONST Int type=kotlin.Int value=0
|
||||
BRANCH
|
||||
if: CONST Boolean type=kotlin.Boolean value=true
|
||||
then: CALL 'public open fun hashCode (): kotlin.Int declared in kotlin.Any' type=kotlin.Int origin=null
|
||||
$this: TYPE_OP type=kotlin.Any origin=IMPLICIT_DYNAMIC_CAST typeOperand=kotlin.Any
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:b type:dynamic visibility:private [final]' type=dynamic origin=null
|
||||
receiver: GET_VAR '<this>: <root>.Some declared in <root>.Some.hashCode' type=<root>.Some origin=null
|
||||
RETURN type=kotlin.Nothing from='public open fun hashCode (): kotlin.Int declared in <root>.Some'
|
||||
GET_VAR 'var result: kotlin.Int declared in <root>.Some.hashCode' type=kotlin.Int origin=null
|
||||
FUN GENERATED_DATA_CLASS_MEMBER name:equals visibility:public modality:OPEN <> ($this:<root>.Some, other:kotlin.Any?) returnType:kotlin.Boolean [operator]
|
||||
overridden:
|
||||
public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.Some
|
||||
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
|
||||
BLOCK_BODY
|
||||
WHEN type=kotlin.Unit origin=null
|
||||
BRANCH
|
||||
if: CALL 'public final fun EQEQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQEQ
|
||||
arg0: GET_VAR '<this>: <root>.Some declared in <root>.Some.equals' type=<root>.Some origin=null
|
||||
arg1: GET_VAR 'other: kotlin.Any? declared in <root>.Some.equals' type=kotlin.Any? origin=null
|
||||
then: RETURN type=kotlin.Nothing from='public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in <root>.Some'
|
||||
CONST Boolean type=kotlin.Boolean value=true
|
||||
WHEN type=kotlin.Unit origin=null
|
||||
BRANCH
|
||||
if: TYPE_OP type=kotlin.Boolean origin=NOT_INSTANCEOF typeOperand=<root>.Some
|
||||
GET_VAR 'other: kotlin.Any? declared in <root>.Some.equals' type=kotlin.Any? origin=null
|
||||
then: RETURN type=kotlin.Nothing from='public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in <root>.Some'
|
||||
CONST Boolean type=kotlin.Boolean value=false
|
||||
VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:<root>.Some [val]
|
||||
TYPE_OP type=<root>.Some origin=CAST typeOperand=<root>.Some
|
||||
GET_VAR 'other: kotlin.Any? declared in <root>.Some.equals' type=kotlin.Any? origin=null
|
||||
WHEN type=kotlin.Unit origin=null
|
||||
BRANCH
|
||||
if: CALL 'public final fun not (): kotlin.Boolean declared in kotlin.Boolean' type=kotlin.Boolean origin=EXCLEQ
|
||||
$this: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EXCLEQ
|
||||
arg0: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:a type:kotlin.String visibility:private [final]' type=kotlin.String origin=null
|
||||
receiver: GET_VAR '<this>: <root>.Some declared in <root>.Some.equals' type=<root>.Some origin=null
|
||||
arg1: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:a type:kotlin.String visibility:private [final]' type=kotlin.String origin=null
|
||||
receiver: GET_VAR 'val tmp_0: <root>.Some declared in <root>.Some.equals' type=<root>.Some origin=null
|
||||
then: RETURN type=kotlin.Nothing from='public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in <root>.Some'
|
||||
CONST Boolean type=kotlin.Boolean value=false
|
||||
WHEN type=kotlin.Unit origin=null
|
||||
BRANCH
|
||||
if: CALL 'public final fun not (): kotlin.Boolean declared in kotlin.Boolean' type=kotlin.Boolean origin=EXCLEQ
|
||||
$this: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EXCLEQ
|
||||
arg0: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:b type:dynamic visibility:private [final]' type=dynamic origin=null
|
||||
receiver: GET_VAR '<this>: <root>.Some declared in <root>.Some.equals' type=<root>.Some origin=null
|
||||
arg1: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:b type:dynamic visibility:private [final]' type=dynamic origin=null
|
||||
receiver: GET_VAR 'val tmp_0: <root>.Some declared in <root>.Some.equals' type=<root>.Some origin=null
|
||||
then: RETURN type=kotlin.Nothing from='public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in <root>.Some'
|
||||
CONST Boolean type=kotlin.Boolean value=false
|
||||
RETURN type=kotlin.Nothing from='public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in <root>.Some'
|
||||
CONST Boolean type=kotlin.Boolean value=true
|
||||
FUN name:box visibility:public modality:FINAL <> () returnType:kotlin.String
|
||||
BLOCK_BODY
|
||||
VAR name:event type:<root>.Some [val]
|
||||
CONSTRUCTOR_CALL 'public constructor <init> (a: kotlin.String, b: dynamic) declared in <root>.Some' type=<root>.Some origin=null
|
||||
a: CONST String type=kotlin.String value="O"
|
||||
b: CONST String type=kotlin.String value="K"
|
||||
TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
|
||||
CALL 'public open fun hashCode (): kotlin.Int declared in <root>.Some' type=kotlin.Int origin=null
|
||||
$this: GET_VAR 'val event: <root>.Some declared in <root>.box' type=<root>.Some origin=null
|
||||
RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in <root>'
|
||||
CONST String type=kotlin.String value="OK"
|
||||
@@ -0,0 +1,9 @@
|
||||
// TARGET_BACKEND: JS_IR
|
||||
|
||||
data class Some(val a: String, val b: dynamic)
|
||||
|
||||
fun box(): String {
|
||||
val event = Some("O", "K")
|
||||
event.hashCode()
|
||||
return "OK"
|
||||
}
|
||||
@@ -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 /*~> Any */.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"
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
// CHECK:
|
||||
// Mangled name: Some
|
||||
// Public signature: /Some|null[0]
|
||||
data class Some {
|
||||
// CHECK:
|
||||
// Mangled name: Some{}a
|
||||
// Public signature: /Some.a|-1200697420457237799[0]
|
||||
// Public signature debug description: {}a
|
||||
val a: String
|
||||
// CHECK JS_IR NATIVE:
|
||||
// Mangled name: Some#<get-a>(){}
|
||||
// Public signature: /Some.a.<get-a>|6785176174175479410[0]
|
||||
// Public signature debug description: <get-a>(){}
|
||||
get
|
||||
|
||||
// CHECK:
|
||||
// Mangled name: Some{}b
|
||||
// Public signature: /Some.b|772347207915745207[0]
|
||||
// Public signature debug description: {}b
|
||||
val b: dynamic
|
||||
// CHECK JS_IR NATIVE:
|
||||
// Mangled name: Some#<get-b>(){}
|
||||
// Public signature: /Some.b.<get-b>|812004636995167743[0]
|
||||
// Public signature debug description: <get-b>(){}
|
||||
get
|
||||
|
||||
// CHECK:
|
||||
// Mangled name: Some#<init>(kotlin.String;<dynamic>){}
|
||||
// Public signature: /Some.<init>|-5225459408480290556[0]
|
||||
// Public signature debug description: <init>(kotlin.String;<dynamic>){}
|
||||
constructor(a: String, b: dynamic) /* primary */
|
||||
// CHECK JS_IR NATIVE:
|
||||
// Mangled name: Some#component1(){}
|
||||
// Public signature: /Some.component1|162597135895221648[0]
|
||||
// Public signature debug description: component1(){}
|
||||
operator fun component1(): String
|
||||
|
||||
// CHECK JS_IR NATIVE:
|
||||
// Mangled name: Some#component2(){}
|
||||
// Public signature: /Some.component2|3796717572321500973[0]
|
||||
// Public signature debug description: component2(){}
|
||||
operator fun component2(): dynamic
|
||||
|
||||
// CHECK JS_IR NATIVE:
|
||||
// Mangled name: Some#copy(kotlin.String;<dynamic>){}
|
||||
// Public signature: /Some.copy|-666200579701757332[0]
|
||||
// Public signature debug description: copy(kotlin.String;<dynamic>){}
|
||||
fun copy(a: String, b: dynamic): Some
|
||||
|
||||
// CHECK JS_IR NATIVE:
|
||||
// Mangled name: Some#equals(kotlin.Any?){}
|
||||
// Public signature: /Some.equals|4638265728071529943[0]
|
||||
// Public signature debug description: equals(kotlin.Any?){}
|
||||
override operator fun equals(other: Any?): Boolean
|
||||
|
||||
// CHECK JS_IR NATIVE:
|
||||
// Mangled name: Some#hashCode(){}
|
||||
// Public signature: /Some.hashCode|3409210261493131192[0]
|
||||
// Public signature debug description: hashCode(){}
|
||||
override fun hashCode(): Int
|
||||
|
||||
// CHECK JS_IR NATIVE:
|
||||
// Mangled name: Some#toString(){}
|
||||
// Public signature: /Some.toString|-1522858123163872138[0]
|
||||
// Public signature debug description: toString(){}
|
||||
override fun toString(): String
|
||||
|
||||
}
|
||||
|
||||
// CHECK JS_IR NATIVE:
|
||||
// Mangled name: #box(){}
|
||||
// Public signature: /box|2173511048851971368[0]
|
||||
// Public signature debug description: box(){}
|
||||
fun box(): String
|
||||
+5
@@ -2283,6 +2283,11 @@ public class KlibIrTextTestCaseGenerated extends AbstractKlibIrTextTestCase {
|
||||
runTest("compiler/testData/ir/irText/js/dynamic/dynamicExclExclOperator.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("dynamicInDataClass.kt")
|
||||
public void testDynamicInDataClass() throws Exception {
|
||||
runTest("compiler/testData/ir/irText/js/dynamic/dynamicInDataClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("dynamicInfixCall.kt")
|
||||
public void testDynamicInfixCall() throws Exception {
|
||||
runTest("compiler/testData/ir/irText/js/dynamic/dynamicInfixCall.kt");
|
||||
|
||||
+5
@@ -102,6 +102,11 @@ public class KlibJsIrTextTestCaseGenerated extends AbstractKlibJsIrTextTestCase
|
||||
runTest("compiler/testData/ir/irText/js/dynamic/dynamicExclExclOperator.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("dynamicInDataClass.kt")
|
||||
public void testDynamicInDataClass() throws Exception {
|
||||
runTest("compiler/testData/ir/irText/js/dynamic/dynamicInDataClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("dynamicInfixCall.kt")
|
||||
public void testDynamicInfixCall() throws Exception {
|
||||
runTest("compiler/testData/ir/irText/js/dynamic/dynamicInfixCall.kt");
|
||||
|
||||
Generated
+6
@@ -2617,6 +2617,12 @@ public class FirLightTreeJsIrTextTestGenerated extends AbstractFirLightTreeJsIrT
|
||||
runTest("compiler/testData/ir/irText/js/dynamic/dynamicExclExclOperator.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("dynamicInDataClass.kt")
|
||||
public void testDynamicInDataClass() throws Exception {
|
||||
runTest("compiler/testData/ir/irText/js/dynamic/dynamicInDataClass.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("dynamicInfixCall.kt")
|
||||
public void testDynamicInfixCall() throws Exception {
|
||||
|
||||
+6
@@ -2617,6 +2617,12 @@ public class FirPsiJsIrTextTestGenerated extends AbstractFirPsiJsIrTextTest {
|
||||
runTest("compiler/testData/ir/irText/js/dynamic/dynamicExclExclOperator.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("dynamicInDataClass.kt")
|
||||
public void testDynamicInDataClass() throws Exception {
|
||||
runTest("compiler/testData/ir/irText/js/dynamic/dynamicInDataClass.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("dynamicInfixCall.kt")
|
||||
public void testDynamicInfixCall() throws Exception {
|
||||
|
||||
+6
@@ -2617,6 +2617,12 @@ public class ClassicJsIrTextTestGenerated extends AbstractClassicJsIrTextTest {
|
||||
runTest("compiler/testData/ir/irText/js/dynamic/dynamicExclExclOperator.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("dynamicInDataClass.kt")
|
||||
public void testDynamicInDataClass() throws Exception {
|
||||
runTest("compiler/testData/ir/irText/js/dynamic/dynamicInDataClass.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("dynamicInfixCall.kt")
|
||||
public void testDynamicInfixCall() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user