Fix unjustified descriptorToDeclaration in bridge codegen

Delegated and synthesized members don't usually have a declaration as well as
fake overrides
This commit is contained in:
Alexander Udalov
2014-04-18 17:18:51 +04:00
parent 45073c5a1c
commit cdceaec79f
4 changed files with 30 additions and 4 deletions
@@ -66,6 +66,7 @@ import static org.jetbrains.jet.codegen.AsmUtil.*;
import static org.jetbrains.jet.codegen.JvmSerializationBindings.*;
import static org.jetbrains.jet.codegen.binding.CodegenBinding.asmTypeForAnonymousClass;
import static org.jetbrains.jet.codegen.binding.CodegenBinding.isLocalNamedFun;
import static org.jetbrains.jet.lang.descriptors.CallableMemberDescriptor.Kind.DECLARATION;
import static org.jetbrains.jet.lang.resolve.BindingContextUtils.callableDescriptorToDeclaration;
import static org.jetbrains.jet.lang.resolve.BindingContextUtils.descriptorToDeclaration;
import static org.jetbrains.jet.lang.resolve.DescriptorUtils.isFunctionLiteral;
@@ -440,9 +441,7 @@ public class FunctionCodegen extends ParentCodegenAwareImpl {
);
if (!bridgesToGenerate.isEmpty()) {
PsiElement origin = descriptor.getKind().isReal()
? callableDescriptorToDeclaration(bindingContext, descriptor)
: null;
PsiElement origin = descriptor.getKind() == DECLARATION ? callableDescriptorToDeclaration(bindingContext, descriptor) : null;
for (Bridge<Method> bridge : bridgesToGenerate) {
generateBridge(origin, bridge.getFrom(), bridge.getTo());
}
@@ -0,0 +1,7 @@
import java.util.Set;
public class delegationAndInheritanceFromJava {
public interface A extends Set<String> {}
public interface B extends Set<String> {}
}
@@ -0,0 +1,6 @@
import delegationAndInheritanceFromJava.*
import java.util.HashSet
class Impl(b: B): A, B by b
fun box() = "OK"
@@ -31,7 +31,7 @@ import org.jetbrains.jet.codegen.generated.AbstractBlackBoxCodegenTest;
/** This class is generated by {@link org.jetbrains.jet.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */
@SuppressWarnings("all")
@TestMetadata("compiler/testData/codegen/boxWithJava")
@InnerTestClasses({BlackBoxWithJavaCodegenTestGenerated.Annotations.class, BlackBoxWithJavaCodegenTestGenerated.CallableReference.class, BlackBoxWithJavaCodegenTestGenerated.Constructor.class, BlackBoxWithJavaCodegenTestGenerated.Enum.class, BlackBoxWithJavaCodegenTestGenerated.Functions.class, BlackBoxWithJavaCodegenTestGenerated.InnerClass.class, BlackBoxWithJavaCodegenTestGenerated.Property.class, BlackBoxWithJavaCodegenTestGenerated.Sam.class, BlackBoxWithJavaCodegenTestGenerated.StaticFun.class, BlackBoxWithJavaCodegenTestGenerated.Visibility.class})
@InnerTestClasses({BlackBoxWithJavaCodegenTestGenerated.Annotations.class, BlackBoxWithJavaCodegenTestGenerated.CallableReference.class, BlackBoxWithJavaCodegenTestGenerated.Constructor.class, BlackBoxWithJavaCodegenTestGenerated.Delegation.class, BlackBoxWithJavaCodegenTestGenerated.Enum.class, BlackBoxWithJavaCodegenTestGenerated.Functions.class, BlackBoxWithJavaCodegenTestGenerated.InnerClass.class, BlackBoxWithJavaCodegenTestGenerated.Property.class, BlackBoxWithJavaCodegenTestGenerated.Sam.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.TestsPackage", new File("compiler/testData/codegen/boxWithJava"), Pattern.compile("^(.+)\\.kt$"), true);
@@ -101,6 +101,19 @@ public class BlackBoxWithJavaCodegenTestGenerated extends AbstractBlackBoxCodege
}
@TestMetadata("compiler/testData/codegen/boxWithJava/delegation")
public static class Delegation extends AbstractBlackBoxCodegenTest {
public void testAllFilesPresentInDelegation() throws Exception {
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("compiler/testData/codegen/boxWithJava/delegation"), Pattern.compile("^(.+)\\.kt$"), true);
}
@TestMetadata("delegationAndInheritanceFromJava.kt")
public void testDelegationAndInheritanceFromJava() throws Exception {
doTestWithJava("compiler/testData/codegen/boxWithJava/delegation/delegationAndInheritanceFromJava.kt");
}
}
@TestMetadata("compiler/testData/codegen/boxWithJava/enum")
public static class Enum extends AbstractBlackBoxCodegenTest {
public void testAllFilesPresentInEnum() throws Exception {
@@ -566,6 +579,7 @@ public class BlackBoxWithJavaCodegenTestGenerated extends AbstractBlackBoxCodege
suite.addTestSuite(Annotations.class);
suite.addTestSuite(CallableReference.class);
suite.addTestSuite(Constructor.class);
suite.addTestSuite(Delegation.class);
suite.addTestSuite(Enum.class);
suite.addTestSuite(Functions.class);
suite.addTestSuite(InnerClass.class);