diff --git a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/resolver/JavaFunctionResolver.java b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/resolver/JavaFunctionResolver.java index 906fbc5455b..6742b59ee4c 100644 --- a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/resolver/JavaFunctionResolver.java +++ b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/resolver/JavaFunctionResolver.java @@ -188,6 +188,11 @@ public final class JavaFunctionResolver { ) { final Set functions = new HashSet(); + Set functionsFromSupertypes = null; + if (owner instanceof ClassDescriptor) { + functionsFromSupertypes = getFunctionsFromSupertypes(methodName, owner); + } + Set functionsFromCurrent = Sets.newHashSet(); for (PsiMethodWrapper method : namedMembers.getMethods()) { SimpleFunctionDescriptor function = resolveMethodToFunctionDescriptor(psiClass, method, scopeData, owner); @@ -199,8 +204,6 @@ public final class JavaFunctionResolver { if (owner instanceof ClassDescriptor) { ClassDescriptor classDescriptor = (ClassDescriptor) owner; - Set functionsFromSupertypes = getFunctionsFromSupertypes(methodName, owner); - OverrideResolver.generateOverridesInFunctionGroup(methodName, functionsFromSupertypes, functionsFromCurrent, classDescriptor, new OverrideResolver.DescriptorSink() { @Override diff --git a/compiler/testData/loadJavaCustom/kotlinSignature/TwoSuperclassesInconsistentGenericTypes.java b/compiler/testData/loadJavaCustom/kotlinSignature/TwoSuperclassesInconsistentGenericTypes.java new file mode 100644 index 00000000000..fb546563f87 --- /dev/null +++ b/compiler/testData/loadJavaCustom/kotlinSignature/TwoSuperclassesInconsistentGenericTypes.java @@ -0,0 +1,22 @@ +package test; + +import org.jetbrains.annotations.NotNull; +import java.util.List; + +import jet.runtime.typeinfo.KotlinSignature; + +public interface TwoSuperclassesInconsistentGenericTypes { + @KotlinSignature("fun foo(): MutableList") + List foo(); + + public interface Other { + @KotlinSignature("fun foo(): MutableList?") + List foo(); + } + + public class Sub implements TwoSuperclassesInconsistentGenericTypes, Other { + public List foo() { + throw new UnsupportedOperationException(); + } + } +} \ No newline at end of file diff --git a/compiler/testData/loadJavaCustom/kotlinSignature/TwoSuperclassesInconsistentGenericTypes.txt b/compiler/testData/loadJavaCustom/kotlinSignature/TwoSuperclassesInconsistentGenericTypes.txt new file mode 100644 index 00000000000..507ad3514f1 --- /dev/null +++ b/compiler/testData/loadJavaCustom/kotlinSignature/TwoSuperclassesInconsistentGenericTypes.txt @@ -0,0 +1,12 @@ +namespace test + +public abstract trait test.TwoSuperclassesInconsistentGenericTypes : java.lang.Object { + public abstract fun foo(): jet.MutableList + public abstract trait test.TwoSuperclassesInconsistentGenericTypes.Other : java.lang.Object { + public abstract fun foo(): jet.MutableList? + } + public open class test.TwoSuperclassesInconsistentGenericTypes.Sub : test.TwoSuperclassesInconsistentGenericTypes, test.TwoSuperclassesInconsistentGenericTypes.Other { + public final /*constructor*/ fun (): test.TwoSuperclassesInconsistentGenericTypes.Sub + public open override /*2*/ fun foo(): jet.MutableList + } +} diff --git a/compiler/tests/org/jetbrains/jet/jvm/compiler/LoadJavaCustomTest.java b/compiler/tests/org/jetbrains/jet/jvm/compiler/LoadJavaCustomTest.java index beb7939a61f..fa89abb2da6 100644 --- a/compiler/tests/org/jetbrains/jet/jvm/compiler/LoadJavaCustomTest.java +++ b/compiler/tests/org/jetbrains/jet/jvm/compiler/LoadJavaCustomTest.java @@ -84,6 +84,12 @@ public final class LoadJavaCustomTest extends KotlinTestWithEnvironment { PATH + "/" + getTestName(true) + ".java"); } + public void testKotlinSignatureTwoSuperclassesInconsistentGenericTypes() throws Exception { + String dir = PATH + "/kotlinSignature/"; + doTest(dir + "TwoSuperclassesInconsistentGenericTypes.txt", + dir + "TwoSuperclassesInconsistentGenericTypes.java"); + } + //TODO: move to LoadJavaTestGenerated when possible public void testEnum() throws Exception { String dir = PATH + "/enum";