Do not rely on descriptors in KTypeParameterImpl.equals/hashCode
Descriptors are cached via weak references in moduleByClassLoader.kt and can be garbage-collected at any point. So relying on identity of descriptors in KTypeParameterImpl is dangerous because the same type parameter can be represented by different descriptors. For example, the test equalsOnFunctionParameters.kt was flaky before this change because of this issue, and that could be reproduced by running it a few hundred times in the same process. Instead, use the type parameter's container (which is either KClass or KCallable) and name, in equals/hashCode. KClass and KCallable already have equals/hashCode independent of descriptors, so this works in case the descriptor is invalidated.
This commit is contained in:
+15
@@ -25412,6 +25412,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
runTest("compiler/testData/codegen/box/reflection/methodsFromAny/typeParametersEqualsHashCode.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("typeParametersEqualsWithClearCaches.kt")
|
||||
public void testTypeParametersEqualsWithClearCaches() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/reflection/methodsFromAny/typeParametersEqualsWithClearCaches.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("typeParametersToString.kt")
|
||||
public void testTypeParametersToString() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/reflection/methodsFromAny/typeParametersToString.kt");
|
||||
@@ -26298,6 +26303,16 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
runTest("compiler/testData/codegen/box/reflection/typeParameters/declarationSiteVariance.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("innerGenericParameter.kt")
|
||||
public void testInnerGenericParameter() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/reflection/typeParameters/innerGenericParameter.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("javaGenericTypeConstructor.kt")
|
||||
public void testJavaGenericTypeConstructor() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/reflection/typeParameters/javaGenericTypeConstructor.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("typeParametersAndNames.kt")
|
||||
public void testTypeParametersAndNames() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/reflection/typeParameters/typeParametersAndNames.kt");
|
||||
|
||||
Reference in New Issue
Block a user