Reflection: improve and optimize kotlinFunction/kotlinProperty

- Make the implementations very similar, to fix KT-54833 where the
  companion object case was forgotten for kotlinProperty.
- Optimize both functions to look up the function/property by name
  first, to cover the most probable case when the JVM name of a
  declaration is equal to its Kotlin name. This fixes KT-55937.

 #KT-54833 Fixed
 #KT-55937 Fixed
This commit is contained in:
Alexander Udalov
2023-01-16 22:41:47 +01:00
parent aa7b4cfbe6
commit c58314fddf
9 changed files with 225 additions and 14 deletions
@@ -33661,6 +33661,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/reflection/mapping"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true);
}
@TestMetadata("companionObjectProperty.kt")
public void testCompanionObjectProperty() throws Exception {
runTest("compiler/testData/codegen/box/reflection/mapping/companionObjectProperty.kt");
}
@TestMetadata("constructor.kt")
public void testConstructor() throws Exception {
runTest("compiler/testData/codegen/box/reflection/mapping/constructor.kt");
@@ -33736,6 +33741,16 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
runTest("compiler/testData/codegen/box/reflection/mapping/methodsFromSuperInterface.kt");
}
@TestMetadata("nonTrivialFunctionNames.kt")
public void testNonTrivialFunctionNames() throws Exception {
runTest("compiler/testData/codegen/box/reflection/mapping/nonTrivialFunctionNames.kt");
}
@TestMetadata("nonTrivialPropertyNames.kt")
public void testNonTrivialPropertyNames() throws Exception {
runTest("compiler/testData/codegen/box/reflection/mapping/nonTrivialPropertyNames.kt");
}
@TestMetadata("openSuspendFun.kt")
public void testOpenSuspendFun() throws Exception {
runTest("compiler/testData/codegen/box/reflection/mapping/openSuspendFun.kt");