Introduced simple propagation of nullability on loading Java.
#KT-2776 in progress
This commit is contained in:
+15
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user