192 references to IsNullableType
Microsoft.CodeAnalysis.CSharp (192)
Binder\Binder_Conversions.cs (6)
320
if (destination.
IsNullableType
())
322
switch (source.Type?.
IsNullableType
())
352
else if (source.Type?.
IsNullableType
() == true)
2105
if (conversionToType.
IsNullableType
() && TypeSymbol.Equals(conversionToType.GetNullableUnderlyingType(), conversionReturnType, TypeCompareKind.ConsiderEverything2))
2429
Debug.Assert(conversion.IsNullable == destination.
IsNullableType
());
3171
if (destination.
IsNullableType
())
Binder\Binder_Expressions.cs (12)
2540
if (targetType.
IsNullableType
() &&
2543
!operand.Type.
IsNullableType
() &&
2565
if ((object)boundOperand.Type != null && boundOperand.Type.
IsNullableType
())
2644
if (left?.Type.
IsNullableType
() == true || right?.Type.
IsNullableType
() == true)
2672
if (boundOperand.Type?.
IsNullableType
() == true)
2745
if (!targetType.IsReferenceType && !targetType.
IsNullableType
() && operand.IsLiteralNull())
2880
Debug.Assert((object)operand.Type != null && !operand.Type.
IsNullableType
());
5143
if (typeWithAnnotations.NullableAnnotation.IsAnnotated() && !type.
IsNullableType
())
11023
if (accessType.IsValueType && !accessType.
IsNullableType
() && !accessType.IsVoidType())
11094
if (receiverType?.
IsNullableType
() == true)
11140
if (receiverType.IsValueType && !receiverType.
IsNullableType
())
Binder\Binder_Operators.cs (9)
731
(leftNull && (object)rightType != null && rightType.
IsNullableType
() ||
732
rightNull && (object)leftType != null && leftType.
IsNullableType
());
3605
if (targetType.
IsNullableType
())
3610
Debug.Assert(operandType.
IsNullableType
());
3667
Debug.Assert(targetType.
IsNullableType
());
3740
else if (!targetType.IsReferenceType && !targetType.
IsNullableType
())
4011
bool isLeftNullable = (object)optLeftType != null && optLeftType.
IsNullableType
();
4189
if (leftType.IsValueType && !leftType.
IsNullableType
())
4199
if (leftType.
IsNullableType
())
Binder\Binder_Patterns.cs (2)
690
if (inputType.
IsNullableType
() && (convertedExpression.ConstantValueOpt == null || !convertedExpression.ConstantValueOpt.IsNull))
740
else if (patternType.
IsNullableType
())
Binder\Binder_TupleOperators.cs (2)
247
bool leftNullable = left.Type?.
IsNullableType
() == true;
248
bool rightNullable = right.Type?.
IsNullableType
() == true;
Binder\ForEachLoopBinder.cs (3)
544
(builder.ElementType.
IsNullableType
() && builder.ElementType.GetMemberTypeArgumentsNoUseSiteDiagnostics().Single().IsErrorType() && collectionExpr.Type.IsArray()));
704
if ((object)collectionExprType != null && collectionExprType.
IsNullableType
())
908
(originalCollectionExpr.Type?.
IsNullableType
() == true && originalCollectionExpr.Type.StrippedType().Equals(collectionExpr.Type, TypeCompareKind.AllIgnoreOptions)));
Binder\PatternExplainer.cs (1)
357
input.Type.
IsNullableType
() && input.Type.GetNullableUnderlyingType().Equals(evaluationType, TypeCompareKind.AllIgnoreOptions))
Binder\Semantics\Conversions\Conversions.cs (2)
342
else if (method.ContainingType.
IsNullableType
() && !method.IsOverride)
463
if (method.ContainingType.
IsNullableType
() && !method.IsOverride)
Binder\Semantics\Conversions\ConversionsBase.cs (9)
1242
if (destination.
IsNullableType
())
1453
destination.
IsNullableType
() && destination.GetNullableUnderlyingType().IsEnumType();
2249
if (!destination.
IsNullableType
())
2446
if (!source.
IsNullableType
() && !destination.
IsNullableType
())
3325
if (source.
IsNullableType
())
3836
if (destination.IsValueType && !destination.
IsNullableType
())
3846
!destination.
IsNullableType
() &&
3862
destination.
IsNullableType
() &&
Binder\Semantics\Conversions\UserDefinedExplicitConversions.cs (5)
275
source.
IsNullableType
() &&
284
target.
IsNullableType
() &&
317
if ((object)source != null && source.
IsNullableType
() && convertsFrom.IsValidNullableTypeArgument() && target.CanBeAssignedNull())
345
if (target.
IsNullableType
() && convertsTo.IsValidNullableTypeArgument())
351
if ((object)source != null && source.
IsNullableType
() && convertsFrom.IsValidNullableTypeArgument())
Binder\Semantics\Conversions\UserDefinedImplicitConversions.cs (2)
318
if ((object)target != null && target.
IsNullableType
() && convertsTo.IsValidNullableTypeArgument())
327
else if ((object)source != null && source.
IsNullableType
() && convertsFrom.IsValidNullableTypeArgument() &&
Binder\Semantics\OverloadResolution\OverloadResolution.cs (2)
3713
if ((object)type != null && type.
IsNullableType
())
3734
if ((object)type != null && type.
IsNullableType
())
BoundTree\BoundNullCoalescingAssignmentOperator.cs (1)
16
if (leftType?.
IsNullableType
() != true)
CodeGen\EmitAddress.cs (1)
44
Debug.Assert(!expression.Type.IsValueType || expression.Type.
IsNullableType
());
CodeGen\EmitConversion.cs (1)
288
Debug.Assert(!conversion.Type.
IsNullableType
());
CodeGen\EmitExpression.cs (4)
54
!expression.Type.
IsNullableType
()))
412
(receiverType.
IsNullableType
() && expression.HasValueMethodOpt != null), "conditional receiver cannot be a struct");
522
Debug.Assert(receiver.Type.
IsNullableType
());
2191
if (methodContainingType.
IsNullableType
())
CodeGen\EmitStatement.cs (1)
1236
Debug.Assert(!dispatch.Expression.Type.
IsNullableType
());
Compilation\CSharpSemanticModel.cs (2)
3859
((binaryOperator.Left.IsLiteralNull() && binaryOperator.Right.Type.
IsNullableType
()) ||
3860
(binaryOperator.Right.IsLiteralNull() && binaryOperator.Left.Type.
IsNullableType
())) &&
FlowAnalysis\AbstractFlowPass.cs (1)
1476
return t.
IsNullableType
();
FlowAnalysis\NullableWalker.cs (16)
3991
else if (type.
IsNullableType
())
5349
if (receiverType.
IsNullableType
())
5840
oldType.
IsNullableType
() && !accessType.
IsNullableType
() ? MakeNullableOf(accessTypeWithAnnotations) :
5857
if (slot > 0 && receiver.Type?.
IsNullableType
() == true)
6164
if (rvalueType?.
IsNullableType
() == true)
6551
type?.
IsNullableType
() == true &&
8386
if (nullableTypeOpt?.
IsNullableType
() == true &&
8387
underlyingTypeOpt?.
IsNullableType
() == false)
9016
if (operandType.Type?.
IsNullableType
() == true && !targetType.
IsNullableType
())
9139
else if (fromExplicitCast && targetTypeWithNullability.NullableAnnotation.IsAnnotated() && !targetType.
IsNullableType
())
9389
if (operandType.Type.
IsNullableType
() && !parameterType.IsNullableType())
9530
if (type?.
IsNullableType
() == true)
10633
parameterOpt?.Type.IsNonNullableValueType() == true && parameterType.
IsNullableType
() ? parameterOpt.Type : parameterType, // Compensate for operator lifting
10828
Debug.Assert(containingType.
IsNullableType
());
Lowering\ClosureConversion\ExpressionLambdaRewriter.cs (3)
608
var promotedType = e.
IsNullableType
() ? _nullableType.Construct(PromotedType(e.GetNullableUnderlyingType())) : PromotedType(e);
706
var resultType = (isLifted && method.ReturnType.IsNonNullableValueType() && node.Type.
IsNullableType
()) ?
725
if (node.Operand.Type.
IsNullableType
())
Lowering\DiagnosticsPass_Warnings.cs (3)
620
if (from.
IsNullableType
())
625
if (to.
IsNullableType
())
858
if ((object)node.Type == null || !node.Type.
IsNullableType
())
Lowering\Extensions.cs (3)
45
if (!expr.Type.
IsNullableType
())
85
if ((object)expr.Type == null || !expr.Type.
IsNullableType
())
132
if (expr.Type.
IsNullableType
() && expr.Type.GetNullableUnderlyingType().SpecialType != SpecialType.System_Boolean)
Lowering\LocalRewriter\LocalRewriter.cs (1)
260
if (type?.
IsNullableType
() != true)
Lowering\LocalRewriter\LocalRewriter.PatternLocalRewriter.cs (4)
344
return MakeNullCheck(d.Syntax, input, input.Type.
IsNullableType
() ? BinaryOperatorKind.NullableNullNotEqual : BinaryOperatorKind.NotEqual);
351
return MakeNullCheck(d.Syntax, input, input.Type.
IsNullableType
() ? BinaryOperatorKind.NullableNullEqual : BinaryOperatorKind.Equal);
354
Debug.Assert(!input.Type.
IsNullableType
());
358
Debug.Assert(!input.Type.
IsNullableType
());
Lowering\LocalRewriter\LocalRewriter_AsOperator.cs (2)
45
Debug.Assert(!rewrittenType.IsValueType || rewrittenType.
IsNullableType
());
61
BoundExpression result = rewrittenType.
IsNullableType
() ? new BoundDefaultExpression(syntax, rewrittenType) : MakeLiteral(syntax, constantValue, rewrittenType);
Lowering\LocalRewriter\LocalRewriter_BinaryOperator.cs (3)
894
if (expression.Type.
IsNullableType
())
917
if (expression.Type.
IsNullableType
())
2106
else if (exprType.
IsNullableType
())
Lowering\LocalRewriter\LocalRewriter_CompoundAssignmentOperator.cs (2)
906
if (expression.Type.
IsNullableType
())
920
if (method.ContainingType?.
IsNullableType
() == true)
Lowering\LocalRewriter\LocalRewriter_ConditionalAccess.cs (3)
133
if (!TypeSymbol.Equals(accessExpressionType, nodeType, TypeCompareKind.ConsiderEverything2) && nodeType.
IsNullableType
())
153
receiverType.
IsNullableType
() ?
207
if (newtarget.Type.
IsNullableType
())
Lowering\LocalRewriter\LocalRewriter_Conversion.cs (23)
50
if (node.Type.
IsNullableType
())
461
if (rewrittenType.
IsNullableType
())
490
if (!rewrittenType.
IsNullableType
() &&
898
if (rewrittenOperand.Type.
IsNullableType
() &&
900
!userDefinedConversionRewrittenType.
IsNullableType
() &&
996
if (!expression.Type.
IsNullableType
())
1013
when underlying.Length == 1 && underlying[0].Kind == ConversionKind.ImplicitTuple && !convertedArgument.Type!.
IsNullableType
():
1050
Debug.Assert(rewrittenType.
IsNullableType
() || rewrittenOperandType.
IsNullableType
());
1052
if (rewrittenOperandType.
IsNullableType
() && rewrittenType.
IsNullableType
())
1056
else if (rewrittenType.
IsNullableType
())
1100
Debug.Assert(rewrittenType.
IsNullableType
() || rewrittenOperandType.
IsNullableType
());
1118
rewrittenOperandType = rewrittenOperandType.
IsNullableType
() ? ((NamedTypeSymbol)rewrittenOperandType.OriginalDefinition).Construct(typeFromUnderlying) : typeFromUnderlying;
1346
if (rewrittenOperand.Type.
IsNullableType
())
1350
!parameterType.
IsNullableType
() &&
1383
Debug.Assert(resultType.
IsNullableType
() && TypeSymbol.Equals(resultType.GetNullableUnderlyingType(), call.Method.ReturnType, TypeCompareKind.ConsiderEverything2));
1413
Debug.Assert(rewrittenOperand.Type.
IsNullableType
());
1509
if (source.
IsNullableType
() && target.
IsNullableType
())
1511
Debug.Assert(target.
IsNullableType
());
1514
else if (source.
IsNullableType
())
Lowering\LocalRewriter\LocalRewriter_FixedStatement.cs (3)
332
bool needNullCheck = !initializerType.IsValueType || initializerType.
IsNullableType
();
338
if (initializerType.
IsNullableType
())
385
if (initializerType.
IsNullableType
())
Lowering\LocalRewriter\LocalRewriter_Index.cs (2)
29
if (!node.Type.
IsNullableType
())
71
Debug.Assert(targetNullableType.
IsNullableType
());
Lowering\LocalRewriter\LocalRewriter_NullCoalescingAssignmentOperator.cs (1)
63
Debug.Assert(node.LeftOperand.Type.
IsNullableType
());
Lowering\LocalRewriter\LocalRewriter_NullCoalescingOperator.cs (5)
110
if (whenNullOpt.Type.
IsNullableType
())
133
if (rewrittenLeft.Type.
IsNullableType
() &&
243
Debug.Assert(rewrittenLeftType.
IsNullableType
() || !rewrittenLeftType.IsValueType);
250
var conversionTakesNullableType = leftPlaceholder?.Type?.
IsNullableType
() == true;
253
&& rewrittenLeftType.
IsNullableType
()
Lowering\LocalRewriter\LocalRewriter_Range.cs (6)
44
if (node.Type.
IsNullableType
())
67
if (operand.Type.
IsNullableType
())
79
Debug.Assert(node.Type.
IsNullableType
());
80
Debug.Assert(left?.Type?.
IsNullableType
() == true || right?.Type?.
IsNullableType
() == true);
133
if (tempOperand.Type.
IsNullableType
())
Lowering\LocalRewriter\LocalRewriter_TupleBinaryOperator.cs (8)
90
expr.Type is { } exprType && exprType.
IsNullableType
() && exprType.StrippedType().Equals(o.Type, TypeCompareKind.AllIgnoreOptions):
205
case BoundObjectCreationExpression { Arguments: { Length: 0 }, Type: { } eType } _ when eType.
IsNullableType
():
207
case BoundObjectCreationExpression { Arguments: { Length: 1 }, Type: { } eType } creation when eType.
IsNullableType
():
356
isNullable = !(expr is BoundTupleExpression) && expr.Type is { } && expr.Type.
IsNullableType
();
404
when expr.Type.
IsNullableType
() && o.Type is { } && o.Type.
IsNullableType
() && !underlying[0].IsUserDefined:
438
expr.Type is { } exprType && exprType.
IsNullableType
() && o.Type is { } && o.Type.
IsNullableType
() && nested[0] is { IsTupleConversion: true } tupleConversion:
Lowering\LocalRewriter\LocalRewriter_UnaryOperator.cs (3)
791
else if (unaryOperandType.
IsNullableType
() && unaryOperandType.GetNullableUnderlyingType().SpecialType == SpecialType.System_Decimal)
833
Debug.Assert(operand.Type is { } && operand.Type.
IsNullableType
() && operand.Type.GetNullableUnderlyingType().SpecialType == SpecialType.System_Decimal);
1020
if (underlyingType.
IsNullableType
())
Lowering\LocalRewriter\LocalRewriter_UsingStatement.cs (1)
359
bool isNullableValueType = local.Type.
IsNullableType
();
Lowering\SyntheticBoundNodeFactory.cs (2)
1508
arg.Type.
IsNullableType
() &&
1778
else if (exprType.
IsNullableType
())
Operations\CSharpOperationFactory.cs (2)
2817
isLifted: boundIndex.Type.
IsNullableType
(),
2834
isLifted: boundRange.Type.
IsNullableType
(),
Symbols\ConstraintsHelper.cs (2)
477
else if (deducedBase.
IsNullableType
() && (typeParameter.HasValueTypeConstraint || typeParameter.HasReferenceTypeConstraint))
1343
if (conversions.HasBoxingConversion(typeArgument.Type.
IsNullableType
() ? ((NamedTypeSymbol)typeArgument.Type).ConstructedFrom : typeArgument.Type,
Symbols\PublicModel\TypeSymbol.cs (1)
70
!(UnderlyingTypeSymbol.IsValueType && !UnderlyingTypeSymbol.
IsNullableType
()))
Symbols\Source\ParameterHelpers.cs (2)
804
else if (((conversion.IsNullable && !defaultExpression.Type.
IsNullableType
()) ||
805
(conversion.IsObjectCreation && convertedExpression.Type.
IsNullableType
())) &&
Symbols\Source\SourceComplexParameterSymbol.cs (1)
402
if (Type.
IsNullableType
())
Symbols\TypeSymbolExtensions.cs (7)
40
return type.IsReferenceType || type.IsPointerOrFunctionPointer() || type.
IsNullableType
();
130
return type.
IsNullableType
();
147
&& !type.
IsNullableType
()
173
RoslynDebug.Assert(
IsNullableType
(type));
181
return type.
IsNullableType
() ? type.GetNullableUnderlyingType() : type;
1332
if (type.
IsNullableType
())
2232
if ((object)type != null && type.
IsNullableType
())
Symbols\TypeWithAnnotations.cs (17)
55
Debug.Assert(defaultType?.
IsNullableType
() != true || defaultAnnotation == NullableAnnotation.Annotated);
97
if (typeSymbol?.
IsNullableType
() == true)
110
if (NullableAnnotation.IsAnnotated() || (Type.IsValueType && Type.
IsNullableType
()))
120
if (NullableAnnotation.IsNotAnnotated() || (Type.IsValueType && !Type.
IsNullableType
()))
264
public bool IsNullableType() => Type.
IsNullableType
();
378
bool isValueType = type.IsValueType && !type.
IsNullableType
();
450
Debug.Assert(newTypeWithModifiers.NullableAnnotation.IsOblivious() || (typeSymbol.
IsNullableType
() && newTypeWithModifiers.NullableAnnotation.IsAnnotated()));
459
else if ((NullableAnnotation.IsOblivious() || (typeSymbol.
IsNullableType
() && NullableAnnotation.IsAnnotated())) &&
615
return type.
IsNullableType
();
710
!(result.NullableAnnotation.IsAnnotated() && oldTypeSymbol.
IsNullableType
())) // Preserve nullable annotation on Nullable<T>.
727
if (NullableAnnotation.IsNotAnnotated() || (typeSymbol.IsValueType && !typeSymbol.
IsNullableType
()))
743
if (!typeSymbol.IsValueType && !typeSymbol.
IsNullableType
())
927
return CreateNonLazyType(defaultType, defaultType.
IsNullableType
() ? type.NullableAnnotation : NullableAnnotation.NotAnnotated, _customModifiers);
1030
return CreateNonLazyType(defaultType, defaultType.
IsNullableType
() ? type.NullableAnnotation : NullableAnnotation.NotAnnotated, _customModifiers);
1103
Debug.Assert(resolvedType.
IsNullableType
() && CustomModifiers.IsEmpty);
1120
if (resolvedType.
IsNullableType
())
1130
if (typeSymbol.
IsNullableType
())