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)
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 (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;
3205
SetResultType(node,
TypeWithState
.ForType(node.Type));
3574
var
resultState = ApplyUnconditionalAnnotations(resultType.ToTypeWithState(), GetRValueAnnotations(withExpr.CloneMethod));
3673
TypeWithState
valueType;
3722
TypeWithState
resultType = ResultType;
3732
var
result = resultType.WithNotNullState();
3854
SetResultType(node,
TypeWithState
.Create(null, NullableFlowState.NotNull));
3862
SetResultType(node,
TypeWithState
.Create(null, NullableFlowState.NotNull));
3875
var elementConversionCompletions = ArrayBuilder<Func<TypeWithAnnotations /*targetElementType*/, TypeSymbol /*targetCollectionType*/,
TypeWithState
>>.GetInstance();
3897
var visitResult = new VisitResult(
TypeWithState
.Create(resultType), resultType,
3903
void visitElement(BoundNode element, BoundCollectionExpression node, TypeWithAnnotations targetElementType, ArrayBuilder<Func<TypeWithAnnotations, TypeSymbol,
TypeWithState
>> elementConversionCompletions)
3937
var
resultType = VisitConversion(
3995
TypeWithState
convertCollection(BoundCollectionExpression node, TypeWithAnnotations targetCollectionType, ArrayBuilder<Func<TypeWithAnnotations, TypeSymbol,
TypeWithState
>> completions)
4017
var
resultTypeWithState =
TypeWithState
.Create(strippedTargetCollectionType, resultState);
4111
TypeWithState
result = setAnalyzedNullability(node, type, argumentResults, argumentsCompletion, initialStateInferenceCompletion, initializerCompletion, resultState, isTargetTyped);
4115
TypeWithState
setAnalyzedNullability(
4125
var
result =
TypeWithState
.Create(type, resultState);
4524
Action<int, Symbol>? visitMemberAssignment(BoundAssignmentOperator node, int containingSlot, Symbol symbol, bool delayCompletionForType, Func<TypeWithAnnotations,
TypeWithState
>? conversionCompletion = null)
4537
(
TypeWithState
resultType, conversionCompletion) =
4557
Action<int, Symbol>? visitMemberAssignmentAsContinuation(BoundAssignmentOperator node, Func<TypeWithAnnotations,
TypeWithState
> conversionCompletion)
4665
TypeWithState
.Create(containingType, receiverResult.RValueType.State),
4685
SetResultType(node,
TypeWithState
.Create(node.Type, NullableFlowState.NotNull));
4690
var
resultType =
TypeWithState
.Create(node.Type, NullableFlowState.NotNull);
4779
var
argumentType = argumentTypes[i];
4798
SetResultType(node,
TypeWithState
.Create(anonymousType, NullableFlowState.NotNull));
4830
SetResultType(node,
TypeWithState
.Create(node.Type, NullableFlowState.NotNull));
4835
SetResultType(node,
TypeWithState
.Create(arrayType, NullableFlowState.NotNull));
4869
var expressionTypes = ArrayBuilder<
TypeWithState
>.GetInstance(n);
4878
var
expressionType = VisitRvalueWithState(expressionNoConversion);
4912
inferredType =
TypeWithState
.Create(inferredType.Type, elementState).ToTypeWithAnnotations(compilation);
5111
private
TypeWithState
InferResultNullability(BinaryOperatorKind operatorKind, MethodSymbol? methodOpt, TypeSymbol resultType,
TypeWithState
leftType,
TypeWithState
rightType)
5123
var
resultTypeWithState = GetReturnTypeWithState(methodOpt);
5154
return
TypeWithState
.Create(resultType, resultState);
5171
var
leftType = ResultType;
5198
var
rightType = VisitRvalueWithState(rightOperand);
5241
static bool isKnownNullOrNotNull(BoundExpression expr,
TypeWithState
resultType)
5276
var
leftResult = ResultType;
5329
SetResult(binary,
TypeWithState
.ForType(binary.Type), TypeWithAnnotations.Create(binary.Type));
5337
TypeWithState
leftType,
5340
TypeWithState
rightType,
5343
var
inferredResult = ReinferAndVisitBinaryOperator(binary, binary.OperatorKind, binary.Method, binary.Type, binary.Left, leftOperand, leftConversion, leftType, binary.Right, rightOperand, rightConversion, rightType);
5347
private
TypeWithState
ReinferAndVisitBinaryOperator(
5355
TypeWithState
leftType,
5359
TypeWithState
rightType)
5369
TypeWithState
leftUnderlyingType = GetNullableUnderlyingTypeIfNecessary(isLifted, leftType);
5370
TypeWithState
rightUnderlyingType = GetNullableUnderlyingTypeIfNecessary(isLifted, rightType);
5392
TypeWithState
operandType)
5425
var
inferredResult = InferResultNullability(operatorKind, method, returnType, leftType, rightType);
5435
TypeWithState
leftUnderlyingType,
5436
TypeWithState
rightUnderlyingType)
5501
private
TypeWithState
VisitBinaryOperatorOperandConversion(
5502
BoundExpression expr, BoundExpression operand, Conversion conversion, ParameterSymbol parameter,
TypeWithState
operandType, bool isLifted,
5526
private void VisitBinaryOperatorOperandConversionAndPostConditions(BoundExpression expr, BoundExpression operand, Conversion conversion, ParameterSymbol parameter,
TypeWithState
operandType, bool isLifted)
5529
TypeWithState
resultType = VisitBinaryOperatorOperandConversion(expr, operand, conversion, parameter, operandType, isLifted, out parameterAnnotations);
5545
var
leftType = ResultType;
5550
var
rightType = ResultType;
5904
TypeWithState
rightResult = VisitOptionalImplicitConversion(rightOperand, targetType, useLegacyWarnings: UseLegacyWarnings(leftOperand), trackMembers: false, AssignmentKind.Assignment);
5909
TypeWithState
resultType =
TypeWithState
.Create(targetType.Type, rightResult.State);
5925
var
rightUnconditionalResult = ResultType;
5928
SetResultType(node,
TypeWithState
.Create(node.Type, rightUnconditionalResult.State));
5933
TypeWithState
leftResult = ResultType;
5944
TypeWithState
rightResult = ResultType;
5962
SetResultType(node,
TypeWithState
.Create(resultType, rightResult.State.Join(leftState)));
5988
var
conversionResult = VisitConversion(
5995
TypeWithState
.Create(leftType, NullableFlowState.NotNull),
6027
var
operandType = ResultType;
6032
var
result = VisitConversion(boundConversion,
6179
SetResultType(node,
TypeWithState
.Create(resultType, NullableFlowState.MaybeDefault));
6215
TypeWithState
consequenceRValue;
6216
TypeWithState
alternativeRValue;
6255
SetResult(node,
TypeWithState
.Create(refResultType, rValueState), TypeWithAnnotations.Create(refResultType, lValueAnnotation));
6319
SetResultType(node,
TypeWithState
.Create(resultType, default));
6330
TypeWithState
typeWithState = convertArms(
6337
TypeWithState
convertArms(
6339
TypeWithState
consequenceRValue,
TypeWithState
alternativeRValue, BoundExpression consequence, Conversion consequenceConversion, bool consequenceEndReachable,
6345
TypeWithState
convertedConsequenceResult = ConvertConditionalOperandOrSwitchExpressionArmResult(
6354
TypeWithState
convertedAlternativeResult = ConvertConditionalOperandOrSwitchExpressionArmResult(
6364
var
typeWithState =
TypeWithState
.Create(resultTypeWithAnnotations.Type, resultState);
6377
return
TypeWithState
.Create(resultTypeWithAnnotations.Type, resultState);
6387
TypeWithState
consequenceRValue,
6388
TypeWithState
alternativeRValue,
6406
(BoundExpression, Conversion,
TypeWithState
) visitConditionalOperand(LocalState state, BoundExpression operand)
6419
(TypeWithAnnotations LValueType,
TypeWithState
RValueType) visitConditionalRefOperand(LocalState state, BoundExpression operand)
6436
private
TypeWithState
ConvertConditionalOperandOrSwitchExpressionArmResult(
6441
TypeWithState
operandType,
6458
var
resultType = VisitConversion(
6502
SetResultType(node,
TypeWithState
.Create(rvalueType, NullableFlowState.NotNull));
6528
TypeWithState
receiverType = visitAndCheckReceiver(node);
6602
TypeWithState
receiverType = visitAndCheckReceiver(node);
6630
TypeWithState
visitAndCheckReceiver(BoundCall node)
6640
void reinferMethodAndVisitArguments(BoundCall node,
TypeWithState
receiverType, VisitResult? firstArgumentResult = null)
6676
var
returnState = GetReturnTypeWithState(method);
6687
private
TypeWithState
VisitAndCheckReceiver(BoundExpression? receiverOpt, MethodSymbol method)
6689
TypeWithState
receiverType = default;
6704
TypeWithState
receiverType,
6821
private void LearnFromEqualsMethod(MethodSymbol method, BoundCall node,
TypeWithState
receiverType, ImmutableArray<VisitResult> results)
6957
void learnFromEqualsMethodArguments(BoundExpression left,
TypeWithState
leftType, BoundExpression right,
TypeWithState
rightType)
7058
private void CheckCallReceiver(BoundExpression? receiverOpt,
TypeWithState
receiverType, MethodSymbol method)
7091
private
TypeWithState
GetReturnTypeWithState(MethodSymbol method)
7093
return
TypeWithState
.Create(method.ReturnTypeWithAnnotations, GetRValueAnnotations(method));
7163
private static
TypeWithState
ApplyUnconditionalAnnotations(
TypeWithState
typeWithState, FlowAnalysisAnnotations annotations)
7167
return
TypeWithState
.Create(typeWithState.Type, NullableFlowState.NotNull);
7172
return
TypeWithState
.Create(typeWithState.Type, NullableFlowState.MaybeDefault);
7499
TrackAnalyzedNullabilityThroughConversionGroup(
TypeWithState
.Create(argument.Type, result.RValueType.State), argument as BoundConversion, argumentNoConversion);
7910
var
resultType = result.RValueType;
7928
var
stateAfterConversion = VisitConversion(
7983
private bool CheckDisallowedNullAssignment(
TypeWithState
state, FlowAnalysisAnnotations annotations, SyntaxNode node, BoundExpression? boundValueOpt = null)
8001
private static bool IsDisallowedNullAssignment(
TypeWithState
valueState, FlowAnalysisAnnotations targetAnnotations)
8059
var
parameterWithState =
TypeWithState
.Create(parameterType, parameterAnnotations);
8063
parameterWithState =
TypeWithState
.Create(parameterType.Type, adjustedState);
8086
var
parameterWithState =
TypeWithState
.Create(parameterType, parameterAnnotations);
8089
var
worstCaseParameterWithState = applyPostConditionsUnconditionally(parameterWithState, parameterAnnotations);
8150
void trackNullableStateForAssignment(BoundExpression parameterValue, TypeWithAnnotations lValueType, int targetSlot,
TypeWithState
parameterWithState, bool isSuppressed, FlowAnalysisAnnotations parameterAnnotations)
8181
static
TypeWithState
applyPostConditionsUnconditionally(
TypeWithState
typeWithState, FlowAnalysisAnnotations annotations)
8186
return
TypeWithState
.Create(typeWithState.Type, NullableFlowState.MaybeDefault);
8192
return
TypeWithState
.Create(typeWithState.Type, NullableFlowState.NotNull);
8198
static
TypeWithState
applyPostConditionsWhenTrue(
TypeWithState
typeWithState, FlowAnalysisAnnotations annotations)
8207
return
TypeWithState
.Create(typeWithState.Type, NullableFlowState.MaybeDefault);
8211
return
TypeWithState
.Create(typeWithState.Type, NullableFlowState.NotNull);
8217
static
TypeWithState
applyPostConditionsWhenFalse(
TypeWithState
typeWithState, FlowAnalysisAnnotations annotations)
8226
return
TypeWithState
.Create(typeWithState.Type, NullableFlowState.MaybeDefault);
8230
return
TypeWithState
.Create(typeWithState.Type, NullableFlowState.NotNull);
8518
if (_walker.TryGetMethodGroupReceiverNullability(group.ReceiverOpt, out
TypeWithState
receiverType))
8784
private
TypeWithState
GetAdjustedResult(
TypeWithState
type, int slot)
8789
return
TypeWithState
.Create(type.Type, state);
8945
private
TypeWithState
VisitOptionalImplicitConversion(BoundExpression expr, TypeWithAnnotations targetTypeOpt, bool useLegacyWarnings, bool trackMembers, AssignmentKind assignmentKind)
8957
private (
TypeWithState
resultType, Func<TypeWithAnnotations,
TypeWithState
>? completion) VisitOptionalImplicitConversion(
8967
var
operandType = VisitRvalueWithState(operand);
8971
(
TypeWithState
resultType, Func<TypeWithAnnotations,
TypeWithState
>? completion) visitConversion(
8976
Conversion conversion,
TypeWithState
operandType,
8981
return (
TypeWithState
.Create(targetTypeOpt), visitConversionAsContinuation(expr, useLegacyWarnings, trackMembers, assignmentKind, operand, conversion, operandType));
8991
var
resultType = VisitConversion(
9008
Func<TypeWithAnnotations,
TypeWithState
> visitConversionAsContinuation(BoundExpression expr, bool useLegacyWarnings, bool trackMembers, AssignmentKind assignmentKind, BoundExpression operand, Conversion conversion,
TypeWithState
operandType)
9058
ImmutableArray<
TypeWithState
> elementTypes = arguments.SelectAsArray((a, w) => w.VisitRvalueWithState(a), this);
9063
SetResultType(node,
TypeWithState
.Create(null, NullableFlowState.NotNull));
9088
SetResultType(node,
TypeWithState
.Create(tupleOpt, NullableFlowState.NotNull));
9101
ImmutableArray<
TypeWithState
> types,
9131
void trackState(BoundExpression value, FieldSymbol field,
TypeWithState
valueType)
9145
private void TrackNullableStateOfNullableValue(int containingSlot, TypeSymbol containingType, BoundExpression? value,
TypeWithState
valueType, int valueSlot)
9239
var
convertedType = VisitUserDefinedConversion(
9412
private
TypeWithState
VisitConversion(
9417
TypeWithState
operandType,
9437
if (TargetTypedAnalysisCompletion.TryGetValue(conversionOperand, out Func<TypeWithAnnotations,
TypeWithState
>? completion))
9519
return
TypeWithState
.Create(targetType, NullableFlowState.NotNull);
9734
TypeWithState
resultType = calculateResultType(targetTypeWithNullability, fromExplicitCast, resultState, isSuppressed, targetType);
9768
static
TypeWithState
calculateResultType(TypeWithAnnotations targetTypeWithNullability, bool fromExplicitCast, NullableFlowState resultState, bool isSuppressed, TypeSymbol targetType)
9780
var
resultType =
TypeWithState
.Create(targetType, resultState);
9784
static NullableFlowState getReferenceConversionResultState(TypeWithAnnotations targetType,
TypeWithState
operandType)
9818
static NullableFlowState getBoxingConversionResultState(TypeWithAnnotations targetType,
TypeWithState
operandType)
9846
static NullableFlowState getUnboxingConversionResultState(
TypeWithState
operandType)
9856
static NullableFlowState getConversionResultState(
TypeWithState
operandType)
9972
private
TypeWithState
VisitUserDefinedConversion(
9977
TypeWithState
operandType,
9997
var
resultType =
TypeWithState
.Create(targetType, NullableFlowState.NotNull);
10029
TypeWithState
underlyingOperandType = default;
10137
private void TrackAnalyzedNullabilityThroughConversionGroup(
TypeWithState
resultType, BoundConversion? conversionOpt, BoundExpression convertedNode)
10160
private
TypeWithState
GetLiftedReturnType(TypeWithAnnotations returnType, NullableFlowState operandState)
10165
return
TypeWithState
.Create(type, state);
10168
private static
TypeWithState
GetNullableUnderlyingTypeIfNecessary(bool isLifted,
TypeWithState
typeWithState)
10181
private
TypeWithState
GetLiftedReturnTypeIfNecessary(bool isLifted, TypeWithAnnotations returnType, NullableFlowState operandState)
10193
private
TypeWithState
ClassifyAndVisitConversion(
10196
TypeWithState
operandType,
10271
TypeWithState
result = setAnalyzedNullability(node, delegateType, analysisCompletion, node.WasTargetTyped);
10275
TypeWithState
setAnalyzedNullability(BoundDelegateCreationExpression node, NamedTypeSymbol delegateType, Action<NamedTypeSymbol>? analysisCompletion, bool isTargetTyped)
10277
var
result =
TypeWithState
.Create(delegateType, NullableFlowState.NotNull);
10377
var
argState = VisitRvalueWithState(arg);
10430
private bool TryGetMethodGroupReceiverNullability([NotNullWhen(true)] BoundExpression? receiverOpt, out
TypeWithState
type)
10445
private void SetMethodGroupReceiverNullability(BoundExpression receiver,
TypeWithState
type)
10447
_methodGroupReceiverMapOpt ??= PooledDictionary<BoundExpression,
TypeWithState
>.GetInstance();
10456
if (TryGetMethodGroupReceiverNullability(receiverOpt, out
TypeWithState
receiverType))
10574
var
rvalueResult =
TypeWithState
.Create(node.Type, NullableFlowState.NotNull);
10584
var
typeWithState = GetParameterState(parameterType, parameter.FlowAnalysisAnnotations);
10627
TypeWithState
rightState;
10650
SetResult(node,
TypeWithState
.Create(leftLValueType.Type, rightState.State), leftLValueType);
10670
var
rValueType = ApplyUnconditionalAnnotations(type.ToTypeWithState(), annotations);
10679
private void AdjustSetValue(BoundExpression left, ref
TypeWithState
rightState)
10773
private BoundNode? VisitDeconstructionAssignmentOperator(BoundDeconstructionAssignmentOperator node,
TypeWithState
? rightResultOpt)
10803
private void VisitDeconstructionArguments(ArrayBuilder<DeconstructionVariable> variables, Conversion conversion, BoundExpression right,
TypeWithState
? rightResultOpt = null)
10817
private void VisitDeconstructMethodArguments(ArrayBuilder<DeconstructionVariable> variables, Conversion conversion, BoundExpression right,
TypeWithState
? rightResultOpt)
10826
var
rightResult = ResultType;
10916
private void VisitTupleDeconstructionArguments(ArrayBuilder<DeconstructionVariable> variables, ImmutableArray<(BoundValuePlaceholder? placeholder, BoundExpression? conversion)> deconstructConversionInfo, BoundExpression right,
TypeWithState
? rightResultOpt)
10939
TypeWithState
operandType;
10940
TypeWithState
valueType;
10992
var
valueBeforeNullableWrapping =
TypeWithState
.Create(underlyingType.Type, NullableFlowState.NotNull);
11049
private ImmutableArray<BoundExpression> GetDeconstructionRightParts(BoundExpression expr,
TypeWithState
? rightResultOpt)
11102
TypeWithState
receiverType = VisitAndCheckReceiver(node.Operand, instanceMethod);
11121
SetResultType(node,
TypeWithState
.Create(receiverType.Type, NullableFlowState.NotNull));
11125
SetResultType(node,
TypeWithState
.Create(results[0].RValueType.Type, GetState(ref State, extensionReceiverSlot)));
11137
var
opType = VisitRvalueWithState(node.Operand);
11145
SetResultType(node,
TypeWithState
.Create(opType.Type, NullableFlowState.NotNull));
11152
var
operandType = VisitRvalueWithState(node.Operand);
11196
TypeWithState
resultOfOperandConversionType;
11220
TypeWithState
resultOfIncrementType;
11246
TypeWithState
resultType = (op == UnaryOperatorKind.PrefixIncrement || op == UnaryOperatorKind.PrefixDecrement) ? resultOfIncrementType : operandType;
11279
TypeWithState
receiverType = VisitAndCheckReceiver(node.Left, instanceMethod);
11298
SetResultType(node,
TypeWithState
.Create(receiverType.Type, NullableFlowState.NotNull));
11302
SetResultType(node,
TypeWithState
.Create(results[0].RValueType.Type, GetState(ref State, extensionReceiverSlot)));
11315
var
opType = ResultType;
11326
SetResultType(node,
TypeWithState
.Create(opType.Type, NullableFlowState.NotNull));
11336
var
leftTypeWithState = ResultType;
11344
var
rightTypeWithState = VisitRvalueWithState(rightConversionOperand);
11351
var
resultTypeWithState = ReinferAndVisitBinaryOperator(
11404
SetResultType(node.Expression,
TypeWithState
.Create(node.Expression.Type, ResultType.State));
11503
TypeWithState
typeWithState = ApplyUnconditionalAnnotations(typeWithAnnotations.ToTypeWithState(), memberAnnotations);
11546
var
resultType = ApplyUnconditionalAnnotations(indexer.TypeWithAnnotations.ToTypeWithState(), GetRValueAnnotations(indexer));
11604
var
receiverType = (receiverOpt != null) ? VisitRvalueWithState(receiverOpt) : default;
11619
var
resultType = ApplyUnconditionalAnnotations(type.ToTypeWithState(), memberAnnotations);
11629
resultType =
TypeWithState
.Create(resultType.Type, state);
11731
var
resultTypeWithState = VisitRvalueWithState(expr);
11800
var
convertedResult = VisitConversion(
11818
TypeWithState
currentPropertyGetterTypeWithState;
11859
var
enumeratorReturnType = GetReturnTypeWithState(reinferredGetEnumeratorMethod);
11915
var
sourceState = node.EnumeratorInfoOpt == null ? default : ResultType;
11932
VisitDeconstructionAssignmentOperator(assignment, sourceState.HasNullType ? (
TypeWithState
?)null : sourceState);
11946
TypeWithState
result = sourceState;
11947
TypeWithState
resultForType = sourceState;
12038
private
TypeWithState
VisitBadExpressionChild(BoundExpression? child)
12080
TypeWithState
resultType;
12112
var
operandResult = ResultType;
12114
var
operandType = GetNullableUnderlyingTypeIfNecessary(isLifted, operandResult);
12145
TypeWithState
adjustForLifting(
TypeWithState
argumentResult) =>
12146
TypeWithState
.Create(node.Type, node.OperatorKind.IsLifted() ? argumentResult.State : NullableFlowState.NotNull);
12152
private MethodSymbol ReInferUnaryOperator(SyntaxNode syntax, MethodSymbol method, BoundExpression operand,
TypeWithState
operandType)
12287
TypeWithState
leftType = ResultType;
12296
TypeWithState
rightType = ResultType;
12303
TypeWithState
leftType = ResultType;
12318
var
rightType = ResultType;
12326
TypeWithState
leftUnderlyingType = GetNullableUnderlyingTypeIfNecessary(isLifted, leftType);
12327
TypeWithState
rightUnderlyingType = GetNullableUnderlyingTypeIfNecessary(isLifted, rightType);
12414
SetResultType(node,
TypeWithState
.Create(node.Type, NullableFlowState.NotNull));
12436
SetResultType(node,
TypeWithState
.Create(node.Type, NullableFlowState.MaybeDefault));
12456
SetResultType(node,
TypeWithState
.ForType(type));
12496
var
argumentType = VisitRvalueWithState(node.Operand);
12518
SetResultType(node,
TypeWithState
.Create(type, resultState));
12550
SetResultType(node,
TypeWithState
.Create(node.Type, node.Type?.CanContainNull() != false && node.ConstantValueOpt?.IsNull == true ? NullableFlowState.MaybeDefault : NullableFlowState.NotNull));
12625
if (TryGetMethodGroupReceiverNullability(receiverOpt, out
TypeWithState
receiverType))
12727
SetResultType(expression,
TypeWithState
.Create(expression.Type, default));
12749
private bool CheckPossibleNullReceiver(BoundExpression? receiverOpt,
TypeWithState
resultType, bool checkNullableValueType)
12793
private void CheckExtensionMethodThisNullability(BoundExpression expr, Conversion conversion, ParameterSymbol parameter,
TypeWithState
result)
12834
SetResultType(node,
TypeWithState
.Create(node.Type, NullableFlowState.NotNull));
12849
SetResultType(node,
TypeWithState
.Create(node.Type, NullableFlowState.NotNull));
12898
SetResultType(node,
TypeWithState
.Create(node.Type, NullableFlowState.NotNull));
12904
SetResultType(node,
TypeWithState
.Create(type, NullableFlowState.NotNull));
12911
var
rValueType =
TypeWithState
.ForType(node.Type);
12933
var
result = VisitRvalueWithState(expr);
13061
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(