[IR] Fix IrCapturedType equals/hashCode
It could lead to SOE if CT has itself as superType - fix KT-47424
This commit is contained in:
committed by
TeamCityServer
parent
7ccefebf1c
commit
6993b86d3b
Generated
+6
@@ -29,6 +29,12 @@ public class Fir2IrTextTestGenerated extends AbstractFir2IrTextTest {
|
||||
@TestMetadata("compiler/testData/ir/irText/classes")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class Classes {
|
||||
@Test
|
||||
@TestMetadata("47424.kt")
|
||||
public void test47424() throws Exception {
|
||||
runTest("compiler/testData/ir/irText/classes/47424.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("abstractMembers.kt")
|
||||
public void testAbstractMembers() throws Exception {
|
||||
|
||||
@@ -107,15 +107,10 @@ class IrCapturedType(
|
||||
return other is IrCapturedType
|
||||
&& captureStatus == other.captureStatus
|
||||
&& lowerType == other.lowerType
|
||||
&& constructor.argument == other.constructor.argument
|
||||
&& constructor.typeParameter == other.constructor.typeParameter
|
||||
&& constructor.superTypes == other.constructor.superTypes
|
||||
&& constructor === other.constructor
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
return (((captureStatus.hashCode() * 31
|
||||
+ (lowerType?.hashCode() ?: 0)) * 31
|
||||
+ constructor.argument.hashCode()) * 31
|
||||
+ constructor.typeParameter.hashCode()) + constructor.superTypes.hashCode()
|
||||
return (captureStatus.hashCode() * 31 + (lowerType?.hashCode() ?: 0)) * 31 + constructor.hashCode()
|
||||
}
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
// FIR_IDENTICAL
|
||||
package com.example
|
||||
|
||||
|
||||
interface Aa
|
||||
|
||||
interface Ab<T : Ab<T>> : Aa
|
||||
|
||||
|
||||
interface Ba
|
||||
|
||||
interface Bb<T : Bb<T>> : Ab<T>, Ba
|
||||
|
||||
|
||||
interface Ca {
|
||||
val b: Ba
|
||||
}
|
||||
|
||||
interface Cb {
|
||||
val b: Bb<*>
|
||||
}
|
||||
|
||||
interface C : Cb, Ca
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.example
|
||||
|
||||
interface Aa {
|
||||
|
||||
}
|
||||
|
||||
interface Ab<T : Ab<T>> : Aa {
|
||||
|
||||
}
|
||||
|
||||
interface Ba {
|
||||
|
||||
}
|
||||
|
||||
interface Bb<T : Bb<T>> : Ab<T>, Ba {
|
||||
|
||||
}
|
||||
|
||||
interface Ca {
|
||||
abstract val b: Ba
|
||||
abstract get
|
||||
|
||||
}
|
||||
|
||||
interface Cb {
|
||||
abstract val b: Bb<*>
|
||||
abstract get
|
||||
|
||||
}
|
||||
|
||||
interface C : Cb, Ca {
|
||||
|
||||
}
|
||||
+132
@@ -0,0 +1,132 @@
|
||||
FILE fqName:com.example fileName:/47424.kt
|
||||
CLASS INTERFACE name:Aa modality:ABSTRACT visibility:public superTypes:[kotlin.Any]
|
||||
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:com.example.Aa
|
||||
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
|
||||
overridden:
|
||||
public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
|
||||
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
|
||||
overridden:
|
||||
public open fun hashCode (): kotlin.Int declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
|
||||
overridden:
|
||||
public open fun toString (): kotlin.String declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
CLASS INTERFACE name:Ab modality:ABSTRACT visibility:public superTypes:[com.example.Aa]
|
||||
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:com.example.Ab<T of com.example.Ab>
|
||||
TYPE_PARAMETER name:T index:0 variance: superTypes:[com.example.Ab<T of com.example.Ab>]
|
||||
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
|
||||
overridden:
|
||||
public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in com.example.Aa
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
|
||||
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
|
||||
overridden:
|
||||
public open fun hashCode (): kotlin.Int [fake_override] declared in com.example.Aa
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
|
||||
overridden:
|
||||
public open fun toString (): kotlin.String [fake_override] declared in com.example.Aa
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
CLASS INTERFACE name:Ba modality:ABSTRACT visibility:public superTypes:[kotlin.Any]
|
||||
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:com.example.Ba
|
||||
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
|
||||
overridden:
|
||||
public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
|
||||
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
|
||||
overridden:
|
||||
public open fun hashCode (): kotlin.Int declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
|
||||
overridden:
|
||||
public open fun toString (): kotlin.String declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
CLASS INTERFACE name:Bb modality:ABSTRACT visibility:public superTypes:[com.example.Ab<T of com.example.Bb>; com.example.Ba]
|
||||
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:com.example.Bb<T of com.example.Bb>
|
||||
TYPE_PARAMETER name:T index:0 variance: superTypes:[com.example.Bb<T of com.example.Bb>]
|
||||
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
|
||||
overridden:
|
||||
public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in com.example.Ab
|
||||
public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in com.example.Ba
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
|
||||
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
|
||||
overridden:
|
||||
public open fun hashCode (): kotlin.Int [fake_override] declared in com.example.Ab
|
||||
public open fun hashCode (): kotlin.Int [fake_override] declared in com.example.Ba
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
|
||||
overridden:
|
||||
public open fun toString (): kotlin.String [fake_override] declared in com.example.Ab
|
||||
public open fun toString (): kotlin.String [fake_override] declared in com.example.Ba
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
CLASS INTERFACE name:Ca modality:ABSTRACT visibility:public superTypes:[kotlin.Any]
|
||||
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:com.example.Ca
|
||||
PROPERTY name:b visibility:public modality:ABSTRACT [val]
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-b> visibility:public modality:ABSTRACT <> ($this:com.example.Ca) returnType:com.example.Ba
|
||||
correspondingProperty: PROPERTY name:b visibility:public modality:ABSTRACT [val]
|
||||
$this: VALUE_PARAMETER name:<this> type:com.example.Ca
|
||||
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
|
||||
overridden:
|
||||
public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
|
||||
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
|
||||
overridden:
|
||||
public open fun hashCode (): kotlin.Int declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
|
||||
overridden:
|
||||
public open fun toString (): kotlin.String declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
CLASS INTERFACE name:Cb modality:ABSTRACT visibility:public superTypes:[kotlin.Any]
|
||||
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:com.example.Cb
|
||||
PROPERTY name:b visibility:public modality:ABSTRACT [val]
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-b> visibility:public modality:ABSTRACT <> ($this:com.example.Cb) returnType:com.example.Bb<*>
|
||||
correspondingProperty: PROPERTY name:b visibility:public modality:ABSTRACT [val]
|
||||
$this: VALUE_PARAMETER name:<this> type:com.example.Cb
|
||||
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
|
||||
overridden:
|
||||
public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
|
||||
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
|
||||
overridden:
|
||||
public open fun hashCode (): kotlin.Int declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
|
||||
overridden:
|
||||
public open fun toString (): kotlin.String declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
CLASS INTERFACE name:C modality:ABSTRACT visibility:public superTypes:[com.example.Cb; com.example.Ca]
|
||||
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:com.example.C
|
||||
PROPERTY FAKE_OVERRIDE name:b visibility:public modality:ABSTRACT [fake_override,val]
|
||||
overridden:
|
||||
public abstract b: com.example.Bb<*> [val]
|
||||
public abstract b: com.example.Ba [val]
|
||||
FUN FAKE_OVERRIDE name:<get-b> visibility:public modality:ABSTRACT <> ($this:com.example.Cb) returnType:com.example.Bb<*> [fake_override]
|
||||
correspondingProperty: PROPERTY FAKE_OVERRIDE name:b visibility:public modality:ABSTRACT [fake_override,val]
|
||||
overridden:
|
||||
public abstract fun <get-b> (): com.example.Bb<*> declared in com.example.Cb
|
||||
public abstract fun <get-b> (): com.example.Ba declared in com.example.Ca
|
||||
$this: VALUE_PARAMETER name:<this> type:com.example.Cb
|
||||
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
|
||||
overridden:
|
||||
public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in com.example.Cb
|
||||
public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in com.example.Ca
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
|
||||
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
|
||||
overridden:
|
||||
public open fun hashCode (): kotlin.Int [fake_override] declared in com.example.Cb
|
||||
public open fun hashCode (): kotlin.Int [fake_override] declared in com.example.Ca
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
|
||||
overridden:
|
||||
public open fun toString (): kotlin.String [fake_override] declared in com.example.Cb
|
||||
public open fun toString (): kotlin.String [fake_override] declared in com.example.Ca
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
Generated
+6
@@ -29,6 +29,12 @@ public class IrTextTestGenerated extends AbstractIrTextTest {
|
||||
@TestMetadata("compiler/testData/ir/irText/classes")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class Classes {
|
||||
@Test
|
||||
@TestMetadata("47424.kt")
|
||||
public void test47424() throws Exception {
|
||||
runTest("compiler/testData/ir/irText/classes/47424.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("abstractMembers.kt")
|
||||
public void testAbstractMembers() throws Exception {
|
||||
|
||||
@@ -38,6 +38,11 @@ public class KlibTextTestCaseGenerated extends AbstractKlibTextTestCase {
|
||||
KotlinTestUtils.runTest(this::doTest, TargetBackend.JS_IR, testDataFilePath);
|
||||
}
|
||||
|
||||
@TestMetadata("47424.kt")
|
||||
public void test47424() throws Exception {
|
||||
runTest("compiler/testData/ir/irText/classes/47424.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("abstractMembers.kt")
|
||||
public void testAbstractMembers() throws Exception {
|
||||
runTest("compiler/testData/ir/irText/classes/abstractMembers.kt");
|
||||
|
||||
Reference in New Issue
Block a user