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)
99
public readonly
TypeWithState
RValueType;
111
public VisitResult(
TypeWithState
rValueType, TypeWithAnnotations lValueType)
120
public VisitResult(
TypeWithState
rValueType, TypeWithAnnotations lValueType, Optional<LocalState> stateForLambda)
128
RValueType =
TypeWithState
.Create(type, state);
137
public VisitResult(
TypeWithState
rValueType, TypeWithAnnotations lValueType, VisitResult[] nestedVisitResults)
216
private static readonly
TypeWithState
_invalidType =
TypeWithState
.Create(new UnsupportedMetadataTypeSymbol(), NullableFlowState.NotNull);
237
private PooledDictionary<BoundExpression,
TypeWithState
>? _methodGroupReceiverMapOpt;
248
private PooledDictionary<BoundExpression, Func<TypeWithAnnotations,
TypeWithState
>>? _targetTypedAnalysisCompletionOpt;
253
/// 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>)"/>.
255
private PooledDictionary<BoundExpression, Func<TypeWithAnnotations,
TypeWithState
>> TargetTypedAnalysisCompletion
256
=> _targetTypedAnalysisCompletionOpt ??= PooledDictionary<BoundExpression, Func<TypeWithAnnotations,
TypeWithState
>>.GetInstance();
297
private
TypeWithState
ResultType
302
private void SetResultType(BoundExpression? expression,
TypeWithState
type, bool updateAnalyzedNullability = true)
307
private void SetAnalyzedNullability(BoundExpression? expression,
TypeWithState
type)
341
private void SetResult(BoundExpression? expression,
TypeWithState
resultType, TypeWithAnnotations lvalueType, bool updateAnalyzedNullability = true, bool? isLvalue = null)
361
private void SetAnalyzedNullability(BoundExpression? expression,
TypeWithState
resultType, TypeWithAnnotations lvalueType, bool? isLvalue = null)
2319
private
TypeWithState
VisitRvalueWithState(BoundExpression? node)
2363
/// This should often be checked together with <seealso cref="IsDisallowedNullAssignment(
TypeWithState
, FlowAnalysisAnnotations)"/>
2403
TypeWithState
valueType,
2458
static bool isMaybeDefaultValue(
TypeWithState
valueType)
2495
var
valueState = GetParameterState(
2534
var
valueWhen = ApplyUnconditionalAnnotations(
2548
static bool isBadAssignment(
TypeWithState
valueState, TypeWithAnnotations destinationType, FlowAnalysisAnnotations destinationAnnotations)
2626
TypeWithState
valueType,
2667
static bool areEquivalentTypes(TypeWithAnnotations target,
TypeWithState
assignedValue) =>
3012
var
resultType = VisitOptionalImplicitConversion(
3026
internal static
TypeWithState
GetParameterState(TypeWithAnnotations parameterType, FlowAnalysisAnnotations parameterAnnotations)
3030
return
TypeWithState
.Create(parameterType.Type, NullableFlowState.MaybeDefault);
3035
return
TypeWithState
.Create(parameterType.Type, NullableFlowState.NotNull);
3066
TypeWithState
returnState;
3083
var
result = VisitRvalueWithState(expr);
3115
private
TypeWithState
VisitRefExpression(BoundExpression expr, TypeWithAnnotations destinationType)
3118
TypeWithState
resultType = ResultType;
3187
SetResultType(node,
TypeWithState
.ForType(node.Type));
3556
var
resultState = ApplyUnconditionalAnnotations(resultType.ToTypeWithState(), GetRValueAnnotations(withExpr.CloneMethod));
3657
TypeWithState
valueType;
3706
TypeWithState
resultType = ResultType;
3716
var
result = resultType.WithNotNullState();
3838
SetResultType(node,
TypeWithState
.Create(null, NullableFlowState.NotNull));
3846
SetResultType(node,
TypeWithState
.Create(null, NullableFlowState.NotNull));
3859
var elementConversionCompletions = ArrayBuilder<Func<TypeWithAnnotations /*targetElementType*/, TypeSymbol /*targetCollectionType*/,
TypeWithState
>>.GetInstance();
3881
var visitResult = new VisitResult(
TypeWithState
.Create(resultType), resultType,
3887
void visitElement(BoundNode element, BoundCollectionExpression node, TypeWithAnnotations targetElementType, ArrayBuilder<Func<TypeWithAnnotations, TypeSymbol,
TypeWithState
>> elementConversionCompletions)
3921
var
resultType = VisitConversion(
3979
TypeWithState
convertCollection(BoundCollectionExpression node, TypeWithAnnotations targetCollectionType, ArrayBuilder<Func<TypeWithAnnotations, TypeSymbol,
TypeWithState
>> completions)
4001
var
resultTypeWithState =
TypeWithState
.Create(strippedTargetCollectionType, resultState);
4096
TypeWithState
result = setAnalyzedNullability(node, type, argumentResults, argumentsCompletion, initialStateInferenceCompletion, initializerCompletion, resultState, isTargetTyped);
4100
TypeWithState
setAnalyzedNullability(
4110
var
result =
TypeWithState
.Create(type, resultState);
4472
Action<int, Symbol>? visitMemberAssignment(BoundAssignmentOperator node, int containingSlot, Symbol symbol, bool delayCompletionForType, Func<TypeWithAnnotations,
TypeWithState
>? conversionCompletion = null)
4485
(
TypeWithState
resultType, conversionCompletion) =
4505
Action<int, Symbol>? visitMemberAssignmentAsContinuation(BoundAssignmentOperator node, Func<TypeWithAnnotations,
TypeWithState
> conversionCompletion)
4613
TypeWithState
.Create(containingType, receiverResult.RValueType.State),
4633
SetResultType(node,
TypeWithState
.Create(node.Type, NullableFlowState.NotNull));
4638
var
resultType =
TypeWithState
.Create(node.Type, NullableFlowState.NotNull);
4727
var
argumentType = argumentTypes[i];
4746
SetResultType(node,
TypeWithState
.Create(anonymousType, NullableFlowState.NotNull));
4778
SetResultType(node,
TypeWithState
.Create(node.Type, NullableFlowState.NotNull));
4783
SetResultType(node,
TypeWithState
.Create(arrayType, NullableFlowState.NotNull));
4817
var expressionTypes = ArrayBuilder<
TypeWithState
>.GetInstance(n);
4826
var
expressionType = VisitRvalueWithState(expressionNoConversion);
4860
inferredType =
TypeWithState
.Create(inferredType.Type, elementState).ToTypeWithAnnotations(compilation);
5059
private
TypeWithState
InferResultNullability(BinaryOperatorKind operatorKind, MethodSymbol? methodOpt, TypeSymbol resultType,
TypeWithState
leftType,
TypeWithState
rightType)
5071
var
resultTypeWithState = GetReturnTypeWithState(methodOpt);
5102
return
TypeWithState
.Create(resultType, resultState);
5119
var
leftType = ResultType;
5146
var
rightType = VisitRvalueWithState(rightOperand);
5189
static bool isKnownNullOrNotNull(BoundExpression expr,
TypeWithState
resultType)
5224
var
leftResult = ResultType;
5277
SetResult(binary,
TypeWithState
.ForType(binary.Type), TypeWithAnnotations.Create(binary.Type));
5285
TypeWithState
leftType,
5288
TypeWithState
rightType,
5291
var
inferredResult = ReinferAndVisitBinaryOperator(binary, binary.OperatorKind, binary.Method, binary.Type, binary.Left, leftOperand, leftConversion, leftType, binary.Right, rightOperand, rightConversion, rightType);
5295
private
TypeWithState
ReinferAndVisitBinaryOperator(
5303
TypeWithState
leftType,
5307
TypeWithState
rightType)
5317
TypeWithState
leftUnderlyingType = GetNullableUnderlyingTypeIfNecessary(isLifted, leftType);
5318
TypeWithState
rightUnderlyingType = GetNullableUnderlyingTypeIfNecessary(isLifted, rightType);
5340
TypeWithState
operandType)
5373
var
inferredResult = InferResultNullability(operatorKind, method, returnType, leftType, rightType);
5383
TypeWithState
leftUnderlyingType,
5384
TypeWithState
rightUnderlyingType)
5449
private
TypeWithState
VisitBinaryOperatorOperandConversion(
5450
BoundExpression expr, BoundExpression operand, Conversion conversion, ParameterSymbol parameter,
TypeWithState
operandType, bool isLifted,
5474
private void VisitBinaryOperatorOperandConversionAndPostConditions(BoundExpression expr, BoundExpression operand, Conversion conversion, ParameterSymbol parameter,
TypeWithState
operandType, bool isLifted)
5477
TypeWithState
resultType = VisitBinaryOperatorOperandConversion(expr, operand, conversion, parameter, operandType, isLifted, out parameterAnnotations);
5493
var
leftType = ResultType;
5498
var
rightType = ResultType;
5852
TypeWithState
rightResult = VisitOptionalImplicitConversion(rightOperand, targetType, useLegacyWarnings: UseLegacyWarnings(leftOperand), trackMembers: false, AssignmentKind.Assignment);
5857
TypeWithState
resultType =
TypeWithState
.Create(targetType.Type, rightResult.State);
5873
var
rightUnconditionalResult = ResultType;
5876
SetResultType(node,
TypeWithState
.Create(node.Type, rightUnconditionalResult.State));
5881
TypeWithState
leftResult = ResultType;
5892
TypeWithState
rightResult = ResultType;
5910
SetResultType(node,
TypeWithState
.Create(resultType, rightResult.State.Join(leftState)));
5936
var
conversionResult = VisitConversion(
5943
TypeWithState
.Create(leftType, NullableFlowState.NotNull),
5975
var
operandType = ResultType;
5980
var
result = VisitConversion(boundConversion,
6127
SetResultType(node,
TypeWithState
.Create(resultType, NullableFlowState.MaybeDefault));
6163
TypeWithState
consequenceRValue;
6164
TypeWithState
alternativeRValue;
6203
SetResult(node,
TypeWithState
.Create(refResultType, rValueState), TypeWithAnnotations.Create(refResultType, lValueAnnotation));
6267
SetResultType(node,
TypeWithState
.Create(resultType, default));
6278
TypeWithState
typeWithState = convertArms(
6285
TypeWithState
convertArms(
6287
TypeWithState
consequenceRValue,
TypeWithState
alternativeRValue, BoundExpression consequence, Conversion consequenceConversion, bool consequenceEndReachable,
6293
TypeWithState
convertedConsequenceResult = ConvertConditionalOperandOrSwitchExpressionArmResult(
6302
TypeWithState
convertedAlternativeResult = ConvertConditionalOperandOrSwitchExpressionArmResult(
6312
var
typeWithState =
TypeWithState
.Create(resultTypeWithAnnotations.Type, resultState);
6325
return
TypeWithState
.Create(resultTypeWithAnnotations.Type, resultState);
6335
TypeWithState
consequenceRValue,
6336
TypeWithState
alternativeRValue,
6354
(BoundExpression, Conversion,
TypeWithState
) visitConditionalOperand(LocalState state, BoundExpression operand)
6367
(TypeWithAnnotations LValueType,
TypeWithState
RValueType) visitConditionalRefOperand(LocalState state, BoundExpression operand)
6384
private
TypeWithState
ConvertConditionalOperandOrSwitchExpressionArmResult(
6389
TypeWithState
operandType,
6406
var
resultType = VisitConversion(
6450
SetResultType(node,
TypeWithState
.Create(rvalueType, NullableFlowState.NotNull));
6476
TypeWithState
receiverType = visitAndCheckReceiver(node);
6531
TypeWithState
receiverType = visitAndCheckReceiver(node);
6559
TypeWithState
visitAndCheckReceiver(BoundCall node)
6564
void reinferMethodAndVisitArguments(BoundCall node,
TypeWithState
receiverType, VisitResult? firstArgumentResult = null)
6582
var
returnState = GetReturnTypeWithState(method);
6593
private
TypeWithState
VisitAndCheckReceiver(BoundExpression? receiverOpt, MethodSymbol method)
6595
TypeWithState
receiverType = default;
6610
TypeWithState
receiverType,
6728
private void LearnFromEqualsMethod(MethodSymbol method, BoundCall node,
TypeWithState
receiverType, ImmutableArray<VisitResult> results)
6864
void learnFromEqualsMethodArguments(BoundExpression left,
TypeWithState
leftType, BoundExpression right,
TypeWithState
rightType)
6965
private void CheckCallReceiver(BoundExpression? receiverOpt,
TypeWithState
receiverType, MethodSymbol method)
6998
private
TypeWithState
GetReturnTypeWithState(MethodSymbol method)
7000
return
TypeWithState
.Create(method.ReturnTypeWithAnnotations, GetRValueAnnotations(method));
7070
private static
TypeWithState
ApplyUnconditionalAnnotations(
TypeWithState
typeWithState, FlowAnalysisAnnotations annotations)
7074
return
TypeWithState
.Create(typeWithState.Type, NullableFlowState.NotNull);
7079
return
TypeWithState
.Create(typeWithState.Type, NullableFlowState.MaybeDefault);
7406
TrackAnalyzedNullabilityThroughConversionGroup(
TypeWithState
.Create(argument.Type, result.RValueType.State), argument as BoundConversion, argumentNoConversion);
7817
var
resultType = result.RValueType;
7835
var
stateAfterConversion = VisitConversion(
7890
private bool CheckDisallowedNullAssignment(
TypeWithState
state, FlowAnalysisAnnotations annotations, SyntaxNode node, BoundExpression? boundValueOpt = null)
7908
private static bool IsDisallowedNullAssignment(
TypeWithState
valueState, FlowAnalysisAnnotations targetAnnotations)
7966
var
parameterWithState =
TypeWithState
.Create(parameterType, parameterAnnotations);
7970
parameterWithState =
TypeWithState
.Create(parameterType.Type, adjustedState);
7993
var
parameterWithState =
TypeWithState
.Create(parameterType, parameterAnnotations);
7996
var
worstCaseParameterWithState = applyPostConditionsUnconditionally(parameterWithState, parameterAnnotations);
8057
void trackNullableStateForAssignment(BoundExpression parameterValue, TypeWithAnnotations lValueType, int targetSlot,
TypeWithState
parameterWithState, bool isSuppressed, FlowAnalysisAnnotations parameterAnnotations)
8088
static
TypeWithState
applyPostConditionsUnconditionally(
TypeWithState
typeWithState, FlowAnalysisAnnotations annotations)
8093
return
TypeWithState
.Create(typeWithState.Type, NullableFlowState.MaybeDefault);
8099
return
TypeWithState
.Create(typeWithState.Type, NullableFlowState.NotNull);
8105
static
TypeWithState
applyPostConditionsWhenTrue(
TypeWithState
typeWithState, FlowAnalysisAnnotations annotations)
8114
return
TypeWithState
.Create(typeWithState.Type, NullableFlowState.MaybeDefault);
8118
return
TypeWithState
.Create(typeWithState.Type, NullableFlowState.NotNull);
8124
static
TypeWithState
applyPostConditionsWhenFalse(
TypeWithState
typeWithState, FlowAnalysisAnnotations annotations)
8133
return
TypeWithState
.Create(typeWithState.Type, NullableFlowState.MaybeDefault);
8137
return
TypeWithState
.Create(typeWithState.Type, NullableFlowState.NotNull);
8379
if (_walker.TryGetMethodGroupReceiverNullability(group.ReceiverOpt, out
TypeWithState
receiverType))
8645
private
TypeWithState
GetAdjustedResult(
TypeWithState
type, int slot)
8650
return
TypeWithState
.Create(type.Type, state);
8806
private
TypeWithState
VisitOptionalImplicitConversion(BoundExpression expr, TypeWithAnnotations targetTypeOpt, bool useLegacyWarnings, bool trackMembers, AssignmentKind assignmentKind)
8818
private (
TypeWithState
resultType, Func<TypeWithAnnotations,
TypeWithState
>? completion) VisitOptionalImplicitConversion(
8828
var
operandType = VisitRvalueWithState(operand);
8832
(
TypeWithState
resultType, Func<TypeWithAnnotations,
TypeWithState
>? completion) visitConversion(
8837
Conversion conversion,
TypeWithState
operandType,
8842
return (
TypeWithState
.Create(targetTypeOpt), visitConversionAsContinuation(expr, useLegacyWarnings, trackMembers, assignmentKind, operand, conversion, operandType));
8852
var
resultType = VisitConversion(
8869
Func<TypeWithAnnotations,
TypeWithState
> visitConversionAsContinuation(BoundExpression expr, bool useLegacyWarnings, bool trackMembers, AssignmentKind assignmentKind, BoundExpression operand, Conversion conversion,
TypeWithState
operandType)
8919
ImmutableArray<
TypeWithState
> elementTypes = arguments.SelectAsArray((a, w) => w.VisitRvalueWithState(a), this);
8924
SetResultType(node,
TypeWithState
.Create(null, NullableFlowState.NotNull));
8949
SetResultType(node,
TypeWithState
.Create(tupleOpt, NullableFlowState.NotNull));
8962
ImmutableArray<
TypeWithState
> types,
8992
void trackState(BoundExpression value, FieldSymbol field,
TypeWithState
valueType)
9006
private void TrackNullableStateOfNullableValue(int containingSlot, TypeSymbol containingType, BoundExpression? value,
TypeWithState
valueType, int valueSlot)
9100
var
convertedType = VisitUserDefinedConversion(
9273
private
TypeWithState
VisitConversion(
9278
TypeWithState
operandType,
9298
if (TargetTypedAnalysisCompletion.TryGetValue(conversionOperand, out Func<TypeWithAnnotations,
TypeWithState
>? completion))
9380
return
TypeWithState
.Create(targetType, NullableFlowState.NotNull);
9595
TypeWithState
resultType = calculateResultType(targetTypeWithNullability, fromExplicitCast, resultState, isSuppressed, targetType);
9629
static
TypeWithState
calculateResultType(TypeWithAnnotations targetTypeWithNullability, bool fromExplicitCast, NullableFlowState resultState, bool isSuppressed, TypeSymbol targetType)
9641
var
resultType =
TypeWithState
.Create(targetType, resultState);
9645
static NullableFlowState getReferenceConversionResultState(TypeWithAnnotations targetType,
TypeWithState
operandType)
9679
static NullableFlowState getBoxingConversionResultState(TypeWithAnnotations targetType,
TypeWithState
operandType)
9707
static NullableFlowState getUnboxingConversionResultState(
TypeWithState
operandType)
9717
static NullableFlowState getConversionResultState(
TypeWithState
operandType)
9833
private
TypeWithState
VisitUserDefinedConversion(
9838
TypeWithState
operandType,
9858
var
resultType =
TypeWithState
.Create(targetType, NullableFlowState.NotNull);
9890
TypeWithState
underlyingOperandType = default;
9998
private void TrackAnalyzedNullabilityThroughConversionGroup(
TypeWithState
resultType, BoundConversion? conversionOpt, BoundExpression convertedNode)
10021
private
TypeWithState
GetLiftedReturnType(TypeWithAnnotations returnType, NullableFlowState operandState)
10026
return
TypeWithState
.Create(type, state);
10029
private static
TypeWithState
GetNullableUnderlyingTypeIfNecessary(bool isLifted,
TypeWithState
typeWithState)
10042
private
TypeWithState
GetLiftedReturnTypeIfNecessary(bool isLifted, TypeWithAnnotations returnType, NullableFlowState operandState)
10054
private
TypeWithState
ClassifyAndVisitConversion(
10057
TypeWithState
operandType,
10132
TypeWithState
result = setAnalyzedNullability(node, delegateType, analysisCompletion, node.WasTargetTyped);
10136
TypeWithState
setAnalyzedNullability(BoundDelegateCreationExpression node, NamedTypeSymbol delegateType, Action<NamedTypeSymbol>? analysisCompletion, bool isTargetTyped)
10138
var
result =
TypeWithState
.Create(delegateType, NullableFlowState.NotNull);
10238
var
argState = VisitRvalueWithState(arg);
10291
private bool TryGetMethodGroupReceiverNullability([NotNullWhen(true)] BoundExpression? receiverOpt, out
TypeWithState
type)
10306
private void SetMethodGroupReceiverNullability(BoundExpression receiver,
TypeWithState
type)
10308
_methodGroupReceiverMapOpt ??= PooledDictionary<BoundExpression,
TypeWithState
>.GetInstance();
10317
if (TryGetMethodGroupReceiverNullability(receiverOpt, out
TypeWithState
receiverType))
10435
var
rvalueResult =
TypeWithState
.Create(node.Type, NullableFlowState.NotNull);
10445
var
typeWithState = GetParameterState(parameterType, parameter.FlowAnalysisAnnotations);
10488
TypeWithState
rightState;
10511
SetResult(node,
TypeWithState
.Create(leftLValueType.Type, rightState.State), leftLValueType);
10531
var
rValueType = ApplyUnconditionalAnnotations(type.ToTypeWithState(), annotations);
10540
private void AdjustSetValue(BoundExpression left, ref
TypeWithState
rightState)
10634
private BoundNode? VisitDeconstructionAssignmentOperator(BoundDeconstructionAssignmentOperator node,
TypeWithState
? rightResultOpt)
10664
private void VisitDeconstructionArguments(ArrayBuilder<DeconstructionVariable> variables, Conversion conversion, BoundExpression right,
TypeWithState
? rightResultOpt = null)
10678
private void VisitDeconstructMethodArguments(ArrayBuilder<DeconstructionVariable> variables, Conversion conversion, BoundExpression right,
TypeWithState
? rightResultOpt)
10687
var
rightResult = ResultType;
10779
private void VisitTupleDeconstructionArguments(ArrayBuilder<DeconstructionVariable> variables, ImmutableArray<(BoundValuePlaceholder? placeholder, BoundExpression? conversion)> deconstructConversionInfo, BoundExpression right,
TypeWithState
? rightResultOpt)
10802
TypeWithState
operandType;
10803
TypeWithState
valueType;
10855
var
valueBeforeNullableWrapping =
TypeWithState
.Create(underlyingType.Type, NullableFlowState.NotNull);
10912
private ImmutableArray<BoundExpression> GetDeconstructionRightParts(BoundExpression expr,
TypeWithState
? rightResultOpt)
10965
TypeWithState
receiverType = VisitAndCheckReceiver(node.Operand, instanceMethod);
10985
SetResultType(node,
TypeWithState
.Create(receiverType.Type, NullableFlowState.NotNull));
10989
SetResultType(node,
TypeWithState
.Create(results[0].RValueType.Type, GetState(ref State, extensionReceiverSlot)));
11001
var
opType = VisitRvalueWithState(node.Operand);
11009
SetResultType(node,
TypeWithState
.Create(opType.Type, NullableFlowState.NotNull));
11016
var
operandType = VisitRvalueWithState(node.Operand);
11060
TypeWithState
resultOfOperandConversionType;
11084
TypeWithState
resultOfIncrementType;
11110
TypeWithState
resultType = (op == UnaryOperatorKind.PrefixIncrement || op == UnaryOperatorKind.PrefixDecrement) ? resultOfIncrementType : operandType;
11143
TypeWithState
receiverType = VisitAndCheckReceiver(node.Left, instanceMethod);
11163
SetResultType(node,
TypeWithState
.Create(receiverType.Type, NullableFlowState.NotNull));
11167
SetResultType(node,
TypeWithState
.Create(results[0].RValueType.Type, GetState(ref State, extensionReceiverSlot)));
11180
var
opType = ResultType;
11191
SetResultType(node,
TypeWithState
.Create(opType.Type, NullableFlowState.NotNull));
11201
var
leftTypeWithState = ResultType;
11209
var
rightTypeWithState = VisitRvalueWithState(rightConversionOperand);
11216
var
resultTypeWithState = ReinferAndVisitBinaryOperator(
11269
SetResultType(node.Expression,
TypeWithState
.Create(node.Expression.Type, ResultType.State));
11368
TypeWithState
typeWithState = ApplyUnconditionalAnnotations(typeWithAnnotations.ToTypeWithState(), memberAnnotations);
11411
var
resultType = ApplyUnconditionalAnnotations(indexer.TypeWithAnnotations.ToTypeWithState(), GetRValueAnnotations(indexer));
11469
var
receiverType = (receiverOpt != null) ? VisitRvalueWithState(receiverOpt) : default;
11484
var
resultType = ApplyUnconditionalAnnotations(type.ToTypeWithState(), memberAnnotations);
11494
resultType =
TypeWithState
.Create(resultType.Type, state);
11598
var
resultTypeWithState = VisitRvalueWithState(expr);
11668
var
convertedResult = VisitConversion(
11686
TypeWithState
currentPropertyGetterTypeWithState;
11727
var
enumeratorReturnType = GetReturnTypeWithState(reinferredGetEnumeratorMethod);
11783
var
sourceState = node.EnumeratorInfoOpt == null ? default : ResultType;
11800
VisitDeconstructionAssignmentOperator(assignment, sourceState.HasNullType ? (
TypeWithState
?)null : sourceState);
11814
TypeWithState
result = sourceState;
11815
TypeWithState
resultForType = sourceState;
11941
TypeWithState
resultType;
11973
var
operandResult = ResultType;
11975
var
operandType = GetNullableUnderlyingTypeIfNecessary(isLifted, operandResult);
12006
TypeWithState
adjustForLifting(
TypeWithState
argumentResult) =>
12007
TypeWithState
.Create(node.Type, node.OperatorKind.IsLifted() ? argumentResult.State : NullableFlowState.NotNull);
12013
private MethodSymbol ReInferUnaryOperator(SyntaxNode syntax, MethodSymbol method, BoundExpression operand,
TypeWithState
operandType)
12148
TypeWithState
leftType = ResultType;
12157
TypeWithState
rightType = ResultType;
12164
TypeWithState
leftType = ResultType;
12179
var
rightType = ResultType;
12187
TypeWithState
leftUnderlyingType = GetNullableUnderlyingTypeIfNecessary(isLifted, leftType);
12188
TypeWithState
rightUnderlyingType = GetNullableUnderlyingTypeIfNecessary(isLifted, rightType);
12275
SetResultType(node,
TypeWithState
.Create(node.Type, NullableFlowState.NotNull));
12297
SetResultType(node,
TypeWithState
.Create(node.Type, NullableFlowState.MaybeDefault));
12317
SetResultType(node,
TypeWithState
.ForType(type));
12357
var
argumentType = VisitRvalueWithState(node.Operand);
12379
SetResultType(node,
TypeWithState
.Create(type, resultState));
12411
SetResultType(node,
TypeWithState
.Create(node.Type, node.Type?.CanContainNull() != false && node.ConstantValueOpt?.IsNull == true ? NullableFlowState.MaybeDefault : NullableFlowState.NotNull));
12486
if (TryGetMethodGroupReceiverNullability(receiverOpt, out
TypeWithState
receiverType))
12588
SetResultType(expression,
TypeWithState
.Create(expression.Type, default));
12610
private bool CheckPossibleNullReceiver(BoundExpression? receiverOpt,
TypeWithState
resultType, bool checkNullableValueType)
12654
private void CheckExtensionMethodThisNullability(BoundExpression expr, Conversion conversion, ParameterSymbol parameter,
TypeWithState
result)
12695
SetResultType(node,
TypeWithState
.Create(node.Type, NullableFlowState.NotNull));
12710
SetResultType(node,
TypeWithState
.Create(node.Type, NullableFlowState.NotNull));
12759
SetResultType(node,
TypeWithState
.Create(node.Type, NullableFlowState.NotNull));
12765
SetResultType(node,
TypeWithState
.Create(type, NullableFlowState.NotNull));
12772
var
rValueType =
TypeWithState
.ForType(node.Type);
12794
var
result = VisitRvalueWithState(expr);
12922
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)
476
var type =
TypeWithState
.Create(