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;
344 references to TypeWithState
Microsoft.CodeAnalysis.CSharp (344)
Binder\Binder_Patterns.cs (1)
2094
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 (315)
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, int, 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)
2376
private
TypeWithState
VisitRvalueWithState(BoundExpression? node)
2420
/// This should often be checked together with <seealso cref="IsDisallowedNullAssignment(
TypeWithState
, FlowAnalysisAnnotations)"/>
2460
TypeWithState
valueType,
2515
static bool isMaybeDefaultValue(
TypeWithState
valueType)
2552
var
valueState = GetParameterState(
2591
var
valueWhen = ApplyUnconditionalAnnotations(
2605
static bool isBadAssignment(
TypeWithState
valueState, TypeWithAnnotations destinationType, FlowAnalysisAnnotations destinationAnnotations)
2683
TypeWithState
valueType,
2724
static bool areEquivalentTypes(TypeWithAnnotations target,
TypeWithState
assignedValue) =>
3077
var
resultType = VisitOptionalImplicitConversion(
3091
internal static
TypeWithState
GetParameterState(TypeWithAnnotations parameterType, FlowAnalysisAnnotations parameterAnnotations)
3095
return
TypeWithState
.Create(parameterType.Type, NullableFlowState.MaybeDefault);
3100
return
TypeWithState
.Create(parameterType.Type, NullableFlowState.NotNull);
3131
TypeWithState
returnState;
3148
var
result = VisitRvalueWithState(expr);
3180
private
TypeWithState
VisitRefExpression(BoundExpression expr, TypeWithAnnotations destinationType)
3183
TypeWithState
resultType = ResultType;
3250
SetResultType(node,
TypeWithState
.ForType(node.Type));
3620
var
resultState = ApplyUnconditionalAnnotations(resultType.ToTypeWithState(), GetRValueAnnotations(withExpr.CloneMethod));
3746
TypeWithState
valueType;
3795
TypeWithState
resultType = ResultType;
3805
var
result = resultType.WithNotNullState();
3927
SetResultType(node,
TypeWithState
.Create(null, NullableFlowState.NotNull));
3935
SetResultType(node,
TypeWithState
.Create(null, NullableFlowState.NotNull));
3980
var visitResult = new VisitResult(
TypeWithState
.Create(resultType), resultType,
4187
TypeWithState
convertCollection(
4214
var
resultTypeWithState =
TypeWithState
.Create(strippedTargetCollectionType, resultState);
4320
TypeWithState
result = setAnalyzedNullability(node, type, argumentResults, argumentsCompletion, initialStateInferenceCompletion, initializerCompletion, resultState, isTargetTyped);
4324
TypeWithState
setAnalyzedNullability(
4334
var
result =
TypeWithState
.Create(type, resultState);
4503
private void SetUnionValueStateFromConstructorArgument(BoundExpression argument,
TypeWithState
argumentTypeWithState, int containingSlot, PropertySymbol valueProperty)
4738
InitializerCompletionAfterUpdatedSymbol? visitMemberAssignment(BoundAssignmentOperator node, int containingSlot, Symbol symbol, bool delayCompletionForType, Func<TypeWithAnnotations,
TypeWithState
>? conversionCompletion = null)
4751
(
TypeWithState
resultType, conversionCompletion) =
4771
InitializerCompletionAfterUpdatedSymbol? visitMemberAssignmentAsContinuation(BoundAssignmentOperator node, Func<TypeWithAnnotations,
TypeWithState
> conversionCompletion)
4932
TypeWithState
.Create(containingType, receiverResult.RValueType.State),
4952
SetResultType(node,
TypeWithState
.Create(node.Type, NullableFlowState.NotNull));
4957
var
resultType =
TypeWithState
.Create(node.Type, NullableFlowState.NotNull);
5046
var
argumentType = argumentTypes[i];
5065
SetResultType(node,
TypeWithState
.Create(anonymousType, NullableFlowState.NotNull));
5097
SetResultType(node,
TypeWithState
.Create(node.Type, NullableFlowState.NotNull));
5102
SetResultType(node,
TypeWithState
.Create(arrayType, NullableFlowState.NotNull));
5136
var expressionTypes = ArrayBuilder<
TypeWithState
>.GetInstance(n);
5145
var
expressionType = VisitRvalueWithState(expressionNoConversion);
5179
inferredType =
TypeWithState
.Create(inferredType.Type, elementState).ToTypeWithAnnotations(compilation);
5378
private
TypeWithState
InferResultNullability(BinaryOperatorKind operatorKind, MethodSymbol? methodOpt, TypeSymbol resultType,
TypeWithState
leftType,
TypeWithState
rightType)
5390
var
resultTypeWithState = GetReturnTypeWithState(methodOpt);
5421
return
TypeWithState
.Create(resultType, resultState);
5438
var
leftType = ResultType;
5465
var
rightType = VisitRvalueWithState(rightOperand);
5508
static bool isKnownNullOrNotNull(BoundExpression expr,
TypeWithState
resultType)
5543
var
leftResult = ResultType;
5596
SetResult(binary,
TypeWithState
.ForType(binary.Type), TypeWithAnnotations.Create(binary.Type));
5604
TypeWithState
leftType,
5607
TypeWithState
rightType,
5610
var
inferredResult = ReinferAndVisitBinaryOperator(binary, binary.OperatorKind, binary.BinaryOperatorMethod, binary.Type, binary.Left, leftOperand, leftConversion, leftType, binary.Right, rightOperand, rightConversion, rightType);
5614
private
TypeWithState
ReinferAndVisitBinaryOperator(
5622
TypeWithState
leftType,
5626
TypeWithState
rightType)
5636
TypeWithState
leftUnderlyingType = GetNullableUnderlyingTypeIfNecessary(isLifted, leftType);
5637
TypeWithState
rightUnderlyingType = GetNullableUnderlyingTypeIfNecessary(isLifted, rightType);
5659
TypeWithState
operandType)
5692
var
inferredResult = InferResultNullability(operatorKind, method, returnType, leftType, rightType);
5702
TypeWithState
leftUnderlyingType,
5703
TypeWithState
rightUnderlyingType)
5768
private
TypeWithState
VisitBinaryOperatorOperandConversion(
5769
BoundExpression expr, BoundExpression operand, Conversion conversion, ParameterSymbol parameter,
TypeWithState
operandType, bool isLifted,
5793
private void VisitBinaryOperatorOperandConversionAndPostConditions(BoundExpression expr, BoundExpression operand, Conversion conversion, ParameterSymbol parameter,
TypeWithState
operandType, bool isLifted)
5796
TypeWithState
resultType = VisitBinaryOperatorOperandConversion(expr, operand, conversion, parameter, operandType, isLifted, out parameterAnnotations);
5812
var
leftType = ResultType;
5817
var
rightType = ResultType;
6171
TypeWithState
rightResult = VisitOptionalImplicitConversion(rightOperand, targetType, useLegacyWarnings: UseLegacyWarnings(leftOperand), trackMembers: false, AssignmentKind.Assignment);
6176
TypeWithState
resultType =
TypeWithState
.Create(targetType.Type, rightResult.State);
6192
var
rightUnconditionalResult = ResultType;
6195
SetResultType(node,
TypeWithState
.Create(node.Type, rightUnconditionalResult.State));
6200
TypeWithState
leftResult = ResultType;
6211
TypeWithState
rightResult = ResultType;
6229
SetResultType(node,
TypeWithState
.Create(resultType, rightResult.State.Join(leftState)));
6257
var
conversionResult = VisitConversion(
6264
TypeWithState
.Create(leftType, NullableFlowState.NotNull),
6296
var
operandType = ResultType;
6301
var
result = VisitConversion(boundConversion,
6448
SetResultType(node,
TypeWithState
.Create(resultType, NullableFlowState.MaybeDefault));
6484
TypeWithState
consequenceRValue;
6485
TypeWithState
alternativeRValue;
6524
SetResult(node,
TypeWithState
.Create(refResultType, rValueState), TypeWithAnnotations.Create(refResultType, lValueAnnotation));
6588
SetResultType(node,
TypeWithState
.Create(resultType, default));
6599
TypeWithState
typeWithState = convertArms(
6606
TypeWithState
convertArms(
6608
TypeWithState
consequenceRValue,
TypeWithState
alternativeRValue, BoundExpression consequence, Conversion consequenceConversion, bool consequenceEndReachable,
6614
TypeWithState
convertedConsequenceResult = ConvertConditionalOperandOrSwitchExpressionArmResult(
6623
TypeWithState
convertedAlternativeResult = ConvertConditionalOperandOrSwitchExpressionArmResult(
6633
var
typeWithState =
TypeWithState
.Create(resultTypeWithAnnotations.Type, resultState);
6646
return
TypeWithState
.Create(resultTypeWithAnnotations.Type, resultState);
6656
TypeWithState
consequenceRValue,
6657
TypeWithState
alternativeRValue,
6675
(BoundExpression, Conversion,
TypeWithState
) visitConditionalOperand(LocalState state, BoundExpression operand)
6688
(TypeWithAnnotations LValueType,
TypeWithState
RValueType) visitConditionalRefOperand(LocalState state, BoundExpression operand)
6705
private
TypeWithState
ConvertConditionalOperandOrSwitchExpressionArmResult(
6710
TypeWithState
operandType,
6727
var
resultType = VisitConversion(
6771
SetResultType(node,
TypeWithState
.Create(rvalueType, NullableFlowState.NotNull));
6797
TypeWithState
receiverType = visitAndCheckReceiver(node);
6871
TypeWithState
receiverType = visitAndCheckReceiver(node);
6899
TypeWithState
visitAndCheckReceiver(BoundCall node)
6909
void reinferMethodAndVisitArguments(BoundCall node,
TypeWithState
receiverType, VisitResult? firstArgumentResult = null)
6950
var
returnState = GetReturnTypeWithState(method);
6961
private
TypeWithState
VisitAndCheckReceiver(BoundExpression? receiverOpt, MethodSymbol method)
6963
TypeWithState
receiverType = default;
6978
TypeWithState
receiverType,
7117
private void LearnFromEqualsMethod(MethodSymbol method, BoundCall node,
TypeWithState
receiverType, ImmutableArray<VisitResult> results)
7253
void learnFromEqualsMethodArguments(BoundExpression left,
TypeWithState
leftType, BoundExpression right,
TypeWithState
rightType)
7354
private void CheckCallReceiver(BoundExpression? receiverOpt,
TypeWithState
receiverType, MethodSymbol method)
7387
private
TypeWithState
GetReturnTypeWithState(MethodSymbol method)
7389
return
TypeWithState
.Create(method.ReturnTypeWithAnnotations, GetRValueAnnotations(method));
7459
private static
TypeWithState
ApplyUnconditionalAnnotations(
TypeWithState
typeWithState, FlowAnalysisAnnotations annotations)
7463
return
TypeWithState
.Create(typeWithState.Type, NullableFlowState.NotNull);
7468
return
TypeWithState
.Create(typeWithState.Type, NullableFlowState.MaybeDefault);
7803
TrackAnalyzedNullabilityThroughConversionGroup(
TypeWithState
.Create(argument.Type, result.RValueType.State), argument as BoundConversion, argumentNoConversion);
8234
var
resultType = result.RValueType;
8252
var
stateAfterConversion = VisitConversion(
8307
private bool CheckDisallowedNullAssignment(
TypeWithState
state, FlowAnalysisAnnotations annotations, SyntaxNode node, BoundExpression? boundValueOpt = null)
8325
private static bool IsDisallowedNullAssignment(
TypeWithState
valueState, FlowAnalysisAnnotations targetAnnotations)
8384
var
parameterWithState =
TypeWithState
.Create(parameterType, parameterAnnotations);
8388
parameterWithState =
TypeWithState
.Create(parameterType.Type, adjustedState);
8411
var
parameterWithState =
TypeWithState
.Create(parameterType, parameterAnnotations);
8414
var
worstCaseParameterWithState = applyPostConditionsUnconditionally(parameterWithState, parameterAnnotations);
8475
void trackNullableStateForAssignment(TypeSymbol? receiverType, BoundExpression parameterValue, TypeWithAnnotations lValueType, int targetSlot,
TypeWithState
parameterWithState, bool isSuppressed, FlowAnalysisAnnotations parameterAnnotations, RefKind refKind, ParameterSymbol parameter)
8525
static
TypeWithState
applyPostConditionsUnconditionally(
TypeWithState
typeWithState, FlowAnalysisAnnotations annotations)
8530
return
TypeWithState
.Create(typeWithState.Type, NullableFlowState.MaybeDefault);
8536
return
TypeWithState
.Create(typeWithState.Type, NullableFlowState.NotNull);
8542
static
TypeWithState
applyPostConditionsWhenTrue(TypeSymbol? receiverType,
TypeWithState
typeWithState, FlowAnalysisAnnotations annotations, RefKind refKind, ParameterSymbol parameter)
8551
return
TypeWithState
.Create(typeWithState.Type, NullableFlowState.MaybeDefault);
8555
return
TypeWithState
.Create(typeWithState.Type, NullableFlowState.NotNull);
8561
static
TypeWithState
applyPostConditionsWhenFalse(
TypeWithState
typeWithState, FlowAnalysisAnnotations annotations)
8570
return
TypeWithState
.Create(typeWithState.Type, NullableFlowState.MaybeDefault);
8574
return
TypeWithState
.Create(typeWithState.Type, NullableFlowState.NotNull);
8862
if (_walker.TryGetMethodGroupReceiverNullability(group.ReceiverOpt, out
TypeWithState
receiverType))
9139
private
TypeWithState
GetAdjustedResult(
TypeWithState
type, int slot)
9144
return
TypeWithState
.Create(type.Type, state);
9300
private
TypeWithState
VisitOptionalImplicitConversion(BoundExpression expr, TypeWithAnnotations targetTypeOpt, bool useLegacyWarnings, bool trackMembers, AssignmentKind assignmentKind)
9312
private (
TypeWithState
resultType, Func<TypeWithAnnotations,
TypeWithState
>? completion) VisitOptionalImplicitConversion(
9322
var
operandType = VisitRvalueWithState(operand);
9326
(
TypeWithState
resultType, Func<TypeWithAnnotations,
TypeWithState
>? completion) visitConversion(
9331
Conversion conversion,
TypeWithState
operandType,
9336
return (
TypeWithState
.Create(targetTypeOpt), visitConversionAsContinuation(expr, useLegacyWarnings, trackMembers, assignmentKind, operand, conversion, operandType));
9346
var
resultType = VisitConversion(
9363
Func<TypeWithAnnotations,
TypeWithState
> visitConversionAsContinuation(BoundExpression expr, bool useLegacyWarnings, bool trackMembers, AssignmentKind assignmentKind, BoundExpression operand, Conversion conversion,
TypeWithState
operandType)
9413
ImmutableArray<
TypeWithState
> elementTypes = arguments.SelectAsArray((a, w) => w.VisitRvalueWithState(a), this);
9418
SetResultType(node,
TypeWithState
.Create(null, NullableFlowState.NotNull));
9443
SetResultType(node,
TypeWithState
.Create(tupleOpt, NullableFlowState.NotNull));
9456
ImmutableArray<
TypeWithState
> types,
9486
void trackState(BoundExpression value, FieldSymbol field,
TypeWithState
valueType)
9500
private void TrackNullableStateOfNullableValue(int containingSlot, TypeSymbol containingType, BoundExpression? value,
TypeWithState
valueType, int valueSlot)
9595
var
convertedType = VisitUserDefinedConversion(
9620
TypeWithState
valueFieldType = ApplyUnconditionalAnnotations(valueField.TypeWithAnnotations.ToTypeWithState(), GetRValueAnnotations(valueField));
9627
valueFieldType =
TypeWithState
.Create(valueFieldType.Type, GetState(ref this.State, valueFieldSlot));
9645
TypeWithState
convertedType = VisitUnionConversion(
9825
private
TypeWithState
VisitConversion(
9830
TypeWithState
operandType,
9852
if (TargetTypedAnalysisCompletion.TryGetValue(conversionOperand, out Func<TypeWithAnnotations,
TypeWithState
>? completion))
9935
return
TypeWithState
.Create(targetType, NullableFlowState.NotNull);
10207
TypeWithState
resultType = calculateResultType(targetTypeWithNullability, fromExplicitCast, resultState, isSuppressed, targetType);
10241
static
TypeWithState
calculateResultType(TypeWithAnnotations targetTypeWithNullability, bool fromExplicitCast, NullableFlowState resultState, bool isSuppressed, TypeSymbol targetType)
10253
var
resultType =
TypeWithState
.Create(targetType, resultState);
10257
static NullableFlowState getReferenceConversionResultState(TypeWithAnnotations targetType,
TypeWithState
operandType)
10291
static NullableFlowState getBoxingConversionResultState(TypeWithAnnotations targetType,
TypeWithState
operandType)
10319
static NullableFlowState getUnboxingConversionResultState(
TypeWithState
operandType)
10329
static NullableFlowState getConversionResultState(
TypeWithState
operandType)
10445
private
TypeWithState
VisitUserDefinedConversion(
10450
TypeWithState
operandType,
10469
var
resultType =
TypeWithState
.Create(targetType, NullableFlowState.NotNull);
10501
TypeWithState
underlyingOperandType = default;
10577
private
TypeWithState
GetConversionReturnTypeWithState(MethodSymbol method, bool isLiftedConversion, NullableFlowState operandState)
10580
TypeWithState
returnType = GetLiftedReturnTypeIfNecessary(isLiftedConversion, methodReturnType, operandState);
10597
private
TypeWithState
VisitUnionConversion(
10602
TypeWithState
operandType,
10621
var
resultType =
TypeWithState
.Create(targetTypeWithNullability.Type, NullableFlowState.NotNull);
10705
TypeWithState
unionTypeWithState;
10710
unionTypeWithState =
TypeWithState
.Create(toType, NullableFlowState.NotNull);
10776
private void TrackAnalyzedNullabilityThroughConversionGroup(
TypeWithState
resultType, BoundConversion? conversionOpt, BoundExpression convertedNode)
10804
private
TypeWithState
GetLiftedReturnType(TypeWithAnnotations returnType, NullableFlowState operandState)
10809
return
TypeWithState
.Create(type, state);
10812
private static
TypeWithState
GetNullableUnderlyingTypeIfNecessary(bool isLifted,
TypeWithState
typeWithState)
10825
private
TypeWithState
GetLiftedReturnTypeIfNecessary(bool isLifted, TypeWithAnnotations returnType, NullableFlowState operandState)
10837
private
TypeWithState
ClassifyAndVisitConversion(
10840
TypeWithState
operandType,
10915
TypeWithState
result = setAnalyzedNullability(node, delegateType, analysisCompletion, node.WasTargetTyped);
10919
TypeWithState
setAnalyzedNullability(BoundDelegateCreationExpression node, NamedTypeSymbol delegateType, Action<NamedTypeSymbol>? analysisCompletion, bool isTargetTyped)
10921
var
result =
TypeWithState
.Create(delegateType, NullableFlowState.NotNull);
11021
var
argState = VisitRvalueWithState(arg);
11074
private bool TryGetMethodGroupReceiverNullability([NotNullWhen(true)] BoundExpression? receiverOpt, out
TypeWithState
type)
11089
private void SetMethodGroupReceiverNullability(BoundExpression receiver,
TypeWithState
type)
11091
_methodGroupReceiverMapOpt ??= PooledDictionary<BoundExpression,
TypeWithState
>.GetInstance();
11100
if (TryGetMethodGroupReceiverNullability(receiverOpt, out
TypeWithState
receiverType))
11218
var
rvalueResult =
TypeWithState
.Create(node.Type, NullableFlowState.NotNull);
11228
var
typeWithState = GetParameterState(parameterType, parameter.FlowAnalysisAnnotations);
11271
TypeWithState
rightState;
11294
SetResult(node,
TypeWithState
.Create(leftLValueType.Type, rightState.State), leftLValueType);
11314
var
rValueType = ApplyUnconditionalAnnotations(type.ToTypeWithState(), annotations);
11323
private void AdjustSetValue(BoundExpression left, ref
TypeWithState
rightState)
11415
private BoundNode? VisitDeconstructionAssignmentOperator(BoundDeconstructionAssignmentOperator node,
TypeWithState
? rightResultOpt)
11445
private void VisitDeconstructionArguments(ArrayBuilder<DeconstructionVariable> variables, Conversion conversion, BoundExpression right,
TypeWithState
? rightResultOpt = null)
11459
private void VisitDeconstructMethodArguments(ArrayBuilder<DeconstructionVariable> variables, Conversion conversion, BoundExpression right,
TypeWithState
? rightResultOpt)
11468
var
rightResult = ResultType;
11560
private void VisitTupleDeconstructionArguments(ArrayBuilder<DeconstructionVariable> variables, ImmutableArray<(BoundValuePlaceholder? placeholder, BoundExpression? conversion)> deconstructConversionInfo, BoundExpression right,
TypeWithState
? rightResultOpt)
11583
TypeWithState
operandType;
11584
TypeWithState
valueType;
11636
var
valueBeforeNullableWrapping =
TypeWithState
.Create(underlyingType.Type, NullableFlowState.NotNull);
11693
private ImmutableArray<BoundExpression> GetDeconstructionRightParts(BoundExpression expr,
TypeWithState
? rightResultOpt)
11746
TypeWithState
receiverType = VisitAndCheckReceiver(node.Operand, instanceMethod);
11769
SetResultType(node,
TypeWithState
.Create(receiverType.Type, NullableFlowState.NotNull));
11773
SetResultType(node,
TypeWithState
.Create(results[0].RValueType.Type, GetState(ref State, extensionReceiverSlot)));
11785
var
opType = VisitRvalueWithState(node.Operand);
11793
SetResultType(node,
TypeWithState
.Create(opType.Type, NullableFlowState.NotNull));
11800
var
operandType = VisitRvalueWithState(node.Operand);
11856
TypeWithState
resultOfOperandConversionType;
11880
TypeWithState
resultOfIncrementType;
11906
TypeWithState
resultType = (op == UnaryOperatorKind.PrefixIncrement || op == UnaryOperatorKind.PrefixDecrement) ? resultOfIncrementType : operandType;
11939
TypeWithState
receiverType = VisitAndCheckReceiver(node.Left, instanceMethod);
11962
SetResultType(node,
TypeWithState
.Create(receiverType.Type, NullableFlowState.NotNull));
11966
SetResultType(node,
TypeWithState
.Create(results[0].RValueType.Type, GetState(ref State, extensionReceiverSlot)));
11979
var
opType = ResultType;
11990
SetResultType(node,
TypeWithState
.Create(opType.Type, NullableFlowState.NotNull));
12000
var
leftTypeWithState = ResultType;
12008
var
rightTypeWithState = VisitRvalueWithState(rightConversionOperand);
12015
var
resultTypeWithState = ReinferAndVisitBinaryOperator(
12068
SetResultType(node.Expression,
TypeWithState
.Create(node.Expression.Type, ResultType.State));
12199
TypeWithState
typeWithState = ApplyUnconditionalAnnotations(typeWithAnnotations.ToTypeWithState(), memberAnnotations);
12252
var
resultType = ApplyUnconditionalAnnotations(indexer.TypeWithAnnotations.ToTypeWithState(), GetRValueAnnotations(indexer));
12316
var
receiverType = (receiverOpt != null) ? VisitRvalueWithState(receiverOpt) : default;
12340
var
resultType = ApplyUnconditionalAnnotations(type.ToTypeWithState(), memberAnnotations);
12350
resultType =
TypeWithState
.Create(resultType.Type, state);
12462
var
resultTypeWithState = VisitRvalueWithState(expr);
12532
var
convertedResult = VisitConversion(
12550
TypeWithState
currentPropertyGetterTypeWithState;
12591
var
enumeratorReturnType = GetReturnTypeWithState(reinferredGetEnumeratorMethod);
12637
var
sourceState = node.EnumeratorInfoOpt == null ? default : ResultType;
12654
VisitDeconstructionAssignmentOperator(assignment, sourceState.HasNullType ? (
TypeWithState
?)null : sourceState);
12668
TypeWithState
result = sourceState;
12669
TypeWithState
resultForType = sourceState;
12760
private
TypeWithState
VisitBadExpressionChild(BoundExpression? child)
12802
TypeWithState
resultType;
12834
var
operandResult = ResultType;
12836
var
operandType = GetNullableUnderlyingTypeIfNecessary(isLifted, operandResult);
12867
TypeWithState
adjustForLifting(
TypeWithState
argumentResult) =>
12868
TypeWithState
.Create(node.Type, node.OperatorKind.IsLifted() ? argumentResult.State : NullableFlowState.NotNull);
12874
private MethodSymbol ReInferUnaryOperator(SyntaxNode syntax, MethodSymbol method, BoundExpression operand,
TypeWithState
operandType)
13009
TypeWithState
leftType = ResultType;
13018
TypeWithState
rightType = ResultType;
13025
TypeWithState
leftType = ResultType;
13040
var
rightType = ResultType;
13048
TypeWithState
leftUnderlyingType = GetNullableUnderlyingTypeIfNecessary(isLifted, leftType);
13049
TypeWithState
rightUnderlyingType = GetNullableUnderlyingTypeIfNecessary(isLifted, rightType);
13134
SetResultType(node,
TypeWithState
.Create(node.Type, NullableFlowState.NotNull));
13156
SetResultType(node,
TypeWithState
.Create(node.Type, NullableFlowState.MaybeDefault));
13176
SetResultType(node,
TypeWithState
.ForType(type));
13216
var
argumentType = VisitRvalueWithState(node.Operand);
13238
SetResultType(node,
TypeWithState
.Create(type, resultState));
13270
SetResultType(node,
TypeWithState
.Create(node.Type, node.Type?.CanContainNull() != false && node.ConstantValueOpt?.IsNull == true ? NullableFlowState.MaybeDefault : NullableFlowState.NotNull));
13345
if (TryGetMethodGroupReceiverNullability(receiverOpt, out
TypeWithState
receiverType))
13447
SetResultType(expression,
TypeWithState
.Create(expression.Type, default));
13469
private bool CheckPossibleNullReceiver(BoundExpression? receiverOpt,
TypeWithState
resultType, bool checkNullableValueType)
13513
private void CheckExtensionMethodThisNullability(BoundExpression expr, Conversion conversion, ParameterSymbol parameter,
TypeWithState
result)
13554
SetResultType(node,
TypeWithState
.Create(node.Type, NullableFlowState.NotNull));
13569
SetResultType(node,
TypeWithState
.Create(node.Type, NullableFlowState.NotNull));
13618
SetResultType(node,
TypeWithState
.Create(node.Type, NullableFlowState.NotNull));
13624
SetResultType(node,
TypeWithState
.Create(type, NullableFlowState.NotNull));
13631
var
rValueType =
TypeWithState
.ForType(node.Type);
13653
var
result = VisitRvalueWithState(expr);
13834
Debug.Assert(ResultType is
TypeWithState
{ Type: FunctionPointerTypeSymbol { }, State: NullableFlowState.NotNull });
FlowAnalysis\NullableWalker_Patterns.cs (19)
301
var
expressionState = ResultType;
381
TypeWithState
expressionTypeWithState,
527
var
inputTypeWithState =
TypeWithState
.Create(inputType, inputState);
634
var
value =
TypeWithState
.Create(tempType, tempState);
646
TrackNullableStateForAssignment(valueOpt: null, inferredType, localSlot,
TypeWithState
.Create(tempType, tempState), tempSlot);
999
receiverType:
TypeWithState
.Create(inputType, NullableFlowState.NotNull),
1080
var
expressionState = ResultType;
1108
var resultTypes = ArrayBuilder<
TypeWithState
>.GetInstance(numSwitchArms);
1129
var
armType = VisitRvalueWithState(expression);
1151
TypeWithState
resultType;
1164
resultType =
TypeWithState
.Create(inferredType, inferredState);
1179
TypeWithState
convertArms(
1183
ArrayBuilder<
TypeWithState
> resultTypes,
1214
TypeWithState
resultType =
TypeWithState
.Create(inferredTypeWithAnnotations.Type, inferredState);
1228
ArrayBuilder<
TypeWithState
> resultTypes,
1253
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;