Fixed propagation for non-abstract methods inherited from traits.
This commit is contained in:
+25
@@ -18,11 +18,16 @@ package org.jetbrains.jet.lang.resolve.java.kotlinSignature;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.psi.HierarchicalMethodSignature;
|
||||
import com.intellij.psi.PsiMethod;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.descriptors.CallableMemberDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.ClassifierDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.TypeParameterDescriptor;
|
||||
import org.jetbrains.jet.lang.resolve.java.kt.DescriptorKindUtils;
|
||||
import org.jetbrains.jet.lang.resolve.java.wrapper.PsiMethodWrapper;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lang.types.JetTypeImpl;
|
||||
@@ -114,6 +119,26 @@ class PropagationHeuristics {
|
||||
return null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
static List<PsiMethod> getSuperMethods(@NotNull PsiMethod method) {
|
||||
List<PsiMethod> superMethods = Lists.newArrayList();
|
||||
for (HierarchicalMethodSignature superSignature : method.getHierarchicalMethodSignature().getSuperSignatures()) {
|
||||
PsiMethod superMethod = superSignature.getMethod();
|
||||
CallableMemberDescriptor.Kind kindFromFlags =
|
||||
DescriptorKindUtils.flagsToKind(new PsiMethodWrapper(superMethod).getJetMethodAnnotation().kind());
|
||||
if (kindFromFlags == CallableMemberDescriptor.Kind.FAKE_OVERRIDE) {
|
||||
// This is for the case when a Kotlin class inherits a non-abstract method from a trait:
|
||||
// from Kotlin's point of view it is fake override, from Java's it is normal override.
|
||||
// We replace this "fake override" method with original method from the trait.
|
||||
superMethods.addAll(getSuperMethods(superMethod));
|
||||
}
|
||||
else {
|
||||
superMethods.add(superMethod);
|
||||
}
|
||||
}
|
||||
return superMethods;
|
||||
}
|
||||
|
||||
private PropagationHeuristics() {
|
||||
}
|
||||
}
|
||||
|
||||
+1
-3
@@ -209,9 +209,7 @@ public class SignaturesPropagationData {
|
||||
Multimap<FqName, Pair<FunctionDescriptor, PsiMethod>> superclassToFunctions =
|
||||
getSuperclassToFunctionsMultimap(method, trace.getBindingContext(), containingClass);
|
||||
|
||||
for (HierarchicalMethodSignature superSignature : method.getPsiMethod().getHierarchicalMethodSignature().getSuperSignatures()) {
|
||||
PsiMethod superMethod = superSignature.getMethod();
|
||||
|
||||
for (PsiMethod superMethod : PropagationHeuristics.getSuperMethods(method.getPsiMethod())) {
|
||||
PsiClass psiClass = superMethod.getContainingClass();
|
||||
assert psiClass != null;
|
||||
String classFqNameString = psiClass.getQualifiedName();
|
||||
|
||||
Reference in New Issue
Block a user