Fix isKotlinFunctionWithBigArity function
fixup! Fix `isKotlinFunctionWithBigArity` function Fix `isKotlinFunctionWithBigArity` function Previous implementation could return false positive results, e.g. for class named `abacaba.kotlin.Function42` ^KT-61548: Fixed Merge-request: KT-MR-11928 Merged-by: Vladislav Grechko <Vladislav.Grechko@jetbrains.com>
This commit is contained in:
committed by
Space Team
parent
84d863aaf4
commit
e9ccc0329c
+6
@@ -3326,6 +3326,12 @@ public class FirLightTreeBlackBoxCodegenTestGenerated extends AbstractFirLightTr
|
||||
runTest("compiler/testData/codegen/box/builtinStubMethods/extendJavaClasses/hashSet.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt61548.kt")
|
||||
public void testKt61548() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/builtinStubMethods/extendJavaClasses/kt61548.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("mapEntry.kt")
|
||||
public void testMapEntry() throws Exception {
|
||||
|
||||
+6
@@ -3326,6 +3326,12 @@ public class FirPsiBlackBoxCodegenTestGenerated extends AbstractFirPsiBlackBoxCo
|
||||
runTest("compiler/testData/codegen/box/builtinStubMethods/extendJavaClasses/hashSet.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt61548.kt")
|
||||
public void testKt61548() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/builtinStubMethods/extendJavaClasses/kt61548.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("mapEntry.kt")
|
||||
public void testMapEntry() throws Exception {
|
||||
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// IGNORE_LIGHT_ANALYSIS
|
||||
|
||||
// FILE: Function42.java
|
||||
|
||||
package abacaba.kotlin;
|
||||
|
||||
public abstract class Function42 implements CharSequence {
|
||||
@Override
|
||||
public char charAt(int index) {
|
||||
return 'a';
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: box.kt
|
||||
|
||||
package abacaba.kotlin
|
||||
|
||||
abstract class KACharSequence : Function42() {
|
||||
companion object {
|
||||
const val x = "OK"
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
return KACharSequence.x
|
||||
}
|
||||
+6
@@ -3152,6 +3152,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
runTest("compiler/testData/codegen/box/builtinStubMethods/extendJavaClasses/hashSet.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt61548.kt")
|
||||
public void testKt61548() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/builtinStubMethods/extendJavaClasses/kt61548.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("mapEntry.kt")
|
||||
public void testMapEntry() throws Exception {
|
||||
|
||||
+6
@@ -3326,6 +3326,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
||||
runTest("compiler/testData/codegen/box/builtinStubMethods/extendJavaClasses/hashSet.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt61548.kt")
|
||||
public void testKt61548() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/builtinStubMethods/extendJavaClasses/kt61548.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("mapEntry.kt")
|
||||
public void testMapEntry() throws Exception {
|
||||
|
||||
+6
@@ -3326,6 +3326,12 @@ public class IrBlackBoxCodegenWithIrInlinerTestGenerated extends AbstractIrBlack
|
||||
runTest("compiler/testData/codegen/box/builtinStubMethods/extendJavaClasses/hashSet.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt61548.kt")
|
||||
public void testKt61548() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/builtinStubMethods/extendJavaClasses/kt61548.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("mapEntry.kt")
|
||||
public void testMapEntry() throws Exception {
|
||||
|
||||
+5
@@ -2916,6 +2916,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
runTest("compiler/testData/codegen/box/builtinStubMethods/extendJavaClasses/hashSet.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt61548.kt")
|
||||
public void testKt61548() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/builtinStubMethods/extendJavaClasses/kt61548.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("mapEntry.kt")
|
||||
public void testMapEntry() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/builtinStubMethods/extendJavaClasses/mapEntry.kt");
|
||||
|
||||
+5
-6
@@ -150,12 +150,11 @@ object JavaToKotlinClassMap {
|
||||
}
|
||||
|
||||
private fun isKotlinFunctionWithBigArity(kotlinFqName: FqNameUnsafe, prefix: String): Boolean {
|
||||
val arityString = kotlinFqName.asString().substringAfter(prefix, "")
|
||||
if (arityString.isNotEmpty() && !arityString.startsWith('0')) {
|
||||
val arity = arityString.toIntOrNull()
|
||||
return arity != null && arity >= BuiltInFunctionArity.BIG_ARITY
|
||||
}
|
||||
return false
|
||||
val fqNameAsString = kotlinFqName.asString()
|
||||
if (!fqNameAsString.startsWith(prefix)) return false
|
||||
val arityString = fqNameAsString.substring(prefix.length)
|
||||
val arity = if (!arityString.startsWith('0')) arityString.toIntOrNull() else return false
|
||||
return arity != null && arity >= BuiltInFunctionArity.BIG_ARITY
|
||||
}
|
||||
|
||||
private fun addMapping(platformMutabilityMapping: PlatformMutabilityMapping) {
|
||||
|
||||
Reference in New Issue
Block a user