Loading functions from superclasses before current to avoid heisenbug.
Added test with two supertypes. #KT-2776 in progress
This commit is contained in:
+5
-2
@@ -188,6 +188,11 @@ public final class JavaFunctionResolver {
|
|||||||
) {
|
) {
|
||||||
final Set<FunctionDescriptor> functions = new HashSet<FunctionDescriptor>();
|
final Set<FunctionDescriptor> functions = new HashSet<FunctionDescriptor>();
|
||||||
|
|
||||||
|
Set<SimpleFunctionDescriptor> functionsFromSupertypes = null;
|
||||||
|
if (owner instanceof ClassDescriptor) {
|
||||||
|
functionsFromSupertypes = getFunctionsFromSupertypes(methodName, owner);
|
||||||
|
}
|
||||||
|
|
||||||
Set<SimpleFunctionDescriptor> functionsFromCurrent = Sets.newHashSet();
|
Set<SimpleFunctionDescriptor> functionsFromCurrent = Sets.newHashSet();
|
||||||
for (PsiMethodWrapper method : namedMembers.getMethods()) {
|
for (PsiMethodWrapper method : namedMembers.getMethods()) {
|
||||||
SimpleFunctionDescriptor function = resolveMethodToFunctionDescriptor(psiClass, method, scopeData, owner);
|
SimpleFunctionDescriptor function = resolveMethodToFunctionDescriptor(psiClass, method, scopeData, owner);
|
||||||
@@ -199,8 +204,6 @@ public final class JavaFunctionResolver {
|
|||||||
if (owner instanceof ClassDescriptor) {
|
if (owner instanceof ClassDescriptor) {
|
||||||
ClassDescriptor classDescriptor = (ClassDescriptor) owner;
|
ClassDescriptor classDescriptor = (ClassDescriptor) owner;
|
||||||
|
|
||||||
Set<SimpleFunctionDescriptor> functionsFromSupertypes = getFunctionsFromSupertypes(methodName, owner);
|
|
||||||
|
|
||||||
OverrideResolver.generateOverridesInFunctionGroup(methodName, functionsFromSupertypes, functionsFromCurrent, classDescriptor,
|
OverrideResolver.generateOverridesInFunctionGroup(methodName, functionsFromSupertypes, functionsFromCurrent, classDescriptor,
|
||||||
new OverrideResolver.DescriptorSink() {
|
new OverrideResolver.DescriptorSink() {
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
+22
@@ -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<String?>")
|
||||||
|
List<String> foo();
|
||||||
|
|
||||||
|
public interface Other {
|
||||||
|
@KotlinSignature("fun foo(): MutableList<String>?")
|
||||||
|
List<String> foo();
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Sub implements TwoSuperclassesInconsistentGenericTypes, Other {
|
||||||
|
public List<String> foo() {
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+12
@@ -0,0 +1,12 @@
|
|||||||
|
namespace test
|
||||||
|
|
||||||
|
public abstract trait test.TwoSuperclassesInconsistentGenericTypes : java.lang.Object {
|
||||||
|
public abstract fun foo(): jet.MutableList<jet.String?>
|
||||||
|
public abstract trait test.TwoSuperclassesInconsistentGenericTypes.Other : java.lang.Object {
|
||||||
|
public abstract fun foo(): jet.MutableList<jet.String>?
|
||||||
|
}
|
||||||
|
public open class test.TwoSuperclassesInconsistentGenericTypes.Sub : test.TwoSuperclassesInconsistentGenericTypes, test.TwoSuperclassesInconsistentGenericTypes.Other {
|
||||||
|
public final /*constructor*/ fun <init>(): test.TwoSuperclassesInconsistentGenericTypes.Sub
|
||||||
|
public open override /*2*/ fun foo(): jet.MutableList<jet.String?>
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -84,6 +84,12 @@ public final class LoadJavaCustomTest extends KotlinTestWithEnvironment {
|
|||||||
PATH + "/" + getTestName(true) + ".java");
|
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
|
//TODO: move to LoadJavaTestGenerated when possible
|
||||||
public void testEnum() throws Exception {
|
public void testEnum() throws Exception {
|
||||||
String dir = PATH + "/enum";
|
String dir = PATH + "/enum";
|
||||||
|
|||||||
Reference in New Issue
Block a user