Introduced simple propagation of nullability on loading Java.

#KT-2776 in progress
This commit is contained in:
Evgeny Gerashchenko
2012-11-02 15:12:24 +04:00
parent 961fde3c8a
commit 1f4d994480
21 changed files with 367 additions and 2 deletions
@@ -18,6 +18,7 @@ package org.jetbrains.jet.lang.resolve.java.resolver;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import com.intellij.psi.HierarchicalMethodSignature;
import com.intellij.psi.PsiClass;
import com.intellij.psi.PsiMethod;
import com.intellij.psi.PsiType;
@@ -135,6 +136,20 @@ public final class JavaFunctionResolver {
.resolveParameterDescriptors(functionDescriptorImpl, method.getParameters(), methodTypeVariableResolver);
JetType returnType = makeReturnType(returnPsiType, method, methodTypeVariableResolver);
Set<JetType> typesFromSuperMethods = Sets.newHashSet();
for (HierarchicalMethodSignature superSignature : method.getPsiMethod().getHierarchicalMethodSignature().getSuperSignatures()) {
DeclarationDescriptor superFun = trace.get(BindingContext.DECLARATION_TO_DESCRIPTOR, superSignature.getMethod());
if (superFun instanceof FunctionDescriptor) {
typesFromSuperMethods.add(((FunctionDescriptor) superFun).getReturnType());
}
}
typesFromSuperMethods.add(returnType);
JetType intersectionType = TypeUtils.intersect(JetTypeChecker.INSTANCE, typesFromSuperMethods);
if (intersectionType != null && intersectionType.getConstructor().getDeclarationDescriptor() != null) {
returnType = intersectionType;
}
// TODO consider better place for this check
AlternativeMethodSignatureData alternativeMethodSignatureData =
new AlternativeMethodSignatureData(method, valueParameterDescriptors, returnType, methodTypeParameters);