Mangle function names with inline class parameters

Avoid name clashes in cases such as

  inline class Login(val login: String)
  inline class Password(val password: String)

  fun validate(login: Login) { ... }
  fun validate(password: Password) { ... }
This commit is contained in:
Dmitry Petrov
2018-08-15 10:25:49 +03:00
committed by Ilya Gorbunov
parent ff9ba97d66
commit a56d1d3ce8
45 changed files with 1273 additions and 30 deletions
@@ -11757,6 +11757,104 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
public void testUseThisInsideInlineClass() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/useThisInsideInlineClass.kt");
}
@TestMetadata("compiler/testData/codegen/box/inlineClasses/functionNameMangling")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class FunctionNameMangling extends AbstractBlackBoxCodegenTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath);
}
public void testAllFilesPresentInFunctionNameMangling() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/inlineClasses/functionNameMangling"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM, true);
}
@TestMetadata("anonymousObjectInFunctionWithMangledName.kt")
public void testAnonymousObjectInFunctionWithMangledName() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/functionNameMangling/anonymousObjectInFunctionWithMangledName.kt");
}
@TestMetadata("extensionFunctionsDoNotClash.kt")
public void testExtensionFunctionsDoNotClash() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/functionNameMangling/extensionFunctionsDoNotClash.kt");
}
@TestMetadata("functionsWithDifferentNullabilityDoNotClash.kt")
public void testFunctionsWithDifferentNullabilityDoNotClash() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/functionNameMangling/functionsWithDifferentNullabilityDoNotClash.kt");
}
@TestMetadata("genericFunctionsDoNotClash.kt")
public void testGenericFunctionsDoNotClash() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/functionNameMangling/genericFunctionsDoNotClash.kt");
}
@TestMetadata("localClassInFunctionWithMangledName.kt")
public void testLocalClassInFunctionWithMangledName() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/functionNameMangling/localClassInFunctionWithMangledName.kt");
}
@TestMetadata("mangledFunctionsCanBeOverridden.kt")
public void testMangledFunctionsCanBeOverridden() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/functionNameMangling/mangledFunctionsCanBeOverridden.kt");
}
@TestMetadata("mangledFunctionsDoNotClash.kt")
public void testMangledFunctionsDoNotClash() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/functionNameMangling/mangledFunctionsDoNotClash.kt");
}
@TestMetadata("mangledFunctionsPresentInStackTrace.kt")
public void testMangledFunctionsPresentInStackTrace() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/functionNameMangling/mangledFunctionsPresentInStackTrace.kt");
}
@TestMetadata("mixedSignatureFunctionsDoNotClash.kt")
public void testMixedSignatureFunctionsDoNotClash() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/functionNameMangling/mixedSignatureFunctionsDoNotClash.kt");
}
@TestMetadata("overridingMethodInGenericClass.kt")
public void testOverridingMethodInGenericClass() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/functionNameMangling/overridingMethodInGenericClass.kt");
}
@TestMetadata("overridingMethodInGenericClass2.kt")
public void testOverridingMethodInGenericClass2() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/functionNameMangling/overridingMethodInGenericClass2.kt");
}
@TestMetadata("propertySetterWithInlineClassTypeArgument.kt")
public void testPropertySetterWithInlineClassTypeArgument() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/functionNameMangling/propertySetterWithInlineClassTypeArgument.kt");
}
@TestMetadata("reflectionForFunctionWithMangledName.kt")
public void testReflectionForFunctionWithMangledName() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/functionNameMangling/reflectionForFunctionWithMangledName.kt");
}
@TestMetadata("reflectionForLocalClassInFunctionWithMangledName.kt")
public void testReflectionForLocalClassInFunctionWithMangledName() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/functionNameMangling/reflectionForLocalClassInFunctionWithMangledName.kt");
}
@TestMetadata("reflectionForPropertyOfInlineClassType.kt")
public void testReflectionForPropertyOfInlineClassType() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/functionNameMangling/reflectionForPropertyOfInlineClassType.kt");
}
@TestMetadata("syntheticAccessorForFunctionWithMangledName.kt")
public void testSyntheticAccessorForFunctionWithMangledName() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/functionNameMangling/syntheticAccessorForFunctionWithMangledName.kt");
}
@TestMetadata("syntheticAccessorsForPropertyOfInlineClassType.kt")
public void testSyntheticAccessorsForPropertyOfInlineClassType() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/functionNameMangling/syntheticAccessorsForPropertyOfInlineClassType.kt");
}
}
}
@TestMetadata("compiler/testData/codegen/box/innerNested")