4 instantiations of TypeWithState
Microsoft.CodeAnalysis.CSharp (4)
Symbols\TypeWithState.cs (4)
34
return new
TypeWithState
(type, defaultState);
37
return new
TypeWithState
(type, state);
81
public TypeWithState WithNotNullState() => new
TypeWithState
(Type, NullableFlowState.NotNull);
83
public TypeWithState WithSuppression(bool suppress) => suppress ? new
TypeWithState
(Type, NullableFlowState.NotNull) : this;
334 references to TypeWithState
Microsoft.CodeAnalysis.CSharp (333)
Binder\Binder_Patterns.cs (1)
1369
var declType =
TypeWithState
.ForType(inputType).ToTypeWithAnnotations(Compilation);
Binder\Semantics\BestTypeInferrer.cs (2)
36
public static NullableFlowState GetNullableState(ArrayBuilder<
TypeWithState
> types)
39
foreach (
var
type in types)
FlowAnalysis\NullableWalker.cs (307)
118
public readonly
TypeWithState
RValueType;
130
public VisitResult(
TypeWithState
rValueType, TypeWithAnnotations lValueType)
139
public VisitResult(
TypeWithState
rValueType, TypeWithAnnotations lValueType, Optional<LocalState> stateForLambda)
147
RValueType =
TypeWithState
.Create(type, state);
156
public VisitResult(
TypeWithState
rValueType, TypeWithAnnotations lValueType, VisitResult[] nestedVisitResults)
235
private static readonly
TypeWithState
_invalidType =
TypeWithState
.Create(new UnsupportedMetadataTypeSymbol(), NullableFlowState.NotNull);
256
private PooledDictionary<BoundExpression,
TypeWithState
>? _methodGroupReceiverMapOpt;
267
private PooledDictionary<BoundExpression, Func<TypeWithAnnotations,
TypeWithState
>>? _targetTypedAnalysisCompletionOpt;
272
/// The delegate is invoked by <see cref="VisitConversion(BoundConversion, BoundExpression, Conversion, TypeWithAnnotations,
TypeWithState
, bool, bool, bool, AssignmentKind, ParameterSymbol, bool, bool, bool, bool, Optional<LocalState>,bool, Location, ArrayBuilder<VisitResult>)"/>.
274
private PooledDictionary<BoundExpression, Func<TypeWithAnnotations,
TypeWithState
>> TargetTypedAnalysisCompletion
275
=> _targetTypedAnalysisCompletionOpt ??= PooledDictionary<BoundExpression, Func<TypeWithAnnotations,
TypeWithState
>>.GetInstance();
316
private
TypeWithState
ResultType
321
private void SetResultType(BoundExpression? expression,
TypeWithState
type, bool updateAnalyzedNullability = true)
326
private void SetAnalyzedNullability(BoundExpression? expression,
TypeWithState
type)
360
private void SetResult(BoundExpression? expression,
TypeWithState
resultType, TypeWithAnnotations lvalueType, bool updateAnalyzedNullability = true, bool? isLvalue = null)
380
private void SetAnalyzedNullability(BoundExpression? expression,
TypeWithState
resultType, TypeWithAnnotations lvalueType, bool? isLvalue = null)
2337
private
TypeWithState
VisitRvalueWithState(BoundExpression? node)
2381
/// This should often be checked together with <seealso cref="IsDisallowedNullAssignment(
TypeWithState
, FlowAnalysisAnnotations)"/>
2421
TypeWithState
valueType,
2476
static bool isMaybeDefaultValue(
TypeWithState
valueType)
2513
var
valueState = GetParameterState(
2552
var
valueWhen = ApplyUnconditionalAnnotations(
2566
static bool isBadAssignment(
TypeWithState
valueState, TypeWithAnnotations destinationType, FlowAnalysisAnnotations destinationAnnotations)
2644
TypeWithState
valueType,
2685
static bool areEquivalentTypes(TypeWithAnnotations target,
TypeWithState
assignedValue) =>
3030
var
resultType = VisitOptionalImplicitConversion(
3044
internal static
TypeWithState
GetParameterState(TypeWithAnnotations parameterType, FlowAnalysisAnnotations parameterAnnotations)
3048
return
TypeWithState
.Create(parameterType.Type, NullableFlowState.MaybeDefault);
3053
return
TypeWithState
.Create(parameterType.Type, NullableFlowState.NotNull);
3084
TypeWithState
returnState;
3101
var
result = VisitRvalueWithState(expr);
3133
private
TypeWithState
VisitRefExpression(BoundExpression expr, TypeWithAnnotations destinationType)
3136
TypeWithState
resultType = ResultType;
3203
SetResultType(node,
TypeWithState
.ForType(node.Type));
3573
var
resultState = ApplyUnconditionalAnnotations(resultType.ToTypeWithState(), GetRValueAnnotations(withExpr.CloneMethod));
3672
TypeWithState
valueType;
3721
TypeWithState
resultType = ResultType;
3731
var
result = resultType.WithNotNullState();
3853
SetResultType(node,
TypeWithState
.Create(null, NullableFlowState.NotNull));
3861
SetResultType(node,
TypeWithState
.Create(null, NullableFlowState.NotNull));
3874
var elementConversionCompletions = ArrayBuilder<Func<TypeWithAnnotations /*targetElementType*/, TypeSymbol /*targetCollectionType*/,
TypeWithState
>>.GetInstance();
3896
var visitResult = new VisitResult(
TypeWithState
.Create(resultType), resultType,
3902
void visitElement(BoundNode element, BoundCollectionExpression node, TypeWithAnnotations targetElementType, ArrayBuilder<Func<TypeWithAnnotations, TypeSymbol,
TypeWithState
>> elementConversionCompletions)
3936
var
resultType = VisitConversion(
3994
TypeWithState
convertCollection(BoundCollectionExpression node, TypeWithAnnotations targetCollectionType, ArrayBuilder<Func<TypeWithAnnotations, TypeSymbol,
TypeWithState
>> completions)
4016
var
resultTypeWithState =
TypeWithState
.Create(strippedTargetCollectionType, resultState);
4110
TypeWithState
result = setAnalyzedNullability(node, type, argumentResults, argumentsCompletion, initialStateInferenceCompletion, initializerCompletion, resultState, isTargetTyped);
4114
TypeWithState
setAnalyzedNullability(
4124
var
result =
TypeWithState
.Create(type, resultState);
4523
Action<int, Symbol>? visitMemberAssignment(BoundAssignmentOperator node, int containingSlot, Symbol symbol, bool delayCompletionForType, Func<TypeWithAnnotations,
TypeWithState
>? conversionCompletion = null)
4536
(
TypeWithState
resultType, conversionCompletion) =
4556
Action<int, Symbol>? visitMemberAssignmentAsContinuation(BoundAssignmentOperator node, Func<TypeWithAnnotations,
TypeWithState
> conversionCompletion)
4664
TypeWithState
.Create(containingType, receiverResult.RValueType.State),
4684
SetResultType(node,
TypeWithState
.Create(node.Type, NullableFlowState.NotNull));
4689
var
resultType =
TypeWithState
.Create(node.Type, NullableFlowState.NotNull);
4778
var
argumentType = argumentTypes[i];
4797
SetResultType(node,
TypeWithState
.Create(anonymousType, NullableFlowState.NotNull));
4829
SetResultType(node,
TypeWithState
.Create(node.Type, NullableFlowState.NotNull));
4834
SetResultType(node,
TypeWithState
.Create(arrayType, NullableFlowState.NotNull));
4868
var expressionTypes = ArrayBuilder<
TypeWithState
>.GetInstance(n);
4877
var
expressionType = VisitRvalueWithState(expressionNoConversion);
4911
inferredType =
TypeWithState
.Create(inferredType.Type, elementState).ToTypeWithAnnotations(compilation);
5110
private
TypeWithState
InferResultNullability(BinaryOperatorKind operatorKind, MethodSymbol? methodOpt, TypeSymbol resultType,
TypeWithState
leftType,
TypeWithState
rightType)
5122
var
resultTypeWithState = GetReturnTypeWithState(methodOpt);
5153
return
TypeWithState
.Create(resultType, resultState);
5170
var
leftType = ResultType;
5197
var
rightType = VisitRvalueWithState(rightOperand);
5240
static bool isKnownNullOrNotNull(BoundExpression expr,
TypeWithState
resultType)
5275
var
leftResult = ResultType;
5328
SetResult(binary,
TypeWithState
.ForType(binary.Type), TypeWithAnnotations.Create(binary.Type));
5336
TypeWithState
leftType,
5339
TypeWithState
rightType,
5342
var
inferredResult = ReinferAndVisitBinaryOperator(binary, binary.OperatorKind, binary.BinaryOperatorMethod, binary.Type, binary.Left, leftOperand, leftConversion, leftType, binary.Right, rightOperand, rightConversion, rightType);
5346
private
TypeWithState
ReinferAndVisitBinaryOperator(
5354
TypeWithState
leftType,
5358
TypeWithState
rightType)
5368
TypeWithState
leftUnderlyingType = GetNullableUnderlyingTypeIfNecessary(isLifted, leftType);
5369
TypeWithState
rightUnderlyingType = GetNullableUnderlyingTypeIfNecessary(isLifted, rightType);
5391
TypeWithState
operandType)
5424
var
inferredResult = InferResultNullability(operatorKind, method, returnType, leftType, rightType);
5434
TypeWithState
leftUnderlyingType,
5435
TypeWithState
rightUnderlyingType)
5500
private
TypeWithState
VisitBinaryOperatorOperandConversion(
5501
BoundExpression expr, BoundExpression operand, Conversion conversion, ParameterSymbol parameter,
TypeWithState
operandType, bool isLifted,
5525
private void VisitBinaryOperatorOperandConversionAndPostConditions(BoundExpression expr, BoundExpression operand, Conversion conversion, ParameterSymbol parameter,
TypeWithState
operandType, bool isLifted)
5528
TypeWithState
resultType = VisitBinaryOperatorOperandConversion(expr, operand, conversion, parameter, operandType, isLifted, out parameterAnnotations);
5544
var
leftType = ResultType;
5549
var
rightType = ResultType;
5903
TypeWithState
rightResult = VisitOptionalImplicitConversion(rightOperand, targetType, useLegacyWarnings: UseLegacyWarnings(leftOperand), trackMembers: false, AssignmentKind.Assignment);
5908
TypeWithState
resultType =
TypeWithState
.Create(targetType.Type, rightResult.State);
5924
var
rightUnconditionalResult = ResultType;
5927
SetResultType(node,
TypeWithState
.Create(node.Type, rightUnconditionalResult.State));
5932
TypeWithState
leftResult = ResultType;
5943
TypeWithState
rightResult = ResultType;
5961
SetResultType(node,
TypeWithState
.Create(resultType, rightResult.State.Join(leftState)));
5987
var
conversionResult = VisitConversion(
5994
TypeWithState
.Create(leftType, NullableFlowState.NotNull),
6026
var
operandType = ResultType;
6031
var
result = VisitConversion(boundConversion,
6178
SetResultType(node,
TypeWithState
.Create(resultType, NullableFlowState.MaybeDefault));
6214
TypeWithState
consequenceRValue;
6215
TypeWithState
alternativeRValue;
6254
SetResult(node,
TypeWithState
.Create(refResultType, rValueState), TypeWithAnnotations.Create(refResultType, lValueAnnotation));
6318
SetResultType(node,
TypeWithState
.Create(resultType, default));
6329
TypeWithState
typeWithState = convertArms(
6336
TypeWithState
convertArms(
6338
TypeWithState
consequenceRValue,
TypeWithState
alternativeRValue, BoundExpression consequence, Conversion consequenceConversion, bool consequenceEndReachable,
6344
TypeWithState
convertedConsequenceResult = ConvertConditionalOperandOrSwitchExpressionArmResult(
6353
TypeWithState
convertedAlternativeResult = ConvertConditionalOperandOrSwitchExpressionArmResult(
6363
var
typeWithState =
TypeWithState
.Create(resultTypeWithAnnotations.Type, resultState);
6376
return
TypeWithState
.Create(resultTypeWithAnnotations.Type, resultState);
6386
TypeWithState
consequenceRValue,
6387
TypeWithState
alternativeRValue,
6405
(BoundExpression, Conversion,
TypeWithState
) visitConditionalOperand(LocalState state, BoundExpression operand)
6418
(TypeWithAnnotations LValueType,
TypeWithState
RValueType) visitConditionalRefOperand(LocalState state, BoundExpression operand)
6435
private
TypeWithState
ConvertConditionalOperandOrSwitchExpressionArmResult(
6440
TypeWithState
operandType,
6457
var
resultType = VisitConversion(
6501
SetResultType(node,
TypeWithState
.Create(rvalueType, NullableFlowState.NotNull));
6527
TypeWithState
receiverType = visitAndCheckReceiver(node);
6601
TypeWithState
receiverType = visitAndCheckReceiver(node);
6629
TypeWithState
visitAndCheckReceiver(BoundCall node)
6639
void reinferMethodAndVisitArguments(BoundCall node,
TypeWithState
receiverType, VisitResult? firstArgumentResult = null)
6675
var
returnState = GetReturnTypeWithState(method);
6686
private
TypeWithState
VisitAndCheckReceiver(BoundExpression? receiverOpt, MethodSymbol method)
6688
TypeWithState
receiverType = default;
6703
TypeWithState
receiverType,
6820
private void LearnFromEqualsMethod(MethodSymbol method, BoundCall node,
TypeWithState
receiverType, ImmutableArray<VisitResult> results)
6956
void learnFromEqualsMethodArguments(BoundExpression left,
TypeWithState
leftType, BoundExpression right,
TypeWithState
rightType)
7057
private void CheckCallReceiver(BoundExpression? receiverOpt,
TypeWithState
receiverType, MethodSymbol method)
7090
private
TypeWithState
GetReturnTypeWithState(MethodSymbol method)
7092
return
TypeWithState
.Create(method.ReturnTypeWithAnnotations, GetRValueAnnotations(method));
7162
private static
TypeWithState
ApplyUnconditionalAnnotations(
TypeWithState
typeWithState, FlowAnalysisAnnotations annotations)
7166
return
TypeWithState
.Create(typeWithState.Type, NullableFlowState.NotNull);
7171
return
TypeWithState
.Create(typeWithState.Type, NullableFlowState.MaybeDefault);
7498
TrackAnalyzedNullabilityThroughConversionGroup(
TypeWithState
.Create(argument.Type, result.RValueType.State), argument as BoundConversion, argumentNoConversion);
7909
var
resultType = result.RValueType;
7927
var
stateAfterConversion = VisitConversion(
7982
private bool CheckDisallowedNullAssignment(
TypeWithState
state, FlowAnalysisAnnotations annotations, SyntaxNode node, BoundExpression? boundValueOpt = null)
8000
private static bool IsDisallowedNullAssignment(
TypeWithState
valueState, FlowAnalysisAnnotations targetAnnotations)
8058
var
parameterWithState =
TypeWithState
.Create(parameterType, parameterAnnotations);
8062
parameterWithState =
TypeWithState
.Create(parameterType.Type, adjustedState);
8085
var
parameterWithState =
TypeWithState
.Create(parameterType, parameterAnnotations);
8088
var
worstCaseParameterWithState = applyPostConditionsUnconditionally(parameterWithState, parameterAnnotations);
8149
void trackNullableStateForAssignment(BoundExpression parameterValue, TypeWithAnnotations lValueType, int targetSlot,
TypeWithState
parameterWithState, bool isSuppressed, FlowAnalysisAnnotations parameterAnnotations)
8180
static
TypeWithState
applyPostConditionsUnconditionally(
TypeWithState
typeWithState, FlowAnalysisAnnotations annotations)
8185
return
TypeWithState
.Create(typeWithState.Type, NullableFlowState.MaybeDefault);
8191
return
TypeWithState
.Create(typeWithState.Type, NullableFlowState.NotNull);
8197
static
TypeWithState
applyPostConditionsWhenTrue(
TypeWithState
typeWithState, FlowAnalysisAnnotations annotations)
8206
return
TypeWithState
.Create(typeWithState.Type, NullableFlowState.MaybeDefault);
8210
return
TypeWithState
.Create(typeWithState.Type, NullableFlowState.NotNull);
8216
static
TypeWithState
applyPostConditionsWhenFalse(
TypeWithState
typeWithState, FlowAnalysisAnnotations annotations)
8225
return
TypeWithState
.Create(typeWithState.Type, NullableFlowState.MaybeDefault);
8229
return
TypeWithState
.Create(typeWithState.Type, NullableFlowState.NotNull);
8517
if (_walker.TryGetMethodGroupReceiverNullability(group.ReceiverOpt, out
TypeWithState
receiverType))
8783
private
TypeWithState
GetAdjustedResult(
TypeWithState
type, int slot)
8788
return
TypeWithState
.Create(type.Type, state);
8944
private
TypeWithState
VisitOptionalImplicitConversion(BoundExpression expr, TypeWithAnnotations targetTypeOpt, bool useLegacyWarnings, bool trackMembers, AssignmentKind assignmentKind)
8956
private (
TypeWithState
resultType, Func<TypeWithAnnotations,
TypeWithState
>? completion) VisitOptionalImplicitConversion(
8966
var
operandType = VisitRvalueWithState(operand);
8970
(
TypeWithState
resultType, Func<TypeWithAnnotations,
TypeWithState
>? completion) visitConversion(
8975
Conversion conversion,
TypeWithState
operandType,
8980
return (
TypeWithState
.Create(targetTypeOpt), visitConversionAsContinuation(expr, useLegacyWarnings, trackMembers, assignmentKind, operand, conversion, operandType));
8990
var
resultType = VisitConversion(
9007
Func<TypeWithAnnotations,
TypeWithState
> visitConversionAsContinuation(BoundExpression expr, bool useLegacyWarnings, bool trackMembers, AssignmentKind assignmentKind, BoundExpression operand, Conversion conversion,
TypeWithState
operandType)
9057
ImmutableArray<
TypeWithState
> elementTypes = arguments.SelectAsArray((a, w) => w.VisitRvalueWithState(a), this);
9062
SetResultType(node,
TypeWithState
.Create(null, NullableFlowState.NotNull));
9087
SetResultType(node,
TypeWithState
.Create(tupleOpt, NullableFlowState.NotNull));
9100
ImmutableArray<
TypeWithState
> types,
9130
void trackState(BoundExpression value, FieldSymbol field,
TypeWithState
valueType)
9144
private void TrackNullableStateOfNullableValue(int containingSlot, TypeSymbol containingType, BoundExpression? value,
TypeWithState
valueType, int valueSlot)
9238
var
convertedType = VisitUserDefinedConversion(
9411
private
TypeWithState
VisitConversion(
9416
TypeWithState
operandType,
9436
if (TargetTypedAnalysisCompletion.TryGetValue(conversionOperand, out Func<TypeWithAnnotations,
TypeWithState
>? completion))
9518
return
TypeWithState
.Create(targetType, NullableFlowState.NotNull);
9733
TypeWithState
resultType = calculateResultType(targetTypeWithNullability, fromExplicitCast, resultState, isSuppressed, targetType);
9767
static
TypeWithState
calculateResultType(TypeWithAnnotations targetTypeWithNullability, bool fromExplicitCast, NullableFlowState resultState, bool isSuppressed, TypeSymbol targetType)
9779
var
resultType =
TypeWithState
.Create(targetType, resultState);
9783
static NullableFlowState getReferenceConversionResultState(TypeWithAnnotations targetType,
TypeWithState
operandType)
9817
static NullableFlowState getBoxingConversionResultState(TypeWithAnnotations targetType,
TypeWithState
operandType)
9845
static NullableFlowState getUnboxingConversionResultState(
TypeWithState
operandType)
9855
static NullableFlowState getConversionResultState(
TypeWithState
operandType)
9971
private
TypeWithState
VisitUserDefinedConversion(
9976
TypeWithState
operandType,
9996
var
resultType =
TypeWithState
.Create(targetType, NullableFlowState.NotNull);
10028
TypeWithState
underlyingOperandType = default;
10136
private void TrackAnalyzedNullabilityThroughConversionGroup(
TypeWithState
resultType, BoundConversion? conversionOpt, BoundExpression convertedNode)
10159
private
TypeWithState
GetLiftedReturnType(TypeWithAnnotations returnType, NullableFlowState operandState)
10164
return
TypeWithState
.Create(type, state);
10167
private static
TypeWithState
GetNullableUnderlyingTypeIfNecessary(bool isLifted,
TypeWithState
typeWithState)
10180
private
TypeWithState
GetLiftedReturnTypeIfNecessary(bool isLifted, TypeWithAnnotations returnType, NullableFlowState operandState)
10192
private
TypeWithState
ClassifyAndVisitConversion(
10195
TypeWithState
operandType,
10270
TypeWithState
result = setAnalyzedNullability(node, delegateType, analysisCompletion, node.WasTargetTyped);
10274
TypeWithState
setAnalyzedNullability(BoundDelegateCreationExpression node, NamedTypeSymbol delegateType, Action<NamedTypeSymbol>? analysisCompletion, bool isTargetTyped)
10276
var
result =
TypeWithState
.Create(delegateType, NullableFlowState.NotNull);
10376
var
argState = VisitRvalueWithState(arg);
10429
private bool TryGetMethodGroupReceiverNullability([NotNullWhen(true)] BoundExpression? receiverOpt, out
TypeWithState
type)
10444
private void SetMethodGroupReceiverNullability(BoundExpression receiver,
TypeWithState
type)
10446
_methodGroupReceiverMapOpt ??= PooledDictionary<BoundExpression,
TypeWithState
>.GetInstance();
10455
if (TryGetMethodGroupReceiverNullability(receiverOpt, out
TypeWithState
receiverType))
10573
var
rvalueResult =
TypeWithState
.Create(node.Type, NullableFlowState.NotNull);
10583
var
typeWithState = GetParameterState(parameterType, parameter.FlowAnalysisAnnotations);
10626
TypeWithState
rightState;
10649
SetResult(node,
TypeWithState
.Create(leftLValueType.Type, rightState.State), leftLValueType);
10669
var
rValueType = ApplyUnconditionalAnnotations(type.ToTypeWithState(), annotations);
10678
private void AdjustSetValue(BoundExpression left, ref
TypeWithState
rightState)
10772
private BoundNode? VisitDeconstructionAssignmentOperator(BoundDeconstructionAssignmentOperator node,
TypeWithState
? rightResultOpt)
10802
private void VisitDeconstructionArguments(ArrayBuilder<DeconstructionVariable> variables, Conversion conversion, BoundExpression right,
TypeWithState
? rightResultOpt = null)
10816
private void VisitDeconstructMethodArguments(ArrayBuilder<DeconstructionVariable> variables, Conversion conversion, BoundExpression right,
TypeWithState
? rightResultOpt)
10825
var
rightResult = ResultType;
10915
private void VisitTupleDeconstructionArguments(ArrayBuilder<DeconstructionVariable> variables, ImmutableArray<(BoundValuePlaceholder? placeholder, BoundExpression? conversion)> deconstructConversionInfo, BoundExpression right,
TypeWithState
? rightResultOpt)
10938
TypeWithState
operandType;
10939
TypeWithState
valueType;
10991
var
valueBeforeNullableWrapping =
TypeWithState
.Create(underlyingType.Type, NullableFlowState.NotNull);
11048
private ImmutableArray<BoundExpression> GetDeconstructionRightParts(BoundExpression expr,
TypeWithState
? rightResultOpt)
11101
TypeWithState
receiverType = VisitAndCheckReceiver(node.Operand, instanceMethod);
11120
SetResultType(node,
TypeWithState
.Create(receiverType.Type, NullableFlowState.NotNull));
11124
SetResultType(node,
TypeWithState
.Create(results[0].RValueType.Type, GetState(ref State, extensionReceiverSlot)));
11136
var
opType = VisitRvalueWithState(node.Operand);
11144
SetResultType(node,
TypeWithState
.Create(opType.Type, NullableFlowState.NotNull));
11151
var
operandType = VisitRvalueWithState(node.Operand);
11195
TypeWithState
resultOfOperandConversionType;
11219
TypeWithState
resultOfIncrementType;
11245
TypeWithState
resultType = (op == UnaryOperatorKind.PrefixIncrement || op == UnaryOperatorKind.PrefixDecrement) ? resultOfIncrementType : operandType;
11278
TypeWithState
receiverType = VisitAndCheckReceiver(node.Left, instanceMethod);
11297
SetResultType(node,
TypeWithState
.Create(receiverType.Type, NullableFlowState.NotNull));
11301
SetResultType(node,
TypeWithState
.Create(results[0].RValueType.Type, GetState(ref State, extensionReceiverSlot)));
11314
var
opType = ResultType;
11325
SetResultType(node,
TypeWithState
.Create(opType.Type, NullableFlowState.NotNull));
11335
var
leftTypeWithState = ResultType;
11343
var
rightTypeWithState = VisitRvalueWithState(rightConversionOperand);
11350
var
resultTypeWithState = ReinferAndVisitBinaryOperator(
11403
SetResultType(node.Expression,
TypeWithState
.Create(node.Expression.Type, ResultType.State));
11502
TypeWithState
typeWithState = ApplyUnconditionalAnnotations(typeWithAnnotations.ToTypeWithState(), memberAnnotations);
11545
var
resultType = ApplyUnconditionalAnnotations(indexer.TypeWithAnnotations.ToTypeWithState(), GetRValueAnnotations(indexer));
11603
var
receiverType = (receiverOpt != null) ? VisitRvalueWithState(receiverOpt) : default;
11618
var
resultType = ApplyUnconditionalAnnotations(type.ToTypeWithState(), memberAnnotations);
11628
resultType =
TypeWithState
.Create(resultType.Type, state);
11730
var
resultTypeWithState = VisitRvalueWithState(expr);
11799
var
convertedResult = VisitConversion(
11817
TypeWithState
currentPropertyGetterTypeWithState;
11858
var
enumeratorReturnType = GetReturnTypeWithState(reinferredGetEnumeratorMethod);
11914
var
sourceState = node.EnumeratorInfoOpt == null ? default : ResultType;
11931
VisitDeconstructionAssignmentOperator(assignment, sourceState.HasNullType ? (
TypeWithState
?)null : sourceState);
11945
TypeWithState
result = sourceState;
11946
TypeWithState
resultForType = sourceState;
12037
private
TypeWithState
VisitBadExpressionChild(BoundExpression? child)
12079
TypeWithState
resultType;
12111
var
operandResult = ResultType;
12113
var
operandType = GetNullableUnderlyingTypeIfNecessary(isLifted, operandResult);
12144
TypeWithState
adjustForLifting(
TypeWithState
argumentResult) =>
12145
TypeWithState
.Create(node.Type, node.OperatorKind.IsLifted() ? argumentResult.State : NullableFlowState.NotNull);
12151
private MethodSymbol ReInferUnaryOperator(SyntaxNode syntax, MethodSymbol method, BoundExpression operand,
TypeWithState
operandType)
12286
TypeWithState
leftType = ResultType;
12295
TypeWithState
rightType = ResultType;
12302
TypeWithState
leftType = ResultType;
12317
var
rightType = ResultType;
12325
TypeWithState
leftUnderlyingType = GetNullableUnderlyingTypeIfNecessary(isLifted, leftType);
12326
TypeWithState
rightUnderlyingType = GetNullableUnderlyingTypeIfNecessary(isLifted, rightType);
12413
SetResultType(node,
TypeWithState
.Create(node.Type, NullableFlowState.NotNull));
12435
SetResultType(node,
TypeWithState
.Create(node.Type, NullableFlowState.MaybeDefault));
12455
SetResultType(node,
TypeWithState
.ForType(type));
12495
var
argumentType = VisitRvalueWithState(node.Operand);
12517
SetResultType(node,
TypeWithState
.Create(type, resultState));
12549
SetResultType(node,
TypeWithState
.Create(node.Type, node.Type?.CanContainNull() != false && node.ConstantValueOpt?.IsNull == true ? NullableFlowState.MaybeDefault : NullableFlowState.NotNull));
12624
if (TryGetMethodGroupReceiverNullability(receiverOpt, out
TypeWithState
receiverType))
12726
SetResultType(expression,
TypeWithState
.Create(expression.Type, default));
12748
private bool CheckPossibleNullReceiver(BoundExpression? receiverOpt,
TypeWithState
resultType, bool checkNullableValueType)
12792
private void CheckExtensionMethodThisNullability(BoundExpression expr, Conversion conversion, ParameterSymbol parameter,
TypeWithState
result)
12833
SetResultType(node,
TypeWithState
.Create(node.Type, NullableFlowState.NotNull));
12848
SetResultType(node,
TypeWithState
.Create(node.Type, NullableFlowState.NotNull));
12897
SetResultType(node,
TypeWithState
.Create(node.Type, NullableFlowState.NotNull));
12903
SetResultType(node,
TypeWithState
.Create(type, NullableFlowState.NotNull));
12910
var
rValueType =
TypeWithState
.ForType(node.Type);
12932
var
result = VisitRvalueWithState(expr);
13062
Debug.Assert(ResultType is
TypeWithState
{ Type: FunctionPointerTypeSymbol { }, State: NullableFlowState.NotNull });
FlowAnalysis\NullableWalker_Patterns.cs (16)
298
var
expressionState = ResultType;
378
TypeWithState
expressionTypeWithState,
685
var
value =
TypeWithState
.Create(tempType, tempState);
697
TrackNullableStateForAssignment(valueOpt: null, inferredType, localSlot,
TypeWithState
.Create(tempType, tempState), tempSlot);
893
var
expressionState = ResultType;
916
var resultTypes = ArrayBuilder<
TypeWithState
>.GetInstance(numSwitchArms);
937
var
armType = VisitRvalueWithState(expression);
959
TypeWithState
resultType;
972
resultType =
TypeWithState
.Create(inferredType, inferredState);
987
TypeWithState
convertArms(
991
ArrayBuilder<
TypeWithState
> resultTypes,
1022
TypeWithState
resultType =
TypeWithState
.Create(inferredTypeWithAnnotations.Type, inferredState);
1036
ArrayBuilder<
TypeWithState
> resultTypes,
1061
var
expressionState = ResultType;
Symbols\TypeWithAnnotations.cs (2)
805
internal
TypeWithState
ToTypeWithState()
811
return
TypeWithState
.Create(Type, getFlowState(Type, NullableAnnotation));
Symbols\TypeWithState.cs (5)
23
public static
TypeWithState
ForType(TypeSymbol? type)
28
public static
TypeWithState
Create(TypeSymbol? type, NullableFlowState defaultState)
40
public static
TypeWithState
Create(TypeWithAnnotations typeWithAnnotations, FlowAnalysisAnnotations annotations = FlowAnalysisAnnotations.None)
81
public
TypeWithState
WithNotNullState() => new TypeWithState(Type, NullableFlowState.NotNull);
83
public
TypeWithState
WithSuppression(bool suppress) => suppress ? new TypeWithState(Type, NullableFlowState.NotNull) : this;
Microsoft.CodeAnalysis.CSharp.Test.Utilities (1)
CompilationTestUtils.cs (1)
483
var type =
TypeWithState
.Create(