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;
332 references to TypeWithState
Microsoft.CodeAnalysis.CSharp (331)
Binder\Binder_Patterns.cs (1)
1369
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 (303)
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)
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) =>
3031
var
resultType = VisitOptionalImplicitConversion(
3045
internal static
TypeWithState
GetParameterState(TypeWithAnnotations parameterType, FlowAnalysisAnnotations parameterAnnotations)
3049
return
TypeWithState
.Create(parameterType.Type, NullableFlowState.MaybeDefault);
3054
return
TypeWithState
.Create(parameterType.Type, NullableFlowState.NotNull);
3085
TypeWithState
returnState;
3102
var
result = VisitRvalueWithState(expr);
3134
private
TypeWithState
VisitRefExpression(BoundExpression expr, TypeWithAnnotations destinationType)
3137
TypeWithState
resultType = ResultType;
3204
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));
3907
var visitResult = new VisitResult(
TypeWithState
.Create(resultType), resultType,
4112
TypeWithState
convertCollection(
4139
var
resultTypeWithState =
TypeWithState
.Create(strippedTargetCollectionType, resultState);
4245
TypeWithState
result = setAnalyzedNullability(node, type, argumentResults, argumentsCompletion, initialStateInferenceCompletion, initializerCompletion, resultState, isTargetTyped);
4249
TypeWithState
setAnalyzedNullability(
4259
var
result =
TypeWithState
.Create(type, resultState);
4681
InitializerCompletionAfterUpdatedSymbol? visitMemberAssignment(BoundAssignmentOperator node, int containingSlot, Symbol symbol, bool delayCompletionForType, Func<TypeWithAnnotations,
TypeWithState
>? conversionCompletion = null)
4694
(
TypeWithState
resultType, conversionCompletion) =
4714
InitializerCompletionAfterUpdatedSymbol? visitMemberAssignmentAsContinuation(BoundAssignmentOperator node, Func<TypeWithAnnotations,
TypeWithState
> conversionCompletion)
4822
TypeWithState
.Create(containingType, receiverResult.RValueType.State),
4842
SetResultType(node,
TypeWithState
.Create(node.Type, NullableFlowState.NotNull));
4847
var
resultType =
TypeWithState
.Create(node.Type, NullableFlowState.NotNull);
4936
var
argumentType = argumentTypes[i];
4955
SetResultType(node,
TypeWithState
.Create(anonymousType, NullableFlowState.NotNull));
4987
SetResultType(node,
TypeWithState
.Create(node.Type, NullableFlowState.NotNull));
4992
SetResultType(node,
TypeWithState
.Create(arrayType, NullableFlowState.NotNull));
5026
var expressionTypes = ArrayBuilder<
TypeWithState
>.GetInstance(n);
5035
var
expressionType = VisitRvalueWithState(expressionNoConversion);
5069
inferredType =
TypeWithState
.Create(inferredType.Type, elementState).ToTypeWithAnnotations(compilation);
5268
private
TypeWithState
InferResultNullability(BinaryOperatorKind operatorKind, MethodSymbol? methodOpt, TypeSymbol resultType,
TypeWithState
leftType,
TypeWithState
rightType)
5280
var
resultTypeWithState = GetReturnTypeWithState(methodOpt);
5311
return
TypeWithState
.Create(resultType, resultState);
5328
var
leftType = ResultType;
5355
var
rightType = VisitRvalueWithState(rightOperand);
5398
static bool isKnownNullOrNotNull(BoundExpression expr,
TypeWithState
resultType)
5433
var
leftResult = ResultType;
5486
SetResult(binary,
TypeWithState
.ForType(binary.Type), TypeWithAnnotations.Create(binary.Type));
5494
TypeWithState
leftType,
5497
TypeWithState
rightType,
5500
var
inferredResult = ReinferAndVisitBinaryOperator(binary, binary.OperatorKind, binary.BinaryOperatorMethod, binary.Type, binary.Left, leftOperand, leftConversion, leftType, binary.Right, rightOperand, rightConversion, rightType);
5504
private
TypeWithState
ReinferAndVisitBinaryOperator(
5512
TypeWithState
leftType,
5516
TypeWithState
rightType)
5526
TypeWithState
leftUnderlyingType = GetNullableUnderlyingTypeIfNecessary(isLifted, leftType);
5527
TypeWithState
rightUnderlyingType = GetNullableUnderlyingTypeIfNecessary(isLifted, rightType);
5549
TypeWithState
operandType)
5582
var
inferredResult = InferResultNullability(operatorKind, method, returnType, leftType, rightType);
5592
TypeWithState
leftUnderlyingType,
5593
TypeWithState
rightUnderlyingType)
5658
private
TypeWithState
VisitBinaryOperatorOperandConversion(
5659
BoundExpression expr, BoundExpression operand, Conversion conversion, ParameterSymbol parameter,
TypeWithState
operandType, bool isLifted,
5683
private void VisitBinaryOperatorOperandConversionAndPostConditions(BoundExpression expr, BoundExpression operand, Conversion conversion, ParameterSymbol parameter,
TypeWithState
operandType, bool isLifted)
5686
TypeWithState
resultType = VisitBinaryOperatorOperandConversion(expr, operand, conversion, parameter, operandType, isLifted, out parameterAnnotations);
5702
var
leftType = ResultType;
5707
var
rightType = ResultType;
6061
TypeWithState
rightResult = VisitOptionalImplicitConversion(rightOperand, targetType, useLegacyWarnings: UseLegacyWarnings(leftOperand), trackMembers: false, AssignmentKind.Assignment);
6066
TypeWithState
resultType =
TypeWithState
.Create(targetType.Type, rightResult.State);
6082
var
rightUnconditionalResult = ResultType;
6085
SetResultType(node,
TypeWithState
.Create(node.Type, rightUnconditionalResult.State));
6090
TypeWithState
leftResult = ResultType;
6101
TypeWithState
rightResult = ResultType;
6119
SetResultType(node,
TypeWithState
.Create(resultType, rightResult.State.Join(leftState)));
6145
var
conversionResult = VisitConversion(
6152
TypeWithState
.Create(leftType, NullableFlowState.NotNull),
6184
var
operandType = ResultType;
6189
var
result = VisitConversion(boundConversion,
6336
SetResultType(node,
TypeWithState
.Create(resultType, NullableFlowState.MaybeDefault));
6372
TypeWithState
consequenceRValue;
6373
TypeWithState
alternativeRValue;
6412
SetResult(node,
TypeWithState
.Create(refResultType, rValueState), TypeWithAnnotations.Create(refResultType, lValueAnnotation));
6476
SetResultType(node,
TypeWithState
.Create(resultType, default));
6487
TypeWithState
typeWithState = convertArms(
6494
TypeWithState
convertArms(
6496
TypeWithState
consequenceRValue,
TypeWithState
alternativeRValue, BoundExpression consequence, Conversion consequenceConversion, bool consequenceEndReachable,
6502
TypeWithState
convertedConsequenceResult = ConvertConditionalOperandOrSwitchExpressionArmResult(
6511
TypeWithState
convertedAlternativeResult = ConvertConditionalOperandOrSwitchExpressionArmResult(
6521
var
typeWithState =
TypeWithState
.Create(resultTypeWithAnnotations.Type, resultState);
6534
return
TypeWithState
.Create(resultTypeWithAnnotations.Type, resultState);
6544
TypeWithState
consequenceRValue,
6545
TypeWithState
alternativeRValue,
6563
(BoundExpression, Conversion,
TypeWithState
) visitConditionalOperand(LocalState state, BoundExpression operand)
6576
(TypeWithAnnotations LValueType,
TypeWithState
RValueType) visitConditionalRefOperand(LocalState state, BoundExpression operand)
6593
private
TypeWithState
ConvertConditionalOperandOrSwitchExpressionArmResult(
6598
TypeWithState
operandType,
6615
var
resultType = VisitConversion(
6659
SetResultType(node,
TypeWithState
.Create(rvalueType, NullableFlowState.NotNull));
6685
TypeWithState
receiverType = visitAndCheckReceiver(node);
6759
TypeWithState
receiverType = visitAndCheckReceiver(node);
6787
TypeWithState
visitAndCheckReceiver(BoundCall node)
6797
void reinferMethodAndVisitArguments(BoundCall node,
TypeWithState
receiverType, VisitResult? firstArgumentResult = null)
6838
var
returnState = GetReturnTypeWithState(method);
6849
private
TypeWithState
VisitAndCheckReceiver(BoundExpression? receiverOpt, MethodSymbol method)
6851
TypeWithState
receiverType = default;
6866
TypeWithState
receiverType,
6984
private void LearnFromEqualsMethod(MethodSymbol method, BoundCall node,
TypeWithState
receiverType, ImmutableArray<VisitResult> results)
7120
void learnFromEqualsMethodArguments(BoundExpression left,
TypeWithState
leftType, BoundExpression right,
TypeWithState
rightType)
7221
private void CheckCallReceiver(BoundExpression? receiverOpt,
TypeWithState
receiverType, MethodSymbol method)
7254
private
TypeWithState
GetReturnTypeWithState(MethodSymbol method)
7256
return
TypeWithState
.Create(method.ReturnTypeWithAnnotations, GetRValueAnnotations(method));
7326
private static
TypeWithState
ApplyUnconditionalAnnotations(
TypeWithState
typeWithState, FlowAnalysisAnnotations annotations)
7330
return
TypeWithState
.Create(typeWithState.Type, NullableFlowState.NotNull);
7335
return
TypeWithState
.Create(typeWithState.Type, NullableFlowState.MaybeDefault);
7655
TrackAnalyzedNullabilityThroughConversionGroup(
TypeWithState
.Create(argument.Type, result.RValueType.State), argument as BoundConversion, argumentNoConversion);
8066
var
resultType = result.RValueType;
8084
var
stateAfterConversion = VisitConversion(
8139
private bool CheckDisallowedNullAssignment(
TypeWithState
state, FlowAnalysisAnnotations annotations, SyntaxNode node, BoundExpression? boundValueOpt = null)
8157
private static bool IsDisallowedNullAssignment(
TypeWithState
valueState, FlowAnalysisAnnotations targetAnnotations)
8215
var
parameterWithState =
TypeWithState
.Create(parameterType, parameterAnnotations);
8219
parameterWithState =
TypeWithState
.Create(parameterType.Type, adjustedState);
8242
var
parameterWithState =
TypeWithState
.Create(parameterType, parameterAnnotations);
8245
var
worstCaseParameterWithState = applyPostConditionsUnconditionally(parameterWithState, parameterAnnotations);
8306
void trackNullableStateForAssignment(BoundExpression parameterValue, TypeWithAnnotations lValueType, int targetSlot,
TypeWithState
parameterWithState, bool isSuppressed, FlowAnalysisAnnotations parameterAnnotations)
8337
static
TypeWithState
applyPostConditionsUnconditionally(
TypeWithState
typeWithState, FlowAnalysisAnnotations annotations)
8342
return
TypeWithState
.Create(typeWithState.Type, NullableFlowState.MaybeDefault);
8348
return
TypeWithState
.Create(typeWithState.Type, NullableFlowState.NotNull);
8354
static
TypeWithState
applyPostConditionsWhenTrue(
TypeWithState
typeWithState, FlowAnalysisAnnotations annotations)
8363
return
TypeWithState
.Create(typeWithState.Type, NullableFlowState.MaybeDefault);
8367
return
TypeWithState
.Create(typeWithState.Type, NullableFlowState.NotNull);
8373
static
TypeWithState
applyPostConditionsWhenFalse(
TypeWithState
typeWithState, FlowAnalysisAnnotations annotations)
8382
return
TypeWithState
.Create(typeWithState.Type, NullableFlowState.MaybeDefault);
8386
return
TypeWithState
.Create(typeWithState.Type, NullableFlowState.NotNull);
8674
if (_walker.TryGetMethodGroupReceiverNullability(group.ReceiverOpt, out
TypeWithState
receiverType))
8951
private
TypeWithState
GetAdjustedResult(
TypeWithState
type, int slot)
8956
return
TypeWithState
.Create(type.Type, state);
9112
private
TypeWithState
VisitOptionalImplicitConversion(BoundExpression expr, TypeWithAnnotations targetTypeOpt, bool useLegacyWarnings, bool trackMembers, AssignmentKind assignmentKind)
9124
private (
TypeWithState
resultType, Func<TypeWithAnnotations,
TypeWithState
>? completion) VisitOptionalImplicitConversion(
9134
var
operandType = VisitRvalueWithState(operand);
9138
(
TypeWithState
resultType, Func<TypeWithAnnotations,
TypeWithState
>? completion) visitConversion(
9143
Conversion conversion,
TypeWithState
operandType,
9148
return (
TypeWithState
.Create(targetTypeOpt), visitConversionAsContinuation(expr, useLegacyWarnings, trackMembers, assignmentKind, operand, conversion, operandType));
9158
var
resultType = VisitConversion(
9175
Func<TypeWithAnnotations,
TypeWithState
> visitConversionAsContinuation(BoundExpression expr, bool useLegacyWarnings, bool trackMembers, AssignmentKind assignmentKind, BoundExpression operand, Conversion conversion,
TypeWithState
operandType)
9225
ImmutableArray<
TypeWithState
> elementTypes = arguments.SelectAsArray((a, w) => w.VisitRvalueWithState(a), this);
9230
SetResultType(node,
TypeWithState
.Create(null, NullableFlowState.NotNull));
9255
SetResultType(node,
TypeWithState
.Create(tupleOpt, NullableFlowState.NotNull));
9268
ImmutableArray<
TypeWithState
> types,
9298
void trackState(BoundExpression value, FieldSymbol field,
TypeWithState
valueType)
9312
private void TrackNullableStateOfNullableValue(int containingSlot, TypeSymbol containingType, BoundExpression? value,
TypeWithState
valueType, int valueSlot)
9406
var
convertedType = VisitUserDefinedConversion(
9579
private
TypeWithState
VisitConversion(
9584
TypeWithState
operandType,
9604
if (TargetTypedAnalysisCompletion.TryGetValue(conversionOperand, out Func<TypeWithAnnotations,
TypeWithState
>? completion))
9686
return
TypeWithState
.Create(targetType, NullableFlowState.NotNull);
9901
TypeWithState
resultType = calculateResultType(targetTypeWithNullability, fromExplicitCast, resultState, isSuppressed, targetType);
9935
static
TypeWithState
calculateResultType(TypeWithAnnotations targetTypeWithNullability, bool fromExplicitCast, NullableFlowState resultState, bool isSuppressed, TypeSymbol targetType)
9947
var
resultType =
TypeWithState
.Create(targetType, resultState);
9951
static NullableFlowState getReferenceConversionResultState(TypeWithAnnotations targetType,
TypeWithState
operandType)
9985
static NullableFlowState getBoxingConversionResultState(TypeWithAnnotations targetType,
TypeWithState
operandType)
10013
static NullableFlowState getUnboxingConversionResultState(
TypeWithState
operandType)
10023
static NullableFlowState getConversionResultState(
TypeWithState
operandType)
10139
private
TypeWithState
VisitUserDefinedConversion(
10144
TypeWithState
operandType,
10163
var
resultType =
TypeWithState
.Create(targetType, NullableFlowState.NotNull);
10195
TypeWithState
underlyingOperandType = default;
10303
private void TrackAnalyzedNullabilityThroughConversionGroup(
TypeWithState
resultType, BoundConversion? conversionOpt, BoundExpression convertedNode)
10326
private
TypeWithState
GetLiftedReturnType(TypeWithAnnotations returnType, NullableFlowState operandState)
10331
return
TypeWithState
.Create(type, state);
10334
private static
TypeWithState
GetNullableUnderlyingTypeIfNecessary(bool isLifted,
TypeWithState
typeWithState)
10347
private
TypeWithState
GetLiftedReturnTypeIfNecessary(bool isLifted, TypeWithAnnotations returnType, NullableFlowState operandState)
10359
private
TypeWithState
ClassifyAndVisitConversion(
10362
TypeWithState
operandType,
10437
TypeWithState
result = setAnalyzedNullability(node, delegateType, analysisCompletion, node.WasTargetTyped);
10441
TypeWithState
setAnalyzedNullability(BoundDelegateCreationExpression node, NamedTypeSymbol delegateType, Action<NamedTypeSymbol>? analysisCompletion, bool isTargetTyped)
10443
var
result =
TypeWithState
.Create(delegateType, NullableFlowState.NotNull);
10543
var
argState = VisitRvalueWithState(arg);
10596
private bool TryGetMethodGroupReceiverNullability([NotNullWhen(true)] BoundExpression? receiverOpt, out
TypeWithState
type)
10611
private void SetMethodGroupReceiverNullability(BoundExpression receiver,
TypeWithState
type)
10613
_methodGroupReceiverMapOpt ??= PooledDictionary<BoundExpression,
TypeWithState
>.GetInstance();
10622
if (TryGetMethodGroupReceiverNullability(receiverOpt, out
TypeWithState
receiverType))
10740
var
rvalueResult =
TypeWithState
.Create(node.Type, NullableFlowState.NotNull);
10750
var
typeWithState = GetParameterState(parameterType, parameter.FlowAnalysisAnnotations);
10793
TypeWithState
rightState;
10816
SetResult(node,
TypeWithState
.Create(leftLValueType.Type, rightState.State), leftLValueType);
10836
var
rValueType = ApplyUnconditionalAnnotations(type.ToTypeWithState(), annotations);
10845
private void AdjustSetValue(BoundExpression left, ref
TypeWithState
rightState)
10939
private BoundNode? VisitDeconstructionAssignmentOperator(BoundDeconstructionAssignmentOperator node,
TypeWithState
? rightResultOpt)
10969
private void VisitDeconstructionArguments(ArrayBuilder<DeconstructionVariable> variables, Conversion conversion, BoundExpression right,
TypeWithState
? rightResultOpt = null)
10983
private void VisitDeconstructMethodArguments(ArrayBuilder<DeconstructionVariable> variables, Conversion conversion, BoundExpression right,
TypeWithState
? rightResultOpt)
10992
var
rightResult = ResultType;
11082
private void VisitTupleDeconstructionArguments(ArrayBuilder<DeconstructionVariable> variables, ImmutableArray<(BoundValuePlaceholder? placeholder, BoundExpression? conversion)> deconstructConversionInfo, BoundExpression right,
TypeWithState
? rightResultOpt)
11105
TypeWithState
operandType;
11106
TypeWithState
valueType;
11158
var
valueBeforeNullableWrapping =
TypeWithState
.Create(underlyingType.Type, NullableFlowState.NotNull);
11215
private ImmutableArray<BoundExpression> GetDeconstructionRightParts(BoundExpression expr,
TypeWithState
? rightResultOpt)
11268
TypeWithState
receiverType = VisitAndCheckReceiver(node.Operand, instanceMethod);
11291
SetResultType(node,
TypeWithState
.Create(receiverType.Type, NullableFlowState.NotNull));
11295
SetResultType(node,
TypeWithState
.Create(results[0].RValueType.Type, GetState(ref State, extensionReceiverSlot)));
11307
var
opType = VisitRvalueWithState(node.Operand);
11315
SetResultType(node,
TypeWithState
.Create(opType.Type, NullableFlowState.NotNull));
11322
var
operandType = VisitRvalueWithState(node.Operand);
11366
TypeWithState
resultOfOperandConversionType;
11390
TypeWithState
resultOfIncrementType;
11416
TypeWithState
resultType = (op == UnaryOperatorKind.PrefixIncrement || op == UnaryOperatorKind.PrefixDecrement) ? resultOfIncrementType : operandType;
11449
TypeWithState
receiverType = VisitAndCheckReceiver(node.Left, instanceMethod);
11472
SetResultType(node,
TypeWithState
.Create(receiverType.Type, NullableFlowState.NotNull));
11476
SetResultType(node,
TypeWithState
.Create(results[0].RValueType.Type, GetState(ref State, extensionReceiverSlot)));
11489
var
opType = ResultType;
11500
SetResultType(node,
TypeWithState
.Create(opType.Type, NullableFlowState.NotNull));
11510
var
leftTypeWithState = ResultType;
11518
var
rightTypeWithState = VisitRvalueWithState(rightConversionOperand);
11525
var
resultTypeWithState = ReinferAndVisitBinaryOperator(
11578
SetResultType(node.Expression,
TypeWithState
.Create(node.Expression.Type, ResultType.State));
11679
TypeWithState
typeWithState = ApplyUnconditionalAnnotations(typeWithAnnotations.ToTypeWithState(), memberAnnotations);
11722
var
resultType = ApplyUnconditionalAnnotations(indexer.TypeWithAnnotations.ToTypeWithState(), GetRValueAnnotations(indexer));
11786
var
receiverType = (receiverOpt != null) ? VisitRvalueWithState(receiverOpt) : default;
11801
var
resultType = ApplyUnconditionalAnnotations(type.ToTypeWithState(), memberAnnotations);
11811
resultType =
TypeWithState
.Create(resultType.Type, state);
11913
var
resultTypeWithState = VisitRvalueWithState(expr);
11983
var
convertedResult = VisitConversion(
12001
TypeWithState
currentPropertyGetterTypeWithState;
12042
var
enumeratorReturnType = GetReturnTypeWithState(reinferredGetEnumeratorMethod);
12098
var
sourceState = node.EnumeratorInfoOpt == null ? default : ResultType;
12115
VisitDeconstructionAssignmentOperator(assignment, sourceState.HasNullType ? (
TypeWithState
?)null : sourceState);
12129
TypeWithState
result = sourceState;
12130
TypeWithState
resultForType = sourceState;
12221
private
TypeWithState
VisitBadExpressionChild(BoundExpression? child)
12263
TypeWithState
resultType;
12295
var
operandResult = ResultType;
12297
var
operandType = GetNullableUnderlyingTypeIfNecessary(isLifted, operandResult);
12328
TypeWithState
adjustForLifting(
TypeWithState
argumentResult) =>
12329
TypeWithState
.Create(node.Type, node.OperatorKind.IsLifted() ? argumentResult.State : NullableFlowState.NotNull);
12335
private MethodSymbol ReInferUnaryOperator(SyntaxNode syntax, MethodSymbol method, BoundExpression operand,
TypeWithState
operandType)
12470
TypeWithState
leftType = ResultType;
12479
TypeWithState
rightType = ResultType;
12486
TypeWithState
leftType = ResultType;
12501
var
rightType = ResultType;
12509
TypeWithState
leftUnderlyingType = GetNullableUnderlyingTypeIfNecessary(isLifted, leftType);
12510
TypeWithState
rightUnderlyingType = GetNullableUnderlyingTypeIfNecessary(isLifted, rightType);
12597
SetResultType(node,
TypeWithState
.Create(node.Type, NullableFlowState.NotNull));
12619
SetResultType(node,
TypeWithState
.Create(node.Type, NullableFlowState.MaybeDefault));
12639
SetResultType(node,
TypeWithState
.ForType(type));
12679
var
argumentType = VisitRvalueWithState(node.Operand);
12701
SetResultType(node,
TypeWithState
.Create(type, resultState));
12733
SetResultType(node,
TypeWithState
.Create(node.Type, node.Type?.CanContainNull() != false && node.ConstantValueOpt?.IsNull == true ? NullableFlowState.MaybeDefault : NullableFlowState.NotNull));
12808
if (TryGetMethodGroupReceiverNullability(receiverOpt, out
TypeWithState
receiverType))
12910
SetResultType(expression,
TypeWithState
.Create(expression.Type, default));
12932
private bool CheckPossibleNullReceiver(BoundExpression? receiverOpt,
TypeWithState
resultType, bool checkNullableValueType)
12976
private void CheckExtensionMethodThisNullability(BoundExpression expr, Conversion conversion, ParameterSymbol parameter,
TypeWithState
result)
13017
SetResultType(node,
TypeWithState
.Create(node.Type, NullableFlowState.NotNull));
13032
SetResultType(node,
TypeWithState
.Create(node.Type, NullableFlowState.NotNull));
13081
SetResultType(node,
TypeWithState
.Create(node.Type, NullableFlowState.NotNull));
13087
SetResultType(node,
TypeWithState
.Create(type, NullableFlowState.NotNull));
13094
var
rValueType =
TypeWithState
.ForType(node.Type);
13116
var
result = VisitRvalueWithState(expr);
13246
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(