Minor. Extract getDataFlowValueExcludingReceiver
This commit is contained in:
+20
-6
@@ -117,19 +117,33 @@ public class SmartCastManager {
|
|||||||
@NotNull DeclarationDescriptor containingDeclarationOrModule,
|
@NotNull DeclarationDescriptor containingDeclarationOrModule,
|
||||||
@NotNull DataFlowInfo dataFlowInfo,
|
@NotNull DataFlowInfo dataFlowInfo,
|
||||||
@NotNull ReceiverValue receiverToCast
|
@NotNull ReceiverValue receiverToCast
|
||||||
|
) {
|
||||||
|
DataFlowValue dataFlowValue = getDataFlowValueExcludingReceiver(bindingContext, containingDeclarationOrModule, receiverToCast);
|
||||||
|
|
||||||
|
if (dataFlowValue != null) {
|
||||||
|
return dataFlowInfo.getPossibleTypes(dataFlowValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public static DataFlowValue getDataFlowValueExcludingReceiver(
|
||||||
|
@NotNull BindingContext bindingContext,
|
||||||
|
@NotNull DeclarationDescriptor containingDeclarationOrModule,
|
||||||
|
@NotNull ReceiverValue receiverToCast
|
||||||
) {
|
) {
|
||||||
if (receiverToCast instanceof ThisReceiver) {
|
if (receiverToCast instanceof ThisReceiver) {
|
||||||
ThisReceiver receiver = (ThisReceiver) receiverToCast;
|
ThisReceiver receiver = (ThisReceiver) receiverToCast;
|
||||||
assert receiver.exists();
|
assert receiver.exists();
|
||||||
DataFlowValue dataFlowValue = DataFlowValueFactory.createDataFlowValue(receiver);
|
return DataFlowValueFactory.createDataFlowValue(receiver);
|
||||||
return dataFlowInfo.getPossibleTypes(dataFlowValue);
|
|
||||||
}
|
}
|
||||||
else if (receiverToCast instanceof ExpressionReceiver) {
|
else if (receiverToCast instanceof ExpressionReceiver) {
|
||||||
DataFlowValue dataFlowValue = DataFlowValueFactory.createDataFlowValue(
|
return DataFlowValueFactory.createDataFlowValue(
|
||||||
receiverToCast, bindingContext, containingDeclarationOrModule);
|
receiverToCast, bindingContext, containingDeclarationOrModule
|
||||||
return dataFlowInfo.getPossibleTypes(dataFlowValue);
|
);
|
||||||
}
|
}
|
||||||
return Collections.emptyList();
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isSubTypeBySmartCastIgnoringNullability(
|
public boolean isSubTypeBySmartCastIgnoringNullability(
|
||||||
|
|||||||
Reference in New Issue
Block a user