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;
343 references to TypeWithState
Microsoft.CodeAnalysis.CSharp (343)
Binder\Binder_Patterns.cs (1)
1978
var declType =
TypeWithState
.ForType(inputType).ToTypeWithAnnotations(Compilation);
Binder\Semantics\BestTypeInferrer.cs (2)
36
public static NullableFlowState GetNullableState(ArrayBuilder<
TypeWithState
> types)
39
foreach (
var
type in types)
FlowAnalysis\NullableWalker.cs (315)
118
public readonly
TypeWithState
RValueType;
130
public VisitResult(
TypeWithState
rValueType, TypeWithAnnotations lValueType)
139
public VisitResult(
TypeWithState
rValueType, TypeWithAnnotations lValueType, Optional<LocalState> stateForLambda)
147
RValueType =
TypeWithState
.Create(type, state);
156
public VisitResult(
TypeWithState
rValueType, TypeWithAnnotations lValueType, VisitResult[] nestedVisitResults)
235
private static readonly
TypeWithState
_invalidType =
TypeWithState
.Create(new UnsupportedMetadataTypeSymbol(), NullableFlowState.NotNull);
256
private PooledDictionary<BoundExpression,
TypeWithState
>? _methodGroupReceiverMapOpt;
267
private PooledDictionary<BoundExpression, Func<TypeWithAnnotations,
TypeWithState
>>? _targetTypedAnalysisCompletionOpt;
272
/// The delegate is invoked by <see cref="VisitConversion(BoundConversion, BoundExpression, Conversion, TypeWithAnnotations,
TypeWithState
, bool, bool, bool, AssignmentKind, ParameterSymbol, bool, bool, bool, bool, Optional<LocalState>,bool, int, Location, ArrayBuilder<VisitResult>)"/>.
274
private PooledDictionary<BoundExpression, Func<TypeWithAnnotations,
TypeWithState
>> TargetTypedAnalysisCompletion
275
=> _targetTypedAnalysisCompletionOpt ??= PooledDictionary<BoundExpression, Func<TypeWithAnnotations,
TypeWithState
>>.GetInstance();
316
private
TypeWithState
ResultType
321
private void SetResultType(BoundExpression? expression,
TypeWithState
type, bool updateAnalyzedNullability = true)
326
private void SetAnalyzedNullability(BoundExpression? expression,
TypeWithState
type)
360
private void SetResult(BoundExpression? expression,
TypeWithState
resultType, TypeWithAnnotations lvalueType, bool updateAnalyzedNullability = true, bool? isLvalue = null)
380
private void SetAnalyzedNullability(BoundExpression? expression,
TypeWithState
resultType, TypeWithAnnotations lvalueType, bool? isLvalue = null)
2374
private
TypeWithState
VisitRvalueWithState(BoundExpression? node)
2418
/// This should often be checked together with <seealso cref="IsDisallowedNullAssignment(
TypeWithState
, FlowAnalysisAnnotations)"/>
2458
TypeWithState
valueType,
2513
static bool isMaybeDefaultValue(
TypeWithState
valueType)
2550
var
valueState = GetParameterState(
2589
var
valueWhen = ApplyUnconditionalAnnotations(
2603
static bool isBadAssignment(
TypeWithState
valueState, TypeWithAnnotations destinationType, FlowAnalysisAnnotations destinationAnnotations)
2681
TypeWithState
valueType,
2722
static bool areEquivalentTypes(TypeWithAnnotations target,
TypeWithState
assignedValue) =>
3068
var
resultType = VisitOptionalImplicitConversion(
3082
internal static
TypeWithState
GetParameterState(TypeWithAnnotations parameterType, FlowAnalysisAnnotations parameterAnnotations)
3086
return
TypeWithState
.Create(parameterType.Type, NullableFlowState.MaybeDefault);
3091
return
TypeWithState
.Create(parameterType.Type, NullableFlowState.NotNull);
3122
TypeWithState
returnState;
3139
var
result = VisitRvalueWithState(expr);
3171
private
TypeWithState
VisitRefExpression(BoundExpression expr, TypeWithAnnotations destinationType)
3174
TypeWithState
resultType = ResultType;
3241
SetResultType(node,
TypeWithState
.ForType(node.Type));
3611
var
resultState = ApplyUnconditionalAnnotations(resultType.ToTypeWithState(), GetRValueAnnotations(withExpr.CloneMethod));
3737
TypeWithState
valueType;
3786
TypeWithState
resultType = ResultType;
3796
var
result = resultType.WithNotNullState();
3918
SetResultType(node,
TypeWithState
.Create(null, NullableFlowState.NotNull));
3926
SetResultType(node,
TypeWithState
.Create(null, NullableFlowState.NotNull));
3971
var visitResult = new VisitResult(
TypeWithState
.Create(resultType), resultType,
4178
TypeWithState
convertCollection(
4205
var
resultTypeWithState =
TypeWithState
.Create(strippedTargetCollectionType, resultState);
4311
TypeWithState
result = setAnalyzedNullability(node, type, argumentResults, argumentsCompletion, initialStateInferenceCompletion, initializerCompletion, resultState, isTargetTyped);
4315
TypeWithState
setAnalyzedNullability(
4325
var
result =
TypeWithState
.Create(type, resultState);
4494
private void SetUnionValueStateFromConstructorArgument(BoundExpression argument,
TypeWithState
argumentTypeWithState, int containingSlot, PropertySymbol valueProperty)
4792
InitializerCompletionAfterUpdatedSymbol? visitMemberAssignment(BoundAssignmentOperator node, int containingSlot, Symbol symbol, bool delayCompletionForType, Func<TypeWithAnnotations,
TypeWithState
>? conversionCompletion = null)
4805
(
TypeWithState
resultType, conversionCompletion) =
4825
InitializerCompletionAfterUpdatedSymbol? visitMemberAssignmentAsContinuation(BoundAssignmentOperator node, Func<TypeWithAnnotations,
TypeWithState
> conversionCompletion)
4934
TypeWithState
.Create(containingType, receiverResult.RValueType.State),
4954
SetResultType(node,
TypeWithState
.Create(node.Type, NullableFlowState.NotNull));
4959
var
resultType =
TypeWithState
.Create(node.Type, NullableFlowState.NotNull);
5048
var
argumentType = argumentTypes[i];
5067
SetResultType(node,
TypeWithState
.Create(anonymousType, NullableFlowState.NotNull));
5099
SetResultType(node,
TypeWithState
.Create(node.Type, NullableFlowState.NotNull));
5104
SetResultType(node,
TypeWithState
.Create(arrayType, NullableFlowState.NotNull));
5138
var expressionTypes = ArrayBuilder<
TypeWithState
>.GetInstance(n);
5147
var
expressionType = VisitRvalueWithState(expressionNoConversion);
5181
inferredType =
TypeWithState
.Create(inferredType.Type, elementState).ToTypeWithAnnotations(compilation);
5380
private
TypeWithState
InferResultNullability(BinaryOperatorKind operatorKind, MethodSymbol? methodOpt, TypeSymbol resultType,
TypeWithState
leftType,
TypeWithState
rightType)
5392
var
resultTypeWithState = GetReturnTypeWithState(methodOpt);
5423
return
TypeWithState
.Create(resultType, resultState);
5440
var
leftType = ResultType;
5467
var
rightType = VisitRvalueWithState(rightOperand);
5510
static bool isKnownNullOrNotNull(BoundExpression expr,
TypeWithState
resultType)
5545
var
leftResult = ResultType;
5598
SetResult(binary,
TypeWithState
.ForType(binary.Type), TypeWithAnnotations.Create(binary.Type));
5606
TypeWithState
leftType,
5609
TypeWithState
rightType,
5612
var
inferredResult = ReinferAndVisitBinaryOperator(binary, binary.OperatorKind, binary.BinaryOperatorMethod, binary.Type, binary.Left, leftOperand, leftConversion, leftType, binary.Right, rightOperand, rightConversion, rightType);
5616
private
TypeWithState
ReinferAndVisitBinaryOperator(
5624
TypeWithState
leftType,
5628
TypeWithState
rightType)
5638
TypeWithState
leftUnderlyingType = GetNullableUnderlyingTypeIfNecessary(isLifted, leftType);
5639
TypeWithState
rightUnderlyingType = GetNullableUnderlyingTypeIfNecessary(isLifted, rightType);
5661
TypeWithState
operandType)
5694
var
inferredResult = InferResultNullability(operatorKind, method, returnType, leftType, rightType);
5704
TypeWithState
leftUnderlyingType,
5705
TypeWithState
rightUnderlyingType)
5770
private
TypeWithState
VisitBinaryOperatorOperandConversion(
5771
BoundExpression expr, BoundExpression operand, Conversion conversion, ParameterSymbol parameter,
TypeWithState
operandType, bool isLifted,
5795
private void VisitBinaryOperatorOperandConversionAndPostConditions(BoundExpression expr, BoundExpression operand, Conversion conversion, ParameterSymbol parameter,
TypeWithState
operandType, bool isLifted)
5798
TypeWithState
resultType = VisitBinaryOperatorOperandConversion(expr, operand, conversion, parameter, operandType, isLifted, out parameterAnnotations);
5814
var
leftType = ResultType;
5819
var
rightType = ResultType;
6173
TypeWithState
rightResult = VisitOptionalImplicitConversion(rightOperand, targetType, useLegacyWarnings: UseLegacyWarnings(leftOperand), trackMembers: false, AssignmentKind.Assignment);
6178
TypeWithState
resultType =
TypeWithState
.Create(targetType.Type, rightResult.State);
6194
var
rightUnconditionalResult = ResultType;
6197
SetResultType(node,
TypeWithState
.Create(node.Type, rightUnconditionalResult.State));
6202
TypeWithState
leftResult = ResultType;
6213
TypeWithState
rightResult = ResultType;
6231
SetResultType(node,
TypeWithState
.Create(resultType, rightResult.State.Join(leftState)));
6259
var
conversionResult = VisitConversion(
6266
TypeWithState
.Create(leftType, NullableFlowState.NotNull),
6298
var
operandType = ResultType;
6303
var
result = VisitConversion(boundConversion,
6450
SetResultType(node,
TypeWithState
.Create(resultType, NullableFlowState.MaybeDefault));
6486
TypeWithState
consequenceRValue;
6487
TypeWithState
alternativeRValue;
6526
SetResult(node,
TypeWithState
.Create(refResultType, rValueState), TypeWithAnnotations.Create(refResultType, lValueAnnotation));
6590
SetResultType(node,
TypeWithState
.Create(resultType, default));
6601
TypeWithState
typeWithState = convertArms(
6608
TypeWithState
convertArms(
6610
TypeWithState
consequenceRValue,
TypeWithState
alternativeRValue, BoundExpression consequence, Conversion consequenceConversion, bool consequenceEndReachable,
6616
TypeWithState
convertedConsequenceResult = ConvertConditionalOperandOrSwitchExpressionArmResult(
6625
TypeWithState
convertedAlternativeResult = ConvertConditionalOperandOrSwitchExpressionArmResult(
6635
var
typeWithState =
TypeWithState
.Create(resultTypeWithAnnotations.Type, resultState);
6648
return
TypeWithState
.Create(resultTypeWithAnnotations.Type, resultState);
6658
TypeWithState
consequenceRValue,
6659
TypeWithState
alternativeRValue,
6677
(BoundExpression, Conversion,
TypeWithState
) visitConditionalOperand(LocalState state, BoundExpression operand)
6690
(TypeWithAnnotations LValueType,
TypeWithState
RValueType) visitConditionalRefOperand(LocalState state, BoundExpression operand)
6707
private
TypeWithState
ConvertConditionalOperandOrSwitchExpressionArmResult(
6712
TypeWithState
operandType,
6729
var
resultType = VisitConversion(
6773
SetResultType(node,
TypeWithState
.Create(rvalueType, NullableFlowState.NotNull));
6799
TypeWithState
receiverType = visitAndCheckReceiver(node);
6873
TypeWithState
receiverType = visitAndCheckReceiver(node);
6901
TypeWithState
visitAndCheckReceiver(BoundCall node)
6911
void reinferMethodAndVisitArguments(BoundCall node,
TypeWithState
receiverType, VisitResult? firstArgumentResult = null)
6952
var
returnState = GetReturnTypeWithState(method);
6963
private
TypeWithState
VisitAndCheckReceiver(BoundExpression? receiverOpt, MethodSymbol method)
6965
TypeWithState
receiverType = default;
6980
TypeWithState
receiverType,
7098
private void LearnFromEqualsMethod(MethodSymbol method, BoundCall node,
TypeWithState
receiverType, ImmutableArray<VisitResult> results)
7234
void learnFromEqualsMethodArguments(BoundExpression left,
TypeWithState
leftType, BoundExpression right,
TypeWithState
rightType)
7335
private void CheckCallReceiver(BoundExpression? receiverOpt,
TypeWithState
receiverType, MethodSymbol method)
7368
private
TypeWithState
GetReturnTypeWithState(MethodSymbol method)
7370
return
TypeWithState
.Create(method.ReturnTypeWithAnnotations, GetRValueAnnotations(method));
7440
private static
TypeWithState
ApplyUnconditionalAnnotations(
TypeWithState
typeWithState, FlowAnalysisAnnotations annotations)
7444
return
TypeWithState
.Create(typeWithState.Type, NullableFlowState.NotNull);
7449
return
TypeWithState
.Create(typeWithState.Type, NullableFlowState.MaybeDefault);
7776
TrackAnalyzedNullabilityThroughConversionGroup(
TypeWithState
.Create(argument.Type, result.RValueType.State), argument as BoundConversion, argumentNoConversion);
8207
var
resultType = result.RValueType;
8225
var
stateAfterConversion = VisitConversion(
8280
private bool CheckDisallowedNullAssignment(
TypeWithState
state, FlowAnalysisAnnotations annotations, SyntaxNode node, BoundExpression? boundValueOpt = null)
8298
private static bool IsDisallowedNullAssignment(
TypeWithState
valueState, FlowAnalysisAnnotations targetAnnotations)
8357
var
parameterWithState =
TypeWithState
.Create(parameterType, parameterAnnotations);
8361
parameterWithState =
TypeWithState
.Create(parameterType.Type, adjustedState);
8384
var
parameterWithState =
TypeWithState
.Create(parameterType, parameterAnnotations);
8387
var
worstCaseParameterWithState = applyPostConditionsUnconditionally(parameterWithState, parameterAnnotations);
8448
void trackNullableStateForAssignment(TypeSymbol? receiverType, BoundExpression parameterValue, TypeWithAnnotations lValueType, int targetSlot,
TypeWithState
parameterWithState, bool isSuppressed, FlowAnalysisAnnotations parameterAnnotations, RefKind refKind, ParameterSymbol parameter)
8498
static
TypeWithState
applyPostConditionsUnconditionally(
TypeWithState
typeWithState, FlowAnalysisAnnotations annotations)
8503
return
TypeWithState
.Create(typeWithState.Type, NullableFlowState.MaybeDefault);
8509
return
TypeWithState
.Create(typeWithState.Type, NullableFlowState.NotNull);
8515
static
TypeWithState
applyPostConditionsWhenTrue(TypeSymbol? receiverType,
TypeWithState
typeWithState, FlowAnalysisAnnotations annotations, RefKind refKind, ParameterSymbol parameter)
8524
return
TypeWithState
.Create(typeWithState.Type, NullableFlowState.MaybeDefault);
8528
return
TypeWithState
.Create(typeWithState.Type, NullableFlowState.NotNull);
8534
static
TypeWithState
applyPostConditionsWhenFalse(
TypeWithState
typeWithState, FlowAnalysisAnnotations annotations)
8543
return
TypeWithState
.Create(typeWithState.Type, NullableFlowState.MaybeDefault);
8547
return
TypeWithState
.Create(typeWithState.Type, NullableFlowState.NotNull);
8835
if (_walker.TryGetMethodGroupReceiverNullability(group.ReceiverOpt, out
TypeWithState
receiverType))
9112
private
TypeWithState
GetAdjustedResult(
TypeWithState
type, int slot)
9117
return
TypeWithState
.Create(type.Type, state);
9273
private
TypeWithState
VisitOptionalImplicitConversion(BoundExpression expr, TypeWithAnnotations targetTypeOpt, bool useLegacyWarnings, bool trackMembers, AssignmentKind assignmentKind)
9285
private (
TypeWithState
resultType, Func<TypeWithAnnotations,
TypeWithState
>? completion) VisitOptionalImplicitConversion(
9295
var
operandType = VisitRvalueWithState(operand);
9299
(
TypeWithState
resultType, Func<TypeWithAnnotations,
TypeWithState
>? completion) visitConversion(
9304
Conversion conversion,
TypeWithState
operandType,
9309
return (
TypeWithState
.Create(targetTypeOpt), visitConversionAsContinuation(expr, useLegacyWarnings, trackMembers, assignmentKind, operand, conversion, operandType));
9319
var
resultType = VisitConversion(
9336
Func<TypeWithAnnotations,
TypeWithState
> visitConversionAsContinuation(BoundExpression expr, bool useLegacyWarnings, bool trackMembers, AssignmentKind assignmentKind, BoundExpression operand, Conversion conversion,
TypeWithState
operandType)
9386
ImmutableArray<
TypeWithState
> elementTypes = arguments.SelectAsArray((a, w) => w.VisitRvalueWithState(a), this);
9391
SetResultType(node,
TypeWithState
.Create(null, NullableFlowState.NotNull));
9416
SetResultType(node,
TypeWithState
.Create(tupleOpt, NullableFlowState.NotNull));
9429
ImmutableArray<
TypeWithState
> types,
9459
void trackState(BoundExpression value, FieldSymbol field,
TypeWithState
valueType)
9473
private void TrackNullableStateOfNullableValue(int containingSlot, TypeSymbol containingType, BoundExpression? value,
TypeWithState
valueType, int valueSlot)
9568
var
convertedType = VisitUserDefinedConversion(
9593
TypeWithState
valueFieldType = ApplyUnconditionalAnnotations(valueField.TypeWithAnnotations.ToTypeWithState(), GetRValueAnnotations(valueField));
9600
valueFieldType =
TypeWithState
.Create(valueFieldType.Type, GetState(ref this.State, valueFieldSlot));
9618
TypeWithState
convertedType = VisitUnionConversion(
9798
private
TypeWithState
VisitConversion(
9803
TypeWithState
operandType,
9825
if (TargetTypedAnalysisCompletion.TryGetValue(conversionOperand, out Func<TypeWithAnnotations,
TypeWithState
>? completion))
9908
return
TypeWithState
.Create(targetType, NullableFlowState.NotNull);
10180
TypeWithState
resultType = calculateResultType(targetTypeWithNullability, fromExplicitCast, resultState, isSuppressed, targetType);
10214
static
TypeWithState
calculateResultType(TypeWithAnnotations targetTypeWithNullability, bool fromExplicitCast, NullableFlowState resultState, bool isSuppressed, TypeSymbol targetType)
10226
var
resultType =
TypeWithState
.Create(targetType, resultState);
10230
static NullableFlowState getReferenceConversionResultState(TypeWithAnnotations targetType,
TypeWithState
operandType)
10264
static NullableFlowState getBoxingConversionResultState(TypeWithAnnotations targetType,
TypeWithState
operandType)
10292
static NullableFlowState getUnboxingConversionResultState(
TypeWithState
operandType)
10302
static NullableFlowState getConversionResultState(
TypeWithState
operandType)
10418
private
TypeWithState
VisitUserDefinedConversion(
10423
TypeWithState
operandType,
10442
var
resultType =
TypeWithState
.Create(targetType, NullableFlowState.NotNull);
10474
TypeWithState
underlyingOperandType = default;
10550
private
TypeWithState
GetConversionReturnTypeWithState(MethodSymbol method, bool isLiftedConversion, NullableFlowState operandState)
10553
TypeWithState
returnType = GetLiftedReturnTypeIfNecessary(isLiftedConversion, methodReturnType, operandState);
10570
private
TypeWithState
VisitUnionConversion(
10575
TypeWithState
operandType,
10594
var
resultType =
TypeWithState
.Create(targetTypeWithNullability.Type, NullableFlowState.NotNull);
10676
TypeWithState
unionTypeWithState;
10681
unionTypeWithState =
TypeWithState
.Create(toType, NullableFlowState.NotNull);
10747
private void TrackAnalyzedNullabilityThroughConversionGroup(
TypeWithState
resultType, BoundConversion? conversionOpt, BoundExpression convertedNode)
10775
private
TypeWithState
GetLiftedReturnType(TypeWithAnnotations returnType, NullableFlowState operandState)
10780
return
TypeWithState
.Create(type, state);
10783
private static
TypeWithState
GetNullableUnderlyingTypeIfNecessary(bool isLifted,
TypeWithState
typeWithState)
10796
private
TypeWithState
GetLiftedReturnTypeIfNecessary(bool isLifted, TypeWithAnnotations returnType, NullableFlowState operandState)
10808
private
TypeWithState
ClassifyAndVisitConversion(
10811
TypeWithState
operandType,
10886
TypeWithState
result = setAnalyzedNullability(node, delegateType, analysisCompletion, node.WasTargetTyped);
10890
TypeWithState
setAnalyzedNullability(BoundDelegateCreationExpression node, NamedTypeSymbol delegateType, Action<NamedTypeSymbol>? analysisCompletion, bool isTargetTyped)
10892
var
result =
TypeWithState
.Create(delegateType, NullableFlowState.NotNull);
10992
var
argState = VisitRvalueWithState(arg);
11045
private bool TryGetMethodGroupReceiverNullability([NotNullWhen(true)] BoundExpression? receiverOpt, out
TypeWithState
type)
11060
private void SetMethodGroupReceiverNullability(BoundExpression receiver,
TypeWithState
type)
11062
_methodGroupReceiverMapOpt ??= PooledDictionary<BoundExpression,
TypeWithState
>.GetInstance();
11071
if (TryGetMethodGroupReceiverNullability(receiverOpt, out
TypeWithState
receiverType))
11189
var
rvalueResult =
TypeWithState
.Create(node.Type, NullableFlowState.NotNull);
11199
var
typeWithState = GetParameterState(parameterType, parameter.FlowAnalysisAnnotations);
11242
TypeWithState
rightState;
11265
SetResult(node,
TypeWithState
.Create(leftLValueType.Type, rightState.State), leftLValueType);
11285
var
rValueType = ApplyUnconditionalAnnotations(type.ToTypeWithState(), annotations);
11294
private void AdjustSetValue(BoundExpression left, ref
TypeWithState
rightState)
11388
private BoundNode? VisitDeconstructionAssignmentOperator(BoundDeconstructionAssignmentOperator node,
TypeWithState
? rightResultOpt)
11418
private void VisitDeconstructionArguments(ArrayBuilder<DeconstructionVariable> variables, Conversion conversion, BoundExpression right,
TypeWithState
? rightResultOpt = null)
11432
private void VisitDeconstructMethodArguments(ArrayBuilder<DeconstructionVariable> variables, Conversion conversion, BoundExpression right,
TypeWithState
? rightResultOpt)
11441
var
rightResult = ResultType;
11532
private void VisitTupleDeconstructionArguments(ArrayBuilder<DeconstructionVariable> variables, ImmutableArray<(BoundValuePlaceholder? placeholder, BoundExpression? conversion)> deconstructConversionInfo, BoundExpression right,
TypeWithState
? rightResultOpt)
11555
TypeWithState
operandType;
11556
TypeWithState
valueType;
11608
var
valueBeforeNullableWrapping =
TypeWithState
.Create(underlyingType.Type, NullableFlowState.NotNull);
11665
private ImmutableArray<BoundExpression> GetDeconstructionRightParts(BoundExpression expr,
TypeWithState
? rightResultOpt)
11718
TypeWithState
receiverType = VisitAndCheckReceiver(node.Operand, instanceMethod);
11741
SetResultType(node,
TypeWithState
.Create(receiverType.Type, NullableFlowState.NotNull));
11745
SetResultType(node,
TypeWithState
.Create(results[0].RValueType.Type, GetState(ref State, extensionReceiverSlot)));
11757
var
opType = VisitRvalueWithState(node.Operand);
11765
SetResultType(node,
TypeWithState
.Create(opType.Type, NullableFlowState.NotNull));
11772
var
operandType = VisitRvalueWithState(node.Operand);
11828
TypeWithState
resultOfOperandConversionType;
11852
TypeWithState
resultOfIncrementType;
11878
TypeWithState
resultType = (op == UnaryOperatorKind.PrefixIncrement || op == UnaryOperatorKind.PrefixDecrement) ? resultOfIncrementType : operandType;
11911
TypeWithState
receiverType = VisitAndCheckReceiver(node.Left, instanceMethod);
11934
SetResultType(node,
TypeWithState
.Create(receiverType.Type, NullableFlowState.NotNull));
11938
SetResultType(node,
TypeWithState
.Create(results[0].RValueType.Type, GetState(ref State, extensionReceiverSlot)));
11951
var
opType = ResultType;
11962
SetResultType(node,
TypeWithState
.Create(opType.Type, NullableFlowState.NotNull));
11972
var
leftTypeWithState = ResultType;
11980
var
rightTypeWithState = VisitRvalueWithState(rightConversionOperand);
11987
var
resultTypeWithState = ReinferAndVisitBinaryOperator(
12040
SetResultType(node.Expression,
TypeWithState
.Create(node.Expression.Type, ResultType.State));
12141
TypeWithState
typeWithState = ApplyUnconditionalAnnotations(typeWithAnnotations.ToTypeWithState(), memberAnnotations);
12184
var
resultType = ApplyUnconditionalAnnotations(indexer.TypeWithAnnotations.ToTypeWithState(), GetRValueAnnotations(indexer));
12248
var
receiverType = (receiverOpt != null) ? VisitRvalueWithState(receiverOpt) : default;
12272
var
resultType = ApplyUnconditionalAnnotations(type.ToTypeWithState(), memberAnnotations);
12282
resultType =
TypeWithState
.Create(resultType.Type, state);
12394
var
resultTypeWithState = VisitRvalueWithState(expr);
12464
var
convertedResult = VisitConversion(
12482
TypeWithState
currentPropertyGetterTypeWithState;
12523
var
enumeratorReturnType = GetReturnTypeWithState(reinferredGetEnumeratorMethod);
12569
var
sourceState = node.EnumeratorInfoOpt == null ? default : ResultType;
12586
VisitDeconstructionAssignmentOperator(assignment, sourceState.HasNullType ? (
TypeWithState
?)null : sourceState);
12600
TypeWithState
result = sourceState;
12601
TypeWithState
resultForType = sourceState;
12692
private
TypeWithState
VisitBadExpressionChild(BoundExpression? child)
12734
TypeWithState
resultType;
12766
var
operandResult = ResultType;
12768
var
operandType = GetNullableUnderlyingTypeIfNecessary(isLifted, operandResult);
12799
TypeWithState
adjustForLifting(
TypeWithState
argumentResult) =>
12800
TypeWithState
.Create(node.Type, node.OperatorKind.IsLifted() ? argumentResult.State : NullableFlowState.NotNull);
12806
private MethodSymbol ReInferUnaryOperator(SyntaxNode syntax, MethodSymbol method, BoundExpression operand,
TypeWithState
operandType)
12941
TypeWithState
leftType = ResultType;
12950
TypeWithState
rightType = ResultType;
12957
TypeWithState
leftType = ResultType;
12972
var
rightType = ResultType;
12980
TypeWithState
leftUnderlyingType = GetNullableUnderlyingTypeIfNecessary(isLifted, leftType);
12981
TypeWithState
rightUnderlyingType = GetNullableUnderlyingTypeIfNecessary(isLifted, rightType);
13066
SetResultType(node,
TypeWithState
.Create(node.Type, NullableFlowState.NotNull));
13088
SetResultType(node,
TypeWithState
.Create(node.Type, NullableFlowState.MaybeDefault));
13108
SetResultType(node,
TypeWithState
.ForType(type));
13148
var
argumentType = VisitRvalueWithState(node.Operand);
13170
SetResultType(node,
TypeWithState
.Create(type, resultState));
13202
SetResultType(node,
TypeWithState
.Create(node.Type, node.Type?.CanContainNull() != false && node.ConstantValueOpt?.IsNull == true ? NullableFlowState.MaybeDefault : NullableFlowState.NotNull));
13277
if (TryGetMethodGroupReceiverNullability(receiverOpt, out
TypeWithState
receiverType))
13379
SetResultType(expression,
TypeWithState
.Create(expression.Type, default));
13401
private bool CheckPossibleNullReceiver(BoundExpression? receiverOpt,
TypeWithState
resultType, bool checkNullableValueType)
13445
private void CheckExtensionMethodThisNullability(BoundExpression expr, Conversion conversion, ParameterSymbol parameter,
TypeWithState
result)
13486
SetResultType(node,
TypeWithState
.Create(node.Type, NullableFlowState.NotNull));
13501
SetResultType(node,
TypeWithState
.Create(node.Type, NullableFlowState.NotNull));
13550
SetResultType(node,
TypeWithState
.Create(node.Type, NullableFlowState.NotNull));
13556
SetResultType(node,
TypeWithState
.Create(type, NullableFlowState.NotNull));
13563
var
rValueType =
TypeWithState
.ForType(node.Type);
13585
var
result = VisitRvalueWithState(expr);
13766
Debug.Assert(ResultType is
TypeWithState
{ Type: FunctionPointerTypeSymbol { }, State: NullableFlowState.NotNull });
FlowAnalysis\NullableWalker_Patterns.cs (18)
300
var
expressionState = ResultType;
380
TypeWithState
expressionTypeWithState,
525
var
inputTypeWithState =
TypeWithState
.Create(inputType, inputState);
632
var
value =
TypeWithState
.Create(tempType, tempState);
644
TrackNullableStateForAssignment(valueOpt: null, inferredType, localSlot,
TypeWithState
.Create(tempType, tempState), tempSlot);
993
var
expressionState = ResultType;
1016
var resultTypes = ArrayBuilder<
TypeWithState
>.GetInstance(numSwitchArms);
1037
var
armType = VisitRvalueWithState(expression);
1059
TypeWithState
resultType;
1072
resultType =
TypeWithState
.Create(inferredType, inferredState);
1087
TypeWithState
convertArms(
1091
ArrayBuilder<
TypeWithState
> resultTypes,
1122
TypeWithState
resultType =
TypeWithState
.Create(inferredTypeWithAnnotations.Type, inferredState);
1136
ArrayBuilder<
TypeWithState
> resultTypes,
1161
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;