Considering SAM interface FQ name in hash.

This commit is contained in:
Evgeny Gerashchenko
2013-06-13 19:55:12 +04:00
parent 7ef4c8cfa8
commit be02943675
4 changed files with 29 additions and 3 deletions
@@ -139,7 +139,7 @@ public class SamWrapperCodegen extends GenerationStateAware {
FqName fqName = DescriptorUtils.getFQName(namespace).toSafe();
String packageInternalName = JvmClassName.byFqNameWithoutInnerClasses(
PackageClassUtils.getPackageClassFqName(fqName)).getInternalName();
return packageInternalName + "$sam$" + samInterface.getName().asString() +
"$" + Integer.toHexString(CodegenUtil.getPathHashCode(containingFile)); // TODO add class FQ name hash
return packageInternalName + "$sam$" + samInterface.getName().asString() + "$" +
Integer.toHexString(CodegenUtil.getPathHashCode(containingFile) * 31 + DescriptorUtils.getFQName(samInterface).hashCode());
}
}
@@ -0,0 +1,5 @@
class Custom {
public interface Runnable {
void run2();
}
}
@@ -0,0 +1,7 @@
fun box(): String {
val f = { }
val class1 = Runnable(f).getClass()
val class2 = Custom.Runnable(f).getClass()
return if (class1 != class2) "OK" else "Same class: $class1"
}
@@ -31,7 +31,7 @@ import org.jetbrains.jet.codegen.generated.AbstractBlackBoxCodegenTest;
/** This class is generated by {@link org.jetbrains.jet.generators.tests.GenerateTests}. DO NOT MODIFY MANUALLY */
@SuppressWarnings("all")
@TestMetadata("compiler/testData/codegen/boxWithJava")
@InnerTestClasses({BlackBoxWithJavaCodegenTestGenerated.CallableReference.class, BlackBoxWithJavaCodegenTestGenerated.Enum.class, BlackBoxWithJavaCodegenTestGenerated.Functions.class, BlackBoxWithJavaCodegenTestGenerated.Property.class, BlackBoxWithJavaCodegenTestGenerated.SamAdapters.class, BlackBoxWithJavaCodegenTestGenerated.StaticFun.class, BlackBoxWithJavaCodegenTestGenerated.Visibility.class})
@InnerTestClasses({BlackBoxWithJavaCodegenTestGenerated.CallableReference.class, BlackBoxWithJavaCodegenTestGenerated.Enum.class, BlackBoxWithJavaCodegenTestGenerated.Functions.class, BlackBoxWithJavaCodegenTestGenerated.Property.class, BlackBoxWithJavaCodegenTestGenerated.SamAdapters.class, BlackBoxWithJavaCodegenTestGenerated.SamWrappers.class, BlackBoxWithJavaCodegenTestGenerated.StaticFun.class, BlackBoxWithJavaCodegenTestGenerated.Visibility.class})
public class BlackBoxWithJavaCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
public void testAllFilesPresentInBoxWithJava() throws Exception {
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("compiler/testData/codegen/boxWithJava"), Pattern.compile("^(.+)\\.kt$"), true);
@@ -182,6 +182,19 @@ public class BlackBoxWithJavaCodegenTestGenerated extends AbstractBlackBoxCodege
}
@TestMetadata("compiler/testData/codegen/boxWithJava/samWrappers")
public static class SamWrappers extends AbstractBlackBoxCodegenTest {
public void testAllFilesPresentInSamWrappers() throws Exception {
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("compiler/testData/codegen/boxWithJava/samWrappers"), Pattern.compile("^(.+)\\.kt$"), true);
}
@TestMetadata("differentFqNames.kt")
public void testDifferentFqNames() throws Exception {
doTestWithJava("compiler/testData/codegen/boxWithJava/samWrappers/differentFqNames.kt");
}
}
@TestMetadata("compiler/testData/codegen/boxWithJava/staticFun")
public static class StaticFun extends AbstractBlackBoxCodegenTest {
public void testAllFilesPresentInStaticFun() throws Exception {
@@ -344,6 +357,7 @@ public class BlackBoxWithJavaCodegenTestGenerated extends AbstractBlackBoxCodege
suite.addTestSuite(Functions.class);
suite.addTestSuite(Property.class);
suite.addTestSuite(SamAdapters.class);
suite.addTestSuite(SamWrappers.class);
suite.addTestSuite(StaticFun.class);
suite.addTest(Visibility.innerSuite());
return suite;