Nullability fixed for many overloaded options
This commit is contained in:
@@ -14,7 +14,7 @@ public class AutoCastServiceImpl implements AutoCastService {
|
|||||||
private final DataFlowInfo dataFlowInfo;
|
private final DataFlowInfo dataFlowInfo;
|
||||||
private final BindingContext bindingContext;
|
private final BindingContext bindingContext;
|
||||||
|
|
||||||
AutoCastServiceImpl(DataFlowInfo dataFlowInfo, BindingContext bindingContext) {
|
public AutoCastServiceImpl(DataFlowInfo dataFlowInfo, BindingContext bindingContext) {
|
||||||
this.dataFlowInfo = dataFlowInfo;
|
this.dataFlowInfo = dataFlowInfo;
|
||||||
this.bindingContext = bindingContext;
|
this.bindingContext = bindingContext;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -652,7 +652,12 @@ public class CallResolver {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!weakErrors.isEmpty()) {
|
if (!weakErrors.isEmpty()) {
|
||||||
return chooseAndReportMaximallySpecific(trace, tracing, weakErrors);
|
OverloadResolutionResults<D> results = chooseAndReportMaximallySpecific(trace, tracing, weakErrors);
|
||||||
|
if (results.isSuccess()) {
|
||||||
|
return OverloadResolutionResults.singleFailedCandidate(results.getResult());
|
||||||
|
}
|
||||||
|
|
||||||
|
return OverloadResolutionResults.manyFailedCandidates(results.getResults());
|
||||||
}
|
}
|
||||||
|
|
||||||
Set<ResolvedCall<D>> noOverrides = OverridingUtil.filterOverrides(failedCandidates, MAP_TO_CANDIDATE);
|
Set<ResolvedCall<D>> noOverrides = OverridingUtil.filterOverrides(failedCandidates, MAP_TO_CANDIDATE);
|
||||||
|
|||||||
+1
-2
@@ -5,7 +5,6 @@ import org.jetbrains.jet.lang.descriptors.CallableDescriptor;
|
|||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author abreslav
|
* @author abreslav
|
||||||
@@ -41,7 +40,7 @@ public class OverloadResolutionResults<D extends CallableDescriptor> {
|
|||||||
public static <D extends CallableDescriptor> OverloadResolutionResults<D> singleFailedCandidate(ResolvedCall<D> candidate) {
|
public static <D extends CallableDescriptor> OverloadResolutionResults<D> singleFailedCandidate(ResolvedCall<D> candidate) {
|
||||||
return new OverloadResolutionResults<D>(Code.SINGLE_CANDIDATE_ARGUMENT_MISMATCH, Collections.singleton(candidate));
|
return new OverloadResolutionResults<D>(Code.SINGLE_CANDIDATE_ARGUMENT_MISMATCH, Collections.singleton(candidate));
|
||||||
}
|
}
|
||||||
public static <D extends CallableDescriptor> OverloadResolutionResults<D> manyFailedCandidates(Set<ResolvedCall<D>> failedCandidates) {
|
public static <D extends CallableDescriptor> OverloadResolutionResults<D> manyFailedCandidates(Collection<ResolvedCall<D>> failedCandidates) {
|
||||||
return new OverloadResolutionResults<D>(Code.MANY_FAILED_CANDIDATES, failedCandidates);
|
return new OverloadResolutionResults<D>(Code.MANY_FAILED_CANDIDATES, failedCandidates);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -236,6 +236,11 @@ public class CallMaker {
|
|||||||
public PsiElement getCallElement() {
|
public PsiElement getCallElement() {
|
||||||
return callElement;
|
return callElement;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return callElement.toString();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,13 +62,16 @@ public class DataFlowInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private List<JetType> getPossibleTypes(Object key) {
|
private List<JetType> getPossibleTypes(Object key, @NotNull JetType originalType) {
|
||||||
List<JetType> types = typeInfo.get(key);
|
List<JetType> types = typeInfo.get(key);
|
||||||
NullabilityFlags nullabilityFlags = nullabilityInfo.get(key);
|
NullabilityFlags nullabilityFlags = nullabilityInfo.get(key);
|
||||||
if (nullabilityFlags == null || nullabilityFlags.canBeNull()) {
|
if (nullabilityFlags == null || nullabilityFlags.canBeNull()) {
|
||||||
return types;
|
return types;
|
||||||
}
|
}
|
||||||
List<JetType> enrichedTypes = Lists.newArrayListWithCapacity(types.size());
|
List<JetType> enrichedTypes = Lists.newArrayListWithCapacity(types.size());
|
||||||
|
if (originalType.isNullable()) {
|
||||||
|
enrichedTypes.add(TypeUtils.makeNotNullable(originalType));
|
||||||
|
}
|
||||||
for (JetType type: types) {
|
for (JetType type: types) {
|
||||||
if (type.isNullable()) {
|
if (type.isNullable()) {
|
||||||
enrichedTypes.add(TypeUtils.makeNotNullable(type));
|
enrichedTypes.add(TypeUtils.makeNotNullable(type));
|
||||||
@@ -81,12 +84,12 @@ public class DataFlowInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public List<JetType> getPossibleTypesForVariable(VariableDescriptor variableDescriptor) {
|
public List<JetType> getPossibleTypesForVariable(@NotNull VariableDescriptor variableDescriptor) {
|
||||||
return getPossibleTypes(variableDescriptor);
|
return getPossibleTypes(variableDescriptor, variableDescriptor.getOutType());
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<JetType> getPossibleTypesForReceiver(@NotNull ReceiverDescriptor receiver) {
|
public List<JetType> getPossibleTypesForReceiver(@NotNull ReceiverDescriptor receiver) {
|
||||||
return getPossibleTypes(receiver);
|
return getPossibleTypes(receiver, receiver.getType());
|
||||||
}
|
}
|
||||||
|
|
||||||
public DataFlowInfo equalsToNull(@NotNull VariableDescriptor variableDescriptor, boolean notNull) {
|
public DataFlowInfo equalsToNull(@NotNull VariableDescriptor variableDescriptor, boolean notNull) {
|
||||||
|
|||||||
Reference in New Issue
Block a user