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;
341 references to TypeWithState
Microsoft.CodeAnalysis.CSharp (340)
Binder\Binder_Patterns.cs (1)
1739
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 (312)
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)
2338
private
TypeWithState
VisitRvalueWithState(BoundExpression? node)
2382
/// This should often be checked together with <seealso cref="IsDisallowedNullAssignment(
TypeWithState
, FlowAnalysisAnnotations)"/>
2422
TypeWithState
valueType,
2477
static bool isMaybeDefaultValue(
TypeWithState
valueType)
2514
var
valueState = GetParameterState(
2553
var
valueWhen = ApplyUnconditionalAnnotations(
2567
static bool isBadAssignment(
TypeWithState
valueState, TypeWithAnnotations destinationType, FlowAnalysisAnnotations destinationAnnotations)
2645
TypeWithState
valueType,
2686
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;
3205
SetResultType(node,
TypeWithState
.ForType(node.Type));
3575
var
resultState = ApplyUnconditionalAnnotations(resultType.ToTypeWithState(), GetRValueAnnotations(withExpr.CloneMethod));
3701
TypeWithState
valueType;
3750
TypeWithState
resultType = ResultType;
3760
var
result = resultType.WithNotNullState();
3882
SetResultType(node,
TypeWithState
.Create(null, NullableFlowState.NotNull));
3890
SetResultType(node,
TypeWithState
.Create(null, NullableFlowState.NotNull));
3935
var visitResult = new VisitResult(
TypeWithState
.Create(resultType), resultType,
4140
TypeWithState
convertCollection(
4167
var
resultTypeWithState =
TypeWithState
.Create(strippedTargetCollectionType, resultState);
4273
TypeWithState
result = setAnalyzedNullability(node, type, argumentResults, argumentsCompletion, initialStateInferenceCompletion, initializerCompletion, resultState, isTargetTyped);
4277
TypeWithState
setAnalyzedNullability(
4287
var
result =
TypeWithState
.Create(type, resultState);
4455
private void SetUnionValueStateFromConstructorArgument(BoundExpression argument,
TypeWithState
argumentTypeWithState, int containingSlot, PropertySymbol valueProperty)
4753
InitializerCompletionAfterUpdatedSymbol? visitMemberAssignment(BoundAssignmentOperator node, int containingSlot, Symbol symbol, bool delayCompletionForType, Func<TypeWithAnnotations,
TypeWithState
>? conversionCompletion = null)
4766
(
TypeWithState
resultType, conversionCompletion) =
4786
InitializerCompletionAfterUpdatedSymbol? visitMemberAssignmentAsContinuation(BoundAssignmentOperator node, Func<TypeWithAnnotations,
TypeWithState
> conversionCompletion)
4894
TypeWithState
.Create(containingType, receiverResult.RValueType.State),
4914
SetResultType(node,
TypeWithState
.Create(node.Type, NullableFlowState.NotNull));
4919
var
resultType =
TypeWithState
.Create(node.Type, NullableFlowState.NotNull);
5008
var
argumentType = argumentTypes[i];
5027
SetResultType(node,
TypeWithState
.Create(anonymousType, NullableFlowState.NotNull));
5059
SetResultType(node,
TypeWithState
.Create(node.Type, NullableFlowState.NotNull));
5064
SetResultType(node,
TypeWithState
.Create(arrayType, NullableFlowState.NotNull));
5098
var expressionTypes = ArrayBuilder<
TypeWithState
>.GetInstance(n);
5107
var
expressionType = VisitRvalueWithState(expressionNoConversion);
5141
inferredType =
TypeWithState
.Create(inferredType.Type, elementState).ToTypeWithAnnotations(compilation);
5340
private
TypeWithState
InferResultNullability(BinaryOperatorKind operatorKind, MethodSymbol? methodOpt, TypeSymbol resultType,
TypeWithState
leftType,
TypeWithState
rightType)
5352
var
resultTypeWithState = GetReturnTypeWithState(methodOpt);
5383
return
TypeWithState
.Create(resultType, resultState);
5400
var
leftType = ResultType;
5427
var
rightType = VisitRvalueWithState(rightOperand);
5470
static bool isKnownNullOrNotNull(BoundExpression expr,
TypeWithState
resultType)
5505
var
leftResult = ResultType;
5558
SetResult(binary,
TypeWithState
.ForType(binary.Type), TypeWithAnnotations.Create(binary.Type));
5566
TypeWithState
leftType,
5569
TypeWithState
rightType,
5572
var
inferredResult = ReinferAndVisitBinaryOperator(binary, binary.OperatorKind, binary.BinaryOperatorMethod, binary.Type, binary.Left, leftOperand, leftConversion, leftType, binary.Right, rightOperand, rightConversion, rightType);
5576
private
TypeWithState
ReinferAndVisitBinaryOperator(
5584
TypeWithState
leftType,
5588
TypeWithState
rightType)
5598
TypeWithState
leftUnderlyingType = GetNullableUnderlyingTypeIfNecessary(isLifted, leftType);
5599
TypeWithState
rightUnderlyingType = GetNullableUnderlyingTypeIfNecessary(isLifted, rightType);
5621
TypeWithState
operandType)
5654
var
inferredResult = InferResultNullability(operatorKind, method, returnType, leftType, rightType);
5664
TypeWithState
leftUnderlyingType,
5665
TypeWithState
rightUnderlyingType)
5730
private
TypeWithState
VisitBinaryOperatorOperandConversion(
5731
BoundExpression expr, BoundExpression operand, Conversion conversion, ParameterSymbol parameter,
TypeWithState
operandType, bool isLifted,
5755
private void VisitBinaryOperatorOperandConversionAndPostConditions(BoundExpression expr, BoundExpression operand, Conversion conversion, ParameterSymbol parameter,
TypeWithState
operandType, bool isLifted)
5758
TypeWithState
resultType = VisitBinaryOperatorOperandConversion(expr, operand, conversion, parameter, operandType, isLifted, out parameterAnnotations);
5774
var
leftType = ResultType;
5779
var
rightType = ResultType;
6133
TypeWithState
rightResult = VisitOptionalImplicitConversion(rightOperand, targetType, useLegacyWarnings: UseLegacyWarnings(leftOperand), trackMembers: false, AssignmentKind.Assignment);
6138
TypeWithState
resultType =
TypeWithState
.Create(targetType.Type, rightResult.State);
6154
var
rightUnconditionalResult = ResultType;
6157
SetResultType(node,
TypeWithState
.Create(node.Type, rightUnconditionalResult.State));
6162
TypeWithState
leftResult = ResultType;
6173
TypeWithState
rightResult = ResultType;
6191
SetResultType(node,
TypeWithState
.Create(resultType, rightResult.State.Join(leftState)));
6219
var
conversionResult = VisitConversion(
6226
TypeWithState
.Create(leftType, NullableFlowState.NotNull),
6258
var
operandType = ResultType;
6263
var
result = VisitConversion(boundConversion,
6410
SetResultType(node,
TypeWithState
.Create(resultType, NullableFlowState.MaybeDefault));
6446
TypeWithState
consequenceRValue;
6447
TypeWithState
alternativeRValue;
6486
SetResult(node,
TypeWithState
.Create(refResultType, rValueState), TypeWithAnnotations.Create(refResultType, lValueAnnotation));
6550
SetResultType(node,
TypeWithState
.Create(resultType, default));
6561
TypeWithState
typeWithState = convertArms(
6568
TypeWithState
convertArms(
6570
TypeWithState
consequenceRValue,
TypeWithState
alternativeRValue, BoundExpression consequence, Conversion consequenceConversion, bool consequenceEndReachable,
6576
TypeWithState
convertedConsequenceResult = ConvertConditionalOperandOrSwitchExpressionArmResult(
6585
TypeWithState
convertedAlternativeResult = ConvertConditionalOperandOrSwitchExpressionArmResult(
6595
var
typeWithState =
TypeWithState
.Create(resultTypeWithAnnotations.Type, resultState);
6608
return
TypeWithState
.Create(resultTypeWithAnnotations.Type, resultState);
6618
TypeWithState
consequenceRValue,
6619
TypeWithState
alternativeRValue,
6637
(BoundExpression, Conversion,
TypeWithState
) visitConditionalOperand(LocalState state, BoundExpression operand)
6650
(TypeWithAnnotations LValueType,
TypeWithState
RValueType) visitConditionalRefOperand(LocalState state, BoundExpression operand)
6667
private
TypeWithState
ConvertConditionalOperandOrSwitchExpressionArmResult(
6672
TypeWithState
operandType,
6689
var
resultType = VisitConversion(
6733
SetResultType(node,
TypeWithState
.Create(rvalueType, NullableFlowState.NotNull));
6759
TypeWithState
receiverType = visitAndCheckReceiver(node);
6833
TypeWithState
receiverType = visitAndCheckReceiver(node);
6861
TypeWithState
visitAndCheckReceiver(BoundCall node)
6871
void reinferMethodAndVisitArguments(BoundCall node,
TypeWithState
receiverType, VisitResult? firstArgumentResult = null)
6912
var
returnState = GetReturnTypeWithState(method);
6923
private
TypeWithState
VisitAndCheckReceiver(BoundExpression? receiverOpt, MethodSymbol method)
6925
TypeWithState
receiverType = default;
6940
TypeWithState
receiverType,
7058
private void LearnFromEqualsMethod(MethodSymbol method, BoundCall node,
TypeWithState
receiverType, ImmutableArray<VisitResult> results)
7194
void learnFromEqualsMethodArguments(BoundExpression left,
TypeWithState
leftType, BoundExpression right,
TypeWithState
rightType)
7295
private void CheckCallReceiver(BoundExpression? receiverOpt,
TypeWithState
receiverType, MethodSymbol method)
7328
private
TypeWithState
GetReturnTypeWithState(MethodSymbol method)
7330
return
TypeWithState
.Create(method.ReturnTypeWithAnnotations, GetRValueAnnotations(method));
7400
private static
TypeWithState
ApplyUnconditionalAnnotations(
TypeWithState
typeWithState, FlowAnalysisAnnotations annotations)
7404
return
TypeWithState
.Create(typeWithState.Type, NullableFlowState.NotNull);
7409
return
TypeWithState
.Create(typeWithState.Type, NullableFlowState.MaybeDefault);
7729
TrackAnalyzedNullabilityThroughConversionGroup(
TypeWithState
.Create(argument.Type, result.RValueType.State), argument as BoundConversion, argumentNoConversion);
8165
var
resultType = result.RValueType;
8183
var
stateAfterConversion = VisitConversion(
8238
private bool CheckDisallowedNullAssignment(
TypeWithState
state, FlowAnalysisAnnotations annotations, SyntaxNode node, BoundExpression? boundValueOpt = null)
8256
private static bool IsDisallowedNullAssignment(
TypeWithState
valueState, FlowAnalysisAnnotations targetAnnotations)
8314
var
parameterWithState =
TypeWithState
.Create(parameterType, parameterAnnotations);
8318
parameterWithState =
TypeWithState
.Create(parameterType.Type, adjustedState);
8341
var
parameterWithState =
TypeWithState
.Create(parameterType, parameterAnnotations);
8344
var
worstCaseParameterWithState = applyPostConditionsUnconditionally(parameterWithState, parameterAnnotations);
8405
void trackNullableStateForAssignment(BoundExpression parameterValue, TypeWithAnnotations lValueType, int targetSlot,
TypeWithState
parameterWithState, bool isSuppressed, FlowAnalysisAnnotations parameterAnnotations, RefKind refKind, ParameterSymbol parameter)
8461
static
TypeWithState
applyPostConditionsUnconditionally(
TypeWithState
typeWithState, FlowAnalysisAnnotations annotations)
8466
return
TypeWithState
.Create(typeWithState.Type, NullableFlowState.MaybeDefault);
8472
return
TypeWithState
.Create(typeWithState.Type, NullableFlowState.NotNull);
8478
static
TypeWithState
applyPostConditionsWhenTrue(
TypeWithState
typeWithState, FlowAnalysisAnnotations annotations, RefKind refKind, ParameterSymbol parameter)
8487
return
TypeWithState
.Create(typeWithState.Type, NullableFlowState.MaybeDefault);
8491
return
TypeWithState
.Create(typeWithState.Type, NullableFlowState.NotNull);
8497
static
TypeWithState
applyPostConditionsWhenFalse(
TypeWithState
typeWithState, FlowAnalysisAnnotations annotations)
8506
return
TypeWithState
.Create(typeWithState.Type, NullableFlowState.MaybeDefault);
8510
return
TypeWithState
.Create(typeWithState.Type, NullableFlowState.NotNull);
8798
if (_walker.TryGetMethodGroupReceiverNullability(group.ReceiverOpt, out
TypeWithState
receiverType))
9075
private
TypeWithState
GetAdjustedResult(
TypeWithState
type, int slot)
9080
return
TypeWithState
.Create(type.Type, state);
9236
private
TypeWithState
VisitOptionalImplicitConversion(BoundExpression expr, TypeWithAnnotations targetTypeOpt, bool useLegacyWarnings, bool trackMembers, AssignmentKind assignmentKind)
9248
private (
TypeWithState
resultType, Func<TypeWithAnnotations,
TypeWithState
>? completion) VisitOptionalImplicitConversion(
9258
var
operandType = VisitRvalueWithState(operand);
9262
(
TypeWithState
resultType, Func<TypeWithAnnotations,
TypeWithState
>? completion) visitConversion(
9267
Conversion conversion,
TypeWithState
operandType,
9272
return (
TypeWithState
.Create(targetTypeOpt), visitConversionAsContinuation(expr, useLegacyWarnings, trackMembers, assignmentKind, operand, conversion, operandType));
9282
var
resultType = VisitConversion(
9299
Func<TypeWithAnnotations,
TypeWithState
> visitConversionAsContinuation(BoundExpression expr, bool useLegacyWarnings, bool trackMembers, AssignmentKind assignmentKind, BoundExpression operand, Conversion conversion,
TypeWithState
operandType)
9349
ImmutableArray<
TypeWithState
> elementTypes = arguments.SelectAsArray((a, w) => w.VisitRvalueWithState(a), this);
9354
SetResultType(node,
TypeWithState
.Create(null, NullableFlowState.NotNull));
9379
SetResultType(node,
TypeWithState
.Create(tupleOpt, NullableFlowState.NotNull));
9392
ImmutableArray<
TypeWithState
> types,
9422
void trackState(BoundExpression value, FieldSymbol field,
TypeWithState
valueType)
9436
private void TrackNullableStateOfNullableValue(int containingSlot, TypeSymbol containingType, BoundExpression? value,
TypeWithState
valueType, int valueSlot)
9531
var
convertedType = VisitUserDefinedConversion(
9556
TypeWithState
valueFieldType = ApplyUnconditionalAnnotations(valueField.TypeWithAnnotations.ToTypeWithState(), GetRValueAnnotations(valueField));
9563
valueFieldType =
TypeWithState
.Create(valueFieldType.Type, GetState(ref this.State, valueFieldSlot));
9581
TypeWithState
convertedType = VisitUnionConversion(
9762
private
TypeWithState
VisitConversion(
9767
TypeWithState
operandType,
9789
if (TargetTypedAnalysisCompletion.TryGetValue(conversionOperand, out Func<TypeWithAnnotations,
TypeWithState
>? completion))
9872
return
TypeWithState
.Create(targetType, NullableFlowState.NotNull);
10145
TypeWithState
resultType = calculateResultType(targetTypeWithNullability, fromExplicitCast, resultState, isSuppressed, targetType);
10179
static
TypeWithState
calculateResultType(TypeWithAnnotations targetTypeWithNullability, bool fromExplicitCast, NullableFlowState resultState, bool isSuppressed, TypeSymbol targetType)
10191
var
resultType =
TypeWithState
.Create(targetType, resultState);
10195
static NullableFlowState getReferenceConversionResultState(TypeWithAnnotations targetType,
TypeWithState
operandType)
10229
static NullableFlowState getBoxingConversionResultState(TypeWithAnnotations targetType,
TypeWithState
operandType)
10257
static NullableFlowState getUnboxingConversionResultState(
TypeWithState
operandType)
10267
static NullableFlowState getConversionResultState(
TypeWithState
operandType)
10383
private
TypeWithState
VisitUserDefinedConversion(
10388
TypeWithState
operandType,
10407
var
resultType =
TypeWithState
.Create(targetType, NullableFlowState.NotNull);
10439
TypeWithState
underlyingOperandType = default;
10528
private
TypeWithState
VisitUnionConversion(
10533
TypeWithState
operandType,
10637
var
unionTypeWithState =
TypeWithState
.Create(toType, NullableFlowState.NotNull);
10675
return
TypeWithState
.Create(targetType, NullableFlowState.NotNull);
10697
private void TrackAnalyzedNullabilityThroughConversionGroup(
TypeWithState
resultType, BoundConversion? conversionOpt, BoundExpression convertedNode)
10725
private
TypeWithState
GetLiftedReturnType(TypeWithAnnotations returnType, NullableFlowState operandState)
10730
return
TypeWithState
.Create(type, state);
10733
private static
TypeWithState
GetNullableUnderlyingTypeIfNecessary(bool isLifted,
TypeWithState
typeWithState)
10746
private
TypeWithState
GetLiftedReturnTypeIfNecessary(bool isLifted, TypeWithAnnotations returnType, NullableFlowState operandState)
10758
private
TypeWithState
ClassifyAndVisitConversion(
10761
TypeWithState
operandType,
10836
TypeWithState
result = setAnalyzedNullability(node, delegateType, analysisCompletion, node.WasTargetTyped);
10840
TypeWithState
setAnalyzedNullability(BoundDelegateCreationExpression node, NamedTypeSymbol delegateType, Action<NamedTypeSymbol>? analysisCompletion, bool isTargetTyped)
10842
var
result =
TypeWithState
.Create(delegateType, NullableFlowState.NotNull);
10942
var
argState = VisitRvalueWithState(arg);
10995
private bool TryGetMethodGroupReceiverNullability([NotNullWhen(true)] BoundExpression? receiverOpt, out
TypeWithState
type)
11010
private void SetMethodGroupReceiverNullability(BoundExpression receiver,
TypeWithState
type)
11012
_methodGroupReceiverMapOpt ??= PooledDictionary<BoundExpression,
TypeWithState
>.GetInstance();
11021
if (TryGetMethodGroupReceiverNullability(receiverOpt, out
TypeWithState
receiverType))
11139
var
rvalueResult =
TypeWithState
.Create(node.Type, NullableFlowState.NotNull);
11149
var
typeWithState = GetParameterState(parameterType, parameter.FlowAnalysisAnnotations);
11192
TypeWithState
rightState;
11215
SetResult(node,
TypeWithState
.Create(leftLValueType.Type, rightState.State), leftLValueType);
11235
var
rValueType = ApplyUnconditionalAnnotations(type.ToTypeWithState(), annotations);
11244
private void AdjustSetValue(BoundExpression left, ref
TypeWithState
rightState)
11338
private BoundNode? VisitDeconstructionAssignmentOperator(BoundDeconstructionAssignmentOperator node,
TypeWithState
? rightResultOpt)
11368
private void VisitDeconstructionArguments(ArrayBuilder<DeconstructionVariable> variables, Conversion conversion, BoundExpression right,
TypeWithState
? rightResultOpt = null)
11382
private void VisitDeconstructMethodArguments(ArrayBuilder<DeconstructionVariable> variables, Conversion conversion, BoundExpression right,
TypeWithState
? rightResultOpt)
11391
var
rightResult = ResultType;
11481
private void VisitTupleDeconstructionArguments(ArrayBuilder<DeconstructionVariable> variables, ImmutableArray<(BoundValuePlaceholder? placeholder, BoundExpression? conversion)> deconstructConversionInfo, BoundExpression right,
TypeWithState
? rightResultOpt)
11504
TypeWithState
operandType;
11505
TypeWithState
valueType;
11557
var
valueBeforeNullableWrapping =
TypeWithState
.Create(underlyingType.Type, NullableFlowState.NotNull);
11614
private ImmutableArray<BoundExpression> GetDeconstructionRightParts(BoundExpression expr,
TypeWithState
? rightResultOpt)
11667
TypeWithState
receiverType = VisitAndCheckReceiver(node.Operand, instanceMethod);
11690
SetResultType(node,
TypeWithState
.Create(receiverType.Type, NullableFlowState.NotNull));
11694
SetResultType(node,
TypeWithState
.Create(results[0].RValueType.Type, GetState(ref State, extensionReceiverSlot)));
11706
var
opType = VisitRvalueWithState(node.Operand);
11714
SetResultType(node,
TypeWithState
.Create(opType.Type, NullableFlowState.NotNull));
11721
var
operandType = VisitRvalueWithState(node.Operand);
11773
TypeWithState
resultOfOperandConversionType;
11797
TypeWithState
resultOfIncrementType;
11823
TypeWithState
resultType = (op == UnaryOperatorKind.PrefixIncrement || op == UnaryOperatorKind.PrefixDecrement) ? resultOfIncrementType : operandType;
11856
TypeWithState
receiverType = VisitAndCheckReceiver(node.Left, instanceMethod);
11879
SetResultType(node,
TypeWithState
.Create(receiverType.Type, NullableFlowState.NotNull));
11883
SetResultType(node,
TypeWithState
.Create(results[0].RValueType.Type, GetState(ref State, extensionReceiverSlot)));
11896
var
opType = ResultType;
11907
SetResultType(node,
TypeWithState
.Create(opType.Type, NullableFlowState.NotNull));
11917
var
leftTypeWithState = ResultType;
11925
var
rightTypeWithState = VisitRvalueWithState(rightConversionOperand);
11932
var
resultTypeWithState = ReinferAndVisitBinaryOperator(
11985
SetResultType(node.Expression,
TypeWithState
.Create(node.Expression.Type, ResultType.State));
12086
TypeWithState
typeWithState = ApplyUnconditionalAnnotations(typeWithAnnotations.ToTypeWithState(), memberAnnotations);
12129
var
resultType = ApplyUnconditionalAnnotations(indexer.TypeWithAnnotations.ToTypeWithState(), GetRValueAnnotations(indexer));
12193
var
receiverType = (receiverOpt != null) ? VisitRvalueWithState(receiverOpt) : default;
12217
var
resultType = ApplyUnconditionalAnnotations(type.ToTypeWithState(), memberAnnotations);
12227
resultType =
TypeWithState
.Create(resultType.Type, state);
12339
var
resultTypeWithState = VisitRvalueWithState(expr);
12409
var
convertedResult = VisitConversion(
12427
TypeWithState
currentPropertyGetterTypeWithState;
12468
var
enumeratorReturnType = GetReturnTypeWithState(reinferredGetEnumeratorMethod);
12514
var
sourceState = node.EnumeratorInfoOpt == null ? default : ResultType;
12531
VisitDeconstructionAssignmentOperator(assignment, sourceState.HasNullType ? (
TypeWithState
?)null : sourceState);
12545
TypeWithState
result = sourceState;
12546
TypeWithState
resultForType = sourceState;
12637
private
TypeWithState
VisitBadExpressionChild(BoundExpression? child)
12679
TypeWithState
resultType;
12711
var
operandResult = ResultType;
12713
var
operandType = GetNullableUnderlyingTypeIfNecessary(isLifted, operandResult);
12744
TypeWithState
adjustForLifting(
TypeWithState
argumentResult) =>
12745
TypeWithState
.Create(node.Type, node.OperatorKind.IsLifted() ? argumentResult.State : NullableFlowState.NotNull);
12751
private MethodSymbol ReInferUnaryOperator(SyntaxNode syntax, MethodSymbol method, BoundExpression operand,
TypeWithState
operandType)
12886
TypeWithState
leftType = ResultType;
12895
TypeWithState
rightType = ResultType;
12902
TypeWithState
leftType = ResultType;
12917
var
rightType = ResultType;
12925
TypeWithState
leftUnderlyingType = GetNullableUnderlyingTypeIfNecessary(isLifted, leftType);
12926
TypeWithState
rightUnderlyingType = GetNullableUnderlyingTypeIfNecessary(isLifted, rightType);
13018
SetResultType(node,
TypeWithState
.Create(node.Type, NullableFlowState.NotNull));
13040
SetResultType(node,
TypeWithState
.Create(node.Type, NullableFlowState.MaybeDefault));
13060
SetResultType(node,
TypeWithState
.ForType(type));
13100
var
argumentType = VisitRvalueWithState(node.Operand);
13122
SetResultType(node,
TypeWithState
.Create(type, resultState));
13154
SetResultType(node,
TypeWithState
.Create(node.Type, node.Type?.CanContainNull() != false && node.ConstantValueOpt?.IsNull == true ? NullableFlowState.MaybeDefault : NullableFlowState.NotNull));
13229
if (TryGetMethodGroupReceiverNullability(receiverOpt, out
TypeWithState
receiverType))
13331
SetResultType(expression,
TypeWithState
.Create(expression.Type, default));
13353
private bool CheckPossibleNullReceiver(BoundExpression? receiverOpt,
TypeWithState
resultType, bool checkNullableValueType)
13397
private void CheckExtensionMethodThisNullability(BoundExpression expr, Conversion conversion, ParameterSymbol parameter,
TypeWithState
result)
13438
SetResultType(node,
TypeWithState
.Create(node.Type, NullableFlowState.NotNull));
13453
SetResultType(node,
TypeWithState
.Create(node.Type, NullableFlowState.NotNull));
13502
SetResultType(node,
TypeWithState
.Create(node.Type, NullableFlowState.NotNull));
13508
SetResultType(node,
TypeWithState
.Create(type, NullableFlowState.NotNull));
13515
var
rValueType =
TypeWithState
.ForType(node.Type);
13537
var
result = VisitRvalueWithState(expr);
13718
Debug.Assert(ResultType is
TypeWithState
{ Type: FunctionPointerTypeSymbol { }, State: NullableFlowState.NotNull });
FlowAnalysis\NullableWalker_Patterns.cs (18)
298
var
expressionState = ResultType;
378
TypeWithState
expressionTypeWithState,
523
var
inputTypeWithState =
TypeWithState
.Create(inputType, inputState);
630
var
value =
TypeWithState
.Create(tempType, tempState);
642
TrackNullableStateForAssignment(valueOpt: null, inferredType, localSlot,
TypeWithState
.Create(tempType, tempState), tempSlot);
991
var
expressionState = ResultType;
1014
var resultTypes = ArrayBuilder<
TypeWithState
>.GetInstance(numSwitchArms);
1035
var
armType = VisitRvalueWithState(expression);
1057
TypeWithState
resultType;
1070
resultType =
TypeWithState
.Create(inferredType, inferredState);
1085
TypeWithState
convertArms(
1089
ArrayBuilder<
TypeWithState
> resultTypes,
1120
TypeWithState
resultType =
TypeWithState
.Create(inferredTypeWithAnnotations.Type, inferredState);
1134
ArrayBuilder<
TypeWithState
> resultTypes,
1159
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(