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;
333 references to TypeWithState
Microsoft.CodeAnalysis.CSharp (332)
Binder\Binder_Patterns.cs (1)
1358
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 (306)
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)
2339
private
TypeWithState
VisitRvalueWithState(BoundExpression? node)
2383
/// This should often be checked together with <seealso cref="IsDisallowedNullAssignment(
TypeWithState
, FlowAnalysisAnnotations)"/>
2423
TypeWithState
valueType,
2478
static bool isMaybeDefaultValue(
TypeWithState
valueType)
2515
var
valueState = GetParameterState(
2554
var
valueWhen = ApplyUnconditionalAnnotations(
2568
static bool isBadAssignment(
TypeWithState
valueState, TypeWithAnnotations destinationType, FlowAnalysisAnnotations destinationAnnotations)
2646
TypeWithState
valueType,
2687
static bool areEquivalentTypes(TypeWithAnnotations target,
TypeWithState
assignedValue) =>
3032
var
resultType = VisitOptionalImplicitConversion(
3046
internal static
TypeWithState
GetParameterState(TypeWithAnnotations parameterType, FlowAnalysisAnnotations parameterAnnotations)
3050
return
TypeWithState
.Create(parameterType.Type, NullableFlowState.MaybeDefault);
3055
return
TypeWithState
.Create(parameterType.Type, NullableFlowState.NotNull);
3086
TypeWithState
returnState;
3103
var
result = VisitRvalueWithState(expr);
3135
private
TypeWithState
VisitRefExpression(BoundExpression expr, TypeWithAnnotations destinationType)
3138
TypeWithState
resultType = ResultType;
3207
SetResultType(node,
TypeWithState
.ForType(node.Type));
3576
var
resultState = ApplyUnconditionalAnnotations(resultType.ToTypeWithState(), GetRValueAnnotations(withExpr.CloneMethod));
3675
TypeWithState
valueType;
3724
TypeWithState
resultType = ResultType;
3734
var
result = resultType.WithNotNullState();
3856
SetResultType(node,
TypeWithState
.Create(null, NullableFlowState.NotNull));
3864
SetResultType(node,
TypeWithState
.Create(null, NullableFlowState.NotNull));
3877
var elementConversionCompletions = ArrayBuilder<Func<TypeWithAnnotations /*targetElementType*/, TypeSymbol /*targetCollectionType*/,
TypeWithState
>>.GetInstance();
3899
var visitResult = new VisitResult(
TypeWithState
.Create(resultType), resultType,
3905
void visitElement(BoundNode element, BoundCollectionExpression node, TypeWithAnnotations targetElementType, ArrayBuilder<Func<TypeWithAnnotations, TypeSymbol,
TypeWithState
>> elementConversionCompletions)
3939
var
resultType = VisitConversion(
3997
TypeWithState
convertCollection(BoundCollectionExpression node, TypeWithAnnotations targetCollectionType, ArrayBuilder<Func<TypeWithAnnotations, TypeSymbol,
TypeWithState
>> completions)
4019
var
resultTypeWithState =
TypeWithState
.Create(strippedTargetCollectionType, resultState);
4114
TypeWithState
result = setAnalyzedNullability(node, type, argumentResults, argumentsCompletion, initialStateInferenceCompletion, initializerCompletion, resultState, isTargetTyped);
4118
TypeWithState
setAnalyzedNullability(
4128
var
result =
TypeWithState
.Create(type, resultState);
4527
Action<int, Symbol>? visitMemberAssignment(BoundAssignmentOperator node, int containingSlot, Symbol symbol, bool delayCompletionForType, Func<TypeWithAnnotations,
TypeWithState
>? conversionCompletion = null)
4540
(
TypeWithState
resultType, conversionCompletion) =
4560
Action<int, Symbol>? visitMemberAssignmentAsContinuation(BoundAssignmentOperator node, Func<TypeWithAnnotations,
TypeWithState
> conversionCompletion)
4668
TypeWithState
.Create(containingType, receiverResult.RValueType.State),
4688
SetResultType(node,
TypeWithState
.Create(node.Type, NullableFlowState.NotNull));
4693
var
resultType =
TypeWithState
.Create(node.Type, NullableFlowState.NotNull);
4782
var
argumentType = argumentTypes[i];
4801
SetResultType(node,
TypeWithState
.Create(anonymousType, NullableFlowState.NotNull));
4833
SetResultType(node,
TypeWithState
.Create(node.Type, NullableFlowState.NotNull));
4838
SetResultType(node,
TypeWithState
.Create(arrayType, NullableFlowState.NotNull));
4872
var expressionTypes = ArrayBuilder<
TypeWithState
>.GetInstance(n);
4881
var
expressionType = VisitRvalueWithState(expressionNoConversion);
4915
inferredType =
TypeWithState
.Create(inferredType.Type, elementState).ToTypeWithAnnotations(compilation);
5114
private
TypeWithState
InferResultNullability(BinaryOperatorKind operatorKind, MethodSymbol? methodOpt, TypeSymbol resultType,
TypeWithState
leftType,
TypeWithState
rightType)
5126
var
resultTypeWithState = GetReturnTypeWithState(methodOpt);
5157
return
TypeWithState
.Create(resultType, resultState);
5174
var
leftType = ResultType;
5201
var
rightType = VisitRvalueWithState(rightOperand);
5244
static bool isKnownNullOrNotNull(BoundExpression expr,
TypeWithState
resultType)
5279
var
leftResult = ResultType;
5332
SetResult(binary,
TypeWithState
.ForType(binary.Type), TypeWithAnnotations.Create(binary.Type));
5340
TypeWithState
leftType,
5343
TypeWithState
rightType,
5346
var
inferredResult = ReinferAndVisitBinaryOperator(binary, binary.OperatorKind, binary.Method, binary.Type, binary.Left, leftOperand, leftConversion, leftType, binary.Right, rightOperand, rightConversion, rightType);
5350
private
TypeWithState
ReinferAndVisitBinaryOperator(
5358
TypeWithState
leftType,
5362
TypeWithState
rightType)
5372
TypeWithState
leftUnderlyingType = GetNullableUnderlyingTypeIfNecessary(isLifted, leftType);
5373
TypeWithState
rightUnderlyingType = GetNullableUnderlyingTypeIfNecessary(isLifted, rightType);
5395
TypeWithState
operandType)
5428
var
inferredResult = InferResultNullability(operatorKind, method, returnType, leftType, rightType);
5438
TypeWithState
leftUnderlyingType,
5439
TypeWithState
rightUnderlyingType)
5504
private
TypeWithState
VisitBinaryOperatorOperandConversion(
5505
BoundExpression expr, BoundExpression operand, Conversion conversion, ParameterSymbol parameter,
TypeWithState
operandType, bool isLifted,
5529
private void VisitBinaryOperatorOperandConversionAndPostConditions(BoundExpression expr, BoundExpression operand, Conversion conversion, ParameterSymbol parameter,
TypeWithState
operandType, bool isLifted)
5532
TypeWithState
resultType = VisitBinaryOperatorOperandConversion(expr, operand, conversion, parameter, operandType, isLifted, out parameterAnnotations);
5548
var
leftType = ResultType;
5553
var
rightType = ResultType;
5907
TypeWithState
rightResult = VisitOptionalImplicitConversion(rightOperand, targetType, useLegacyWarnings: UseLegacyWarnings(leftOperand), trackMembers: false, AssignmentKind.Assignment);
5912
TypeWithState
resultType =
TypeWithState
.Create(targetType.Type, rightResult.State);
5928
var
rightUnconditionalResult = ResultType;
5931
SetResultType(node,
TypeWithState
.Create(node.Type, rightUnconditionalResult.State));
5936
TypeWithState
leftResult = ResultType;
5947
TypeWithState
rightResult = ResultType;
5965
SetResultType(node,
TypeWithState
.Create(resultType, rightResult.State.Join(leftState)));
5991
var
conversionResult = VisitConversion(
5998
TypeWithState
.Create(leftType, NullableFlowState.NotNull),
6030
var
operandType = ResultType;
6035
var
result = VisitConversion(boundConversion,
6182
SetResultType(node,
TypeWithState
.Create(resultType, NullableFlowState.MaybeDefault));
6218
TypeWithState
consequenceRValue;
6219
TypeWithState
alternativeRValue;
6258
SetResult(node,
TypeWithState
.Create(refResultType, rValueState), TypeWithAnnotations.Create(refResultType, lValueAnnotation));
6322
SetResultType(node,
TypeWithState
.Create(resultType, default));
6333
TypeWithState
typeWithState = convertArms(
6340
TypeWithState
convertArms(
6342
TypeWithState
consequenceRValue,
TypeWithState
alternativeRValue, BoundExpression consequence, Conversion consequenceConversion, bool consequenceEndReachable,
6348
TypeWithState
convertedConsequenceResult = ConvertConditionalOperandOrSwitchExpressionArmResult(
6357
TypeWithState
convertedAlternativeResult = ConvertConditionalOperandOrSwitchExpressionArmResult(
6367
var
typeWithState =
TypeWithState
.Create(resultTypeWithAnnotations.Type, resultState);
6380
return
TypeWithState
.Create(resultTypeWithAnnotations.Type, resultState);
6390
TypeWithState
consequenceRValue,
6391
TypeWithState
alternativeRValue,
6409
(BoundExpression, Conversion,
TypeWithState
) visitConditionalOperand(LocalState state, BoundExpression operand)
6422
(TypeWithAnnotations LValueType,
TypeWithState
RValueType) visitConditionalRefOperand(LocalState state, BoundExpression operand)
6439
private
TypeWithState
ConvertConditionalOperandOrSwitchExpressionArmResult(
6444
TypeWithState
operandType,
6461
var
resultType = VisitConversion(
6505
SetResultType(node,
TypeWithState
.Create(rvalueType, NullableFlowState.NotNull));
6531
TypeWithState
receiverType = visitAndCheckReceiver(node);
6586
TypeWithState
receiverType = visitAndCheckReceiver(node);
6614
TypeWithState
visitAndCheckReceiver(BoundCall node)
6619
void reinferMethodAndVisitArguments(BoundCall node,
TypeWithState
receiverType, VisitResult? firstArgumentResult = null)
6637
var
returnState = GetReturnTypeWithState(method);
6648
private
TypeWithState
VisitAndCheckReceiver(BoundExpression? receiverOpt, MethodSymbol method)
6650
TypeWithState
receiverType = default;
6665
TypeWithState
receiverType,
6783
private void LearnFromEqualsMethod(MethodSymbol method, BoundCall node,
TypeWithState
receiverType, ImmutableArray<VisitResult> results)
6919
void learnFromEqualsMethodArguments(BoundExpression left,
TypeWithState
leftType, BoundExpression right,
TypeWithState
rightType)
7020
private void CheckCallReceiver(BoundExpression? receiverOpt,
TypeWithState
receiverType, MethodSymbol method)
7053
private
TypeWithState
GetReturnTypeWithState(MethodSymbol method)
7055
return
TypeWithState
.Create(method.ReturnTypeWithAnnotations, GetRValueAnnotations(method));
7125
private static
TypeWithState
ApplyUnconditionalAnnotations(
TypeWithState
typeWithState, FlowAnalysisAnnotations annotations)
7129
return
TypeWithState
.Create(typeWithState.Type, NullableFlowState.NotNull);
7134
return
TypeWithState
.Create(typeWithState.Type, NullableFlowState.MaybeDefault);
7461
TrackAnalyzedNullabilityThroughConversionGroup(
TypeWithState
.Create(argument.Type, result.RValueType.State), argument as BoundConversion, argumentNoConversion);
7872
var
resultType = result.RValueType;
7890
var
stateAfterConversion = VisitConversion(
7945
private bool CheckDisallowedNullAssignment(
TypeWithState
state, FlowAnalysisAnnotations annotations, SyntaxNode node, BoundExpression? boundValueOpt = null)
7963
private static bool IsDisallowedNullAssignment(
TypeWithState
valueState, FlowAnalysisAnnotations targetAnnotations)
8021
var
parameterWithState =
TypeWithState
.Create(parameterType, parameterAnnotations);
8025
parameterWithState =
TypeWithState
.Create(parameterType.Type, adjustedState);
8048
var
parameterWithState =
TypeWithState
.Create(parameterType, parameterAnnotations);
8051
var
worstCaseParameterWithState = applyPostConditionsUnconditionally(parameterWithState, parameterAnnotations);
8112
void trackNullableStateForAssignment(BoundExpression parameterValue, TypeWithAnnotations lValueType, int targetSlot,
TypeWithState
parameterWithState, bool isSuppressed, FlowAnalysisAnnotations parameterAnnotations)
8143
static
TypeWithState
applyPostConditionsUnconditionally(
TypeWithState
typeWithState, FlowAnalysisAnnotations annotations)
8148
return
TypeWithState
.Create(typeWithState.Type, NullableFlowState.MaybeDefault);
8154
return
TypeWithState
.Create(typeWithState.Type, NullableFlowState.NotNull);
8160
static
TypeWithState
applyPostConditionsWhenTrue(
TypeWithState
typeWithState, FlowAnalysisAnnotations annotations)
8169
return
TypeWithState
.Create(typeWithState.Type, NullableFlowState.MaybeDefault);
8173
return
TypeWithState
.Create(typeWithState.Type, NullableFlowState.NotNull);
8179
static
TypeWithState
applyPostConditionsWhenFalse(
TypeWithState
typeWithState, FlowAnalysisAnnotations annotations)
8188
return
TypeWithState
.Create(typeWithState.Type, NullableFlowState.MaybeDefault);
8192
return
TypeWithState
.Create(typeWithState.Type, NullableFlowState.NotNull);
8480
if (_walker.TryGetMethodGroupReceiverNullability(group.ReceiverOpt, out
TypeWithState
receiverType))
8746
private
TypeWithState
GetAdjustedResult(
TypeWithState
type, int slot)
8751
return
TypeWithState
.Create(type.Type, state);
8907
private
TypeWithState
VisitOptionalImplicitConversion(BoundExpression expr, TypeWithAnnotations targetTypeOpt, bool useLegacyWarnings, bool trackMembers, AssignmentKind assignmentKind)
8919
private (
TypeWithState
resultType, Func<TypeWithAnnotations,
TypeWithState
>? completion) VisitOptionalImplicitConversion(
8929
var
operandType = VisitRvalueWithState(operand);
8933
(
TypeWithState
resultType, Func<TypeWithAnnotations,
TypeWithState
>? completion) visitConversion(
8938
Conversion conversion,
TypeWithState
operandType,
8943
return (
TypeWithState
.Create(targetTypeOpt), visitConversionAsContinuation(expr, useLegacyWarnings, trackMembers, assignmentKind, operand, conversion, operandType));
8953
var
resultType = VisitConversion(
8970
Func<TypeWithAnnotations,
TypeWithState
> visitConversionAsContinuation(BoundExpression expr, bool useLegacyWarnings, bool trackMembers, AssignmentKind assignmentKind, BoundExpression operand, Conversion conversion,
TypeWithState
operandType)
9020
ImmutableArray<
TypeWithState
> elementTypes = arguments.SelectAsArray((a, w) => w.VisitRvalueWithState(a), this);
9025
SetResultType(node,
TypeWithState
.Create(null, NullableFlowState.NotNull));
9050
SetResultType(node,
TypeWithState
.Create(tupleOpt, NullableFlowState.NotNull));
9063
ImmutableArray<
TypeWithState
> types,
9093
void trackState(BoundExpression value, FieldSymbol field,
TypeWithState
valueType)
9107
private void TrackNullableStateOfNullableValue(int containingSlot, TypeSymbol containingType, BoundExpression? value,
TypeWithState
valueType, int valueSlot)
9201
var
convertedType = VisitUserDefinedConversion(
9374
private
TypeWithState
VisitConversion(
9379
TypeWithState
operandType,
9399
if (TargetTypedAnalysisCompletion.TryGetValue(conversionOperand, out Func<TypeWithAnnotations,
TypeWithState
>? completion))
9481
return
TypeWithState
.Create(targetType, NullableFlowState.NotNull);
9696
TypeWithState
resultType = calculateResultType(targetTypeWithNullability, fromExplicitCast, resultState, isSuppressed, targetType);
9730
static
TypeWithState
calculateResultType(TypeWithAnnotations targetTypeWithNullability, bool fromExplicitCast, NullableFlowState resultState, bool isSuppressed, TypeSymbol targetType)
9742
var
resultType =
TypeWithState
.Create(targetType, resultState);
9746
static NullableFlowState getReferenceConversionResultState(TypeWithAnnotations targetType,
TypeWithState
operandType)
9780
static NullableFlowState getBoxingConversionResultState(TypeWithAnnotations targetType,
TypeWithState
operandType)
9808
static NullableFlowState getUnboxingConversionResultState(
TypeWithState
operandType)
9818
static NullableFlowState getConversionResultState(
TypeWithState
operandType)
9934
private
TypeWithState
VisitUserDefinedConversion(
9939
TypeWithState
operandType,
9959
var
resultType =
TypeWithState
.Create(targetType, NullableFlowState.NotNull);
9991
TypeWithState
underlyingOperandType = default;
10099
private void TrackAnalyzedNullabilityThroughConversionGroup(
TypeWithState
resultType, BoundConversion? conversionOpt, BoundExpression convertedNode)
10122
private
TypeWithState
GetLiftedReturnType(TypeWithAnnotations returnType, NullableFlowState operandState)
10127
return
TypeWithState
.Create(type, state);
10130
private static
TypeWithState
GetNullableUnderlyingTypeIfNecessary(bool isLifted,
TypeWithState
typeWithState)
10143
private
TypeWithState
GetLiftedReturnTypeIfNecessary(bool isLifted, TypeWithAnnotations returnType, NullableFlowState operandState)
10155
private
TypeWithState
ClassifyAndVisitConversion(
10158
TypeWithState
operandType,
10233
TypeWithState
result = setAnalyzedNullability(node, delegateType, analysisCompletion, node.WasTargetTyped);
10237
TypeWithState
setAnalyzedNullability(BoundDelegateCreationExpression node, NamedTypeSymbol delegateType, Action<NamedTypeSymbol>? analysisCompletion, bool isTargetTyped)
10239
var
result =
TypeWithState
.Create(delegateType, NullableFlowState.NotNull);
10339
var
argState = VisitRvalueWithState(arg);
10392
private bool TryGetMethodGroupReceiverNullability([NotNullWhen(true)] BoundExpression? receiverOpt, out
TypeWithState
type)
10407
private void SetMethodGroupReceiverNullability(BoundExpression receiver,
TypeWithState
type)
10409
_methodGroupReceiverMapOpt ??= PooledDictionary<BoundExpression,
TypeWithState
>.GetInstance();
10418
if (TryGetMethodGroupReceiverNullability(receiverOpt, out
TypeWithState
receiverType))
10536
var
rvalueResult =
TypeWithState
.Create(node.Type, NullableFlowState.NotNull);
10546
var
typeWithState = GetParameterState(parameterType, parameter.FlowAnalysisAnnotations);
10589
TypeWithState
rightState;
10612
SetResult(node,
TypeWithState
.Create(leftLValueType.Type, rightState.State), leftLValueType);
10632
var
rValueType = ApplyUnconditionalAnnotations(type.ToTypeWithState(), annotations);
10641
private void AdjustSetValue(BoundExpression left, ref
TypeWithState
rightState)
10735
private BoundNode? VisitDeconstructionAssignmentOperator(BoundDeconstructionAssignmentOperator node,
TypeWithState
? rightResultOpt)
10765
private void VisitDeconstructionArguments(ArrayBuilder<DeconstructionVariable> variables, Conversion conversion, BoundExpression right,
TypeWithState
? rightResultOpt = null)
10779
private void VisitDeconstructMethodArguments(ArrayBuilder<DeconstructionVariable> variables, Conversion conversion, BoundExpression right,
TypeWithState
? rightResultOpt)
10788
var
rightResult = ResultType;
10880
private void VisitTupleDeconstructionArguments(ArrayBuilder<DeconstructionVariable> variables, ImmutableArray<(BoundValuePlaceholder? placeholder, BoundExpression? conversion)> deconstructConversionInfo, BoundExpression right,
TypeWithState
? rightResultOpt)
10903
TypeWithState
operandType;
10904
TypeWithState
valueType;
10956
var
valueBeforeNullableWrapping =
TypeWithState
.Create(underlyingType.Type, NullableFlowState.NotNull);
11013
private ImmutableArray<BoundExpression> GetDeconstructionRightParts(BoundExpression expr,
TypeWithState
? rightResultOpt)
11066
TypeWithState
receiverType = VisitAndCheckReceiver(node.Operand, instanceMethod);
11086
SetResultType(node,
TypeWithState
.Create(receiverType.Type, NullableFlowState.NotNull));
11090
SetResultType(node,
TypeWithState
.Create(results[0].RValueType.Type, GetState(ref State, extensionReceiverSlot)));
11102
var
opType = VisitRvalueWithState(node.Operand);
11110
SetResultType(node,
TypeWithState
.Create(opType.Type, NullableFlowState.NotNull));
11117
var
operandType = VisitRvalueWithState(node.Operand);
11161
TypeWithState
resultOfOperandConversionType;
11185
TypeWithState
resultOfIncrementType;
11211
TypeWithState
resultType = (op == UnaryOperatorKind.PrefixIncrement || op == UnaryOperatorKind.PrefixDecrement) ? resultOfIncrementType : operandType;
11244
TypeWithState
receiverType = VisitAndCheckReceiver(node.Left, instanceMethod);
11264
SetResultType(node,
TypeWithState
.Create(receiverType.Type, NullableFlowState.NotNull));
11268
SetResultType(node,
TypeWithState
.Create(results[0].RValueType.Type, GetState(ref State, extensionReceiverSlot)));
11281
var
opType = ResultType;
11292
SetResultType(node,
TypeWithState
.Create(opType.Type, NullableFlowState.NotNull));
11302
var
leftTypeWithState = ResultType;
11310
var
rightTypeWithState = VisitRvalueWithState(rightConversionOperand);
11317
var
resultTypeWithState = ReinferAndVisitBinaryOperator(
11370
SetResultType(node.Expression,
TypeWithState
.Create(node.Expression.Type, ResultType.State));
11469
TypeWithState
typeWithState = ApplyUnconditionalAnnotations(typeWithAnnotations.ToTypeWithState(), memberAnnotations);
11512
var
resultType = ApplyUnconditionalAnnotations(indexer.TypeWithAnnotations.ToTypeWithState(), GetRValueAnnotations(indexer));
11570
var
receiverType = (receiverOpt != null) ? VisitRvalueWithState(receiverOpt) : default;
11585
var
resultType = ApplyUnconditionalAnnotations(type.ToTypeWithState(), memberAnnotations);
11595
resultType =
TypeWithState
.Create(resultType.Type, state);
11699
var
resultTypeWithState = VisitRvalueWithState(expr);
11769
var
convertedResult = VisitConversion(
11787
TypeWithState
currentPropertyGetterTypeWithState;
11828
var
enumeratorReturnType = GetReturnTypeWithState(reinferredGetEnumeratorMethod);
11884
var
sourceState = node.EnumeratorInfoOpt == null ? default : ResultType;
11901
VisitDeconstructionAssignmentOperator(assignment, sourceState.HasNullType ? (
TypeWithState
?)null : sourceState);
11915
TypeWithState
result = sourceState;
11916
TypeWithState
resultForType = sourceState;
12042
TypeWithState
resultType;
12074
var
operandResult = ResultType;
12076
var
operandType = GetNullableUnderlyingTypeIfNecessary(isLifted, operandResult);
12107
TypeWithState
adjustForLifting(
TypeWithState
argumentResult) =>
12108
TypeWithState
.Create(node.Type, node.OperatorKind.IsLifted() ? argumentResult.State : NullableFlowState.NotNull);
12114
private MethodSymbol ReInferUnaryOperator(SyntaxNode syntax, MethodSymbol method, BoundExpression operand,
TypeWithState
operandType)
12249
TypeWithState
leftType = ResultType;
12258
TypeWithState
rightType = ResultType;
12265
TypeWithState
leftType = ResultType;
12280
var
rightType = ResultType;
12288
TypeWithState
leftUnderlyingType = GetNullableUnderlyingTypeIfNecessary(isLifted, leftType);
12289
TypeWithState
rightUnderlyingType = GetNullableUnderlyingTypeIfNecessary(isLifted, rightType);
12376
SetResultType(node,
TypeWithState
.Create(node.Type, NullableFlowState.NotNull));
12398
SetResultType(node,
TypeWithState
.Create(node.Type, NullableFlowState.MaybeDefault));
12418
SetResultType(node,
TypeWithState
.ForType(type));
12458
var
argumentType = VisitRvalueWithState(node.Operand);
12480
SetResultType(node,
TypeWithState
.Create(type, resultState));
12512
SetResultType(node,
TypeWithState
.Create(node.Type, node.Type?.CanContainNull() != false && node.ConstantValueOpt?.IsNull == true ? NullableFlowState.MaybeDefault : NullableFlowState.NotNull));
12587
if (TryGetMethodGroupReceiverNullability(receiverOpt, out
TypeWithState
receiverType))
12689
SetResultType(expression,
TypeWithState
.Create(expression.Type, default));
12711
private bool CheckPossibleNullReceiver(BoundExpression? receiverOpt,
TypeWithState
resultType, bool checkNullableValueType)
12755
private void CheckExtensionMethodThisNullability(BoundExpression expr, Conversion conversion, ParameterSymbol parameter,
TypeWithState
result)
12796
SetResultType(node,
TypeWithState
.Create(node.Type, NullableFlowState.NotNull));
12811
SetResultType(node,
TypeWithState
.Create(node.Type, NullableFlowState.NotNull));
12860
SetResultType(node,
TypeWithState
.Create(node.Type, NullableFlowState.NotNull));
12866
SetResultType(node,
TypeWithState
.Create(type, NullableFlowState.NotNull));
12873
var
rValueType =
TypeWithState
.ForType(node.Type);
12895
var
result = VisitRvalueWithState(expr);
13023
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(