use of org.jetbrains.kotlin.resolve.calls.smartcasts.Nullability in project kotlin by JetBrains.
the class BasicExpressionTypingVisitor method checkNull.
private static void checkNull(@NotNull KtSimpleNameExpression expression, @NotNull ExpressionTypingContext context, @Nullable KotlinType type) {
// Receivers are normally analyzed at resolve, with an exception of KT-10175
if (type != null && !type.isError() && !isLValueOrUnsafeReceiver(expression)) {
DataFlowValue dataFlowValue = DataFlowValueFactory.createDataFlowValue(expression, type, context);
Nullability nullability = context.dataFlowInfo.getStableNullability(dataFlowValue);
if (!nullability.canBeNonNull() && nullability.canBeNull()) {
if (isDangerousWithNull(expression, context)) {
context.trace.report(ALWAYS_NULL.on(expression));
} else {
context.trace.record(SMARTCAST_NULL, expression);
}
}
}
}
Aggregations