271 references to IsNullableType
Microsoft.CodeAnalysis.CSharp (183)
Binder\Binder_Conversions.cs (3)
589if (conversionToType.IsNullableType() && TypeSymbol.Equals(conversionToType.GetNullableUnderlyingType(), conversionReturnType, TypeCompareKind.ConsiderEverything2)) 897Debug.Assert(conversion.IsNullable == destination.IsNullableType()); 1617if (destination.IsNullableType())
Binder\Binder_Expressions.cs (12)
2330if (targetType.IsNullableType() && 2333!operand.Type.IsNullableType() && 2355if ((object)boundOperand.Type != null && boundOperand.Type.IsNullableType()) 2434if (left?.Type.IsNullableType() == true || right?.Type.IsNullableType() == true) 2462if (boundOperand.Type?.IsNullableType() == true) 2535if (!targetType.IsReferenceType && !targetType.IsNullableType() && operand.IsLiteralNull()) 2665Debug.Assert((object)operand.Type != null && !operand.Type.IsNullableType()); 4435if (typeWithAnnotations.NullableAnnotation.IsAnnotated() && !type.IsNullableType()) 9418if (accessType.IsValueType && !accessType.IsNullableType() && !accessType.IsVoidType()) 9489if (receiverType?.IsNullableType() == true) 9535if (receiverType.IsValueType && !receiverType.IsNullableType())
Binder\Binder_Operators.cs (9)
701(leftNull && (object)rightType != null && rightType.IsNullableType() || 702rightNull && (object)leftType != null && leftType.IsNullableType()); 3533if (targetType.IsNullableType()) 3538Debug.Assert(operandType.IsNullableType()); 3595Debug.Assert(targetType.IsNullableType()); 3668else if (!targetType.IsReferenceType && !targetType.IsNullableType()) 3934bool isLeftNullable = (object)optLeftType != null && optLeftType.IsNullableType(); 4112if (leftType.IsValueType && !leftType.IsNullableType()) 4122if (leftType.IsNullableType())
Binder\Binder_Patterns.cs (2)
681if (inputType.IsNullableType() && (convertedExpression.ConstantValueOpt == null || !convertedExpression.ConstantValueOpt.IsNull)) 731else if (patternType.IsNullableType())
Binder\Binder_TupleOperators.cs (2)
247bool leftNullable = left.Type?.IsNullableType() == true; 248bool rightNullable = right.Type?.IsNullableType() == true;
Binder\ForEachLoopBinder.cs (2)
522(builder.ElementType.IsNullableType() && builder.ElementType.GetMemberTypeArgumentsNoUseSiteDiagnostics().Single().IsErrorType() && collectionExpr.Type.IsArray())); 651if ((object)collectionExprType != null && collectionExprType.IsNullableType())
Binder\PatternExplainer.cs (1)
357input.Type.IsNullableType() && input.Type.GetNullableUnderlyingType().Equals(evaluationType, TypeCompareKind.AllIgnoreOptions))
Binder\Semantics\Conversions\Conversions.cs (2)
244else if (method.ContainingType.IsNullableType() && !method.IsOverride) 364if (method.ContainingType.IsNullableType() && !method.IsOverride)
Binder\Semantics\Conversions\ConversionsBase.cs (9)
1160if (destination.IsNullableType()) 1378destination.IsNullableType() && destination.GetNullableUnderlyingType().IsEnumType(); 2100if (!destination.IsNullableType()) 2297if (!source.IsNullableType() && !destination.IsNullableType()) 3096if (source.IsNullableType()) 3597if (destination.IsValueType && !destination.IsNullableType()) 3607!destination.IsNullableType() && 3623destination.IsNullableType() &&
Binder\Semantics\Conversions\UserDefinedExplicitConversions.cs (5)
270source.IsNullableType() && 279target.IsNullableType() && 312if ((object)source != null && source.IsNullableType() && convertsFrom.IsValidNullableTypeArgument() && target.CanBeAssignedNull()) 340if (target.IsNullableType() && convertsTo.IsValidNullableTypeArgument()) 346if ((object)source != null && source.IsNullableType() && convertsFrom.IsValidNullableTypeArgument())
Binder\Semantics\Conversions\UserDefinedImplicitConversions.cs (2)
313if ((object)target != null && target.IsNullableType() && convertsTo.IsValidNullableTypeArgument()) 322else if ((object)source != null && source.IsNullableType() && convertsFrom.IsValidNullableTypeArgument() &&
Binder\Semantics\OverloadResolution\OverloadResolution.cs (2)
3033if ((object)type != null && type.IsNullableType()) 3054if ((object)type != null && type.IsNullableType())
BoundTree\BoundNullCoalescingAssignmentOperator.cs (1)
16if (leftType?.IsNullableType() != true)
CodeGen\EmitAddress.cs (1)
44Debug.Assert(!expression.Type.IsValueType || expression.Type.IsNullableType());
CodeGen\EmitConversion.cs (1)
287Debug.Assert(!conversion.Type.IsNullableType());
CodeGen\EmitExpression.cs (4)
53!expression.Type.IsNullableType())) 397(receiverType.IsNullableType() && expression.HasValueMethodOpt != null), "conditional receiver cannot be a struct"); 507Debug.Assert(receiver.Type.IsNullableType()); 1971if (methodContainingType.IsNullableType())
CodeGen\EmitStatement.cs (1)
1211Debug.Assert(!dispatch.Expression.Type.IsNullableType());
Compilation\CSharpSemanticModel.cs (2)
3847((binaryOperator.Left.IsLiteralNull() && binaryOperator.Right.Type.IsNullableType()) || 3848(binaryOperator.Right.IsLiteralNull() && binaryOperator.Left.Type.IsNullableType())) &&
FlowAnalysis\AbstractFlowPass.cs (1)
1389return t.IsNullableType();
FlowAnalysis\NullableWalker.cs (16)
3591else if (type.IsNullableType()) 4903if (receiverType.IsNullableType()) 5379oldType.IsNullableType() && !accessType.IsNullableType() ? MakeNullableOf(accessTypeWithAnnotations) : 5396if (slot > 0 && receiver.Type?.IsNullableType() == true) 5670if (rvalueType?.IsNullableType() == true) 5969type?.IsNullableType() == true && 7535if (nullableTypeOpt?.IsNullableType() == true && 7536underlyingTypeOpt?.IsNullableType() == false) 8146if (operandType.Type?.IsNullableType() == true && !targetType.IsNullableType()) 8243else if (fromExplicitCast && targetTypeWithNullability.NullableAnnotation.IsAnnotated() && !targetType.IsNullableType()) 8492if (operandType.Type.IsNullableType() && !parameterType.IsNullableType()) 8630if (type?.IsNullableType() == true) 9761parameterOpt?.Type.IsNonNullableValueType() == true && parameterType.IsNullableType() ? parameterOpt.Type : parameterType, // Compensate for operator lifting 9944Debug.Assert(containingType.IsNullableType());
Lowering\ClosureConversion\ExpressionLambdaRewriter.cs (3)
538var promotedType = e.IsNullableType() ? _nullableType.Construct(PromotedType(e.GetNullableUnderlyingType())) : PromotedType(e); 636var resultType = (isLifted && method.ReturnType.IsNonNullableValueType() && node.Type.IsNullableType()) ? 651if (node.Operand.Type.IsNullableType())
Lowering\DiagnosticsPass_Warnings.cs (3)
620if (from.IsNullableType()) 625if (to.IsNullableType()) 858if ((object)node.Type == null || !node.Type.IsNullableType())
Lowering\Extensions.cs (3)
45if (!expr.Type.IsNullableType()) 85if ((object)expr.Type == null || !expr.Type.IsNullableType()) 132if (expr.Type.IsNullableType() && expr.Type.GetNullableUnderlyingType().SpecialType != SpecialType.System_Boolean)
Lowering\LocalRewriter\LocalRewriter.cs (1)
229if (type?.IsNullableType() != true)
Lowering\LocalRewriter\LocalRewriter.PatternLocalRewriter.cs (4)
344return MakeNullCheck(d.Syntax, input, input.Type.IsNullableType() ? BinaryOperatorKind.NullableNullNotEqual : BinaryOperatorKind.NotEqual); 351return MakeNullCheck(d.Syntax, input, input.Type.IsNullableType() ? BinaryOperatorKind.NullableNullEqual : BinaryOperatorKind.Equal); 354Debug.Assert(!input.Type.IsNullableType()); 358Debug.Assert(!input.Type.IsNullableType());
Lowering\LocalRewriter\LocalRewriter_AsOperator.cs (2)
45Debug.Assert(!rewrittenType.IsValueType || rewrittenType.IsNullableType()); 61BoundExpression result = rewrittenType.IsNullableType() ? new BoundDefaultExpression(syntax, rewrittenType) : MakeLiteral(syntax, constantValue, rewrittenType);
Lowering\LocalRewriter\LocalRewriter_BinaryOperator.cs (3)
881if (expression.Type.IsNullableType()) 900if (expression.Type.IsNullableType()) 2026else if (exprType.IsNullableType())
Lowering\LocalRewriter\LocalRewriter_CompoundAssignmentOperator.cs (2)
890if (expression.Type.IsNullableType()) 904if (method.ContainingType?.IsNullableType() == true)
Lowering\LocalRewriter\LocalRewriter_ConditionalAccess.cs (3)
133if (!TypeSymbol.Equals(accessExpressionType, nodeType, TypeCompareKind.ConsiderEverything2) && nodeType.IsNullableType()) 154receiverType.IsNullableType() ? 210if (newtarget.Type.IsNullableType())
Lowering\LocalRewriter\LocalRewriter_Conversion.cs (23)
50if (node.Type.IsNullableType()) 452if (rewrittenType.IsNullableType()) 481if (!rewrittenType.IsNullableType() && 756if (rewrittenOperand.Type.IsNullableType() && 758!userDefinedConversionRewrittenType.IsNullableType() && 854if (!expression.Type.IsNullableType()) 871when underlying.Length == 1 && underlying[0].Kind == ConversionKind.ImplicitTuple && !convertedArgument.Type!.IsNullableType(): 908Debug.Assert(rewrittenType.IsNullableType() || rewrittenOperandType.IsNullableType()); 910if (rewrittenOperandType.IsNullableType() && rewrittenType.IsNullableType()) 914else if (rewrittenType.IsNullableType()) 958Debug.Assert(rewrittenType.IsNullableType() || rewrittenOperandType.IsNullableType()); 976rewrittenOperandType = rewrittenOperandType.IsNullableType() ? ((NamedTypeSymbol)rewrittenOperandType.OriginalDefinition).Construct(typeFromUnderlying) : typeFromUnderlying; 1199if (rewrittenOperand.Type.IsNullableType()) 1203!parameterType.IsNullableType() && 1231Debug.Assert(resultType.IsNullableType() && TypeSymbol.Equals(resultType.GetNullableUnderlyingType(), call.Method.ReturnType, TypeCompareKind.ConsiderEverything2)); 1261Debug.Assert(rewrittenOperand.Type.IsNullableType()); 1352if (source.IsNullableType() && target.IsNullableType()) 1354Debug.Assert(target.IsNullableType()); 1357else if (source.IsNullableType())
Lowering\LocalRewriter\LocalRewriter_Index.cs (2)
29if (!node.Type.IsNullableType()) 71Debug.Assert(targetNullableType.IsNullableType());
Lowering\LocalRewriter\LocalRewriter_NullCoalescingAssignmentOperator.cs (1)
62Debug.Assert(node.LeftOperand.Type.IsNullableType());
Lowering\LocalRewriter\LocalRewriter_NullCoalescingOperator.cs (5)
112if (whenNullOpt.Type.IsNullableType()) 136if (rewrittenLeft.Type.IsNullableType() 234Debug.Assert(rewrittenLeftType.IsNullableType() || !rewrittenLeftType.IsValueType); 241var conversionTakesNullableType = leftPlaceholder?.Type?.IsNullableType() == true; 244&& rewrittenLeftType.IsNullableType()
Lowering\LocalRewriter\LocalRewriter_Range.cs (6)
44if (node.Type.IsNullableType()) 67if (operand.Type.IsNullableType()) 79Debug.Assert(node.Type.IsNullableType()); 80Debug.Assert(left?.Type?.IsNullableType() == true || right?.Type?.IsNullableType() == true); 133if (tempOperand.Type.IsNullableType())
Lowering\LocalRewriter\LocalRewriter_TupleBinaryOperator.cs (8)
90expr.Type is { } exprType && exprType.IsNullableType() && exprType.StrippedType().Equals(o.Type, TypeCompareKind.AllIgnoreOptions): 205case BoundObjectCreationExpression { Arguments: { Length: 0 }, Type: { } eType } _ when eType.IsNullableType(): 207case BoundObjectCreationExpression { Arguments: { Length: 1 }, Type: { } eType } creation when eType.IsNullableType(): 356isNullable = !(expr is BoundTupleExpression) && expr.Type is { } && expr.Type.IsNullableType(); 404when expr.Type.IsNullableType() && o.Type is { } && o.Type.IsNullableType() && !underlying[0].IsUserDefined: 438expr.Type is { } exprType && exprType.IsNullableType() && o.Type is { } && o.Type.IsNullableType() && nested[0] is { IsTupleConversion: true } tupleConversion:
Lowering\LocalRewriter\LocalRewriter_UnaryOperator.cs (3)
774else if (unaryOperandType.IsNullableType() && unaryOperandType.GetNullableUnderlyingType().SpecialType == SpecialType.System_Decimal) 816Debug.Assert(operand.Type is { } && operand.Type.IsNullableType() && operand.Type.GetNullableUnderlyingType().SpecialType == SpecialType.System_Decimal); 1003if (underlyingType.IsNullableType())
Lowering\LocalRewriter\LocalRewriter_UsingStatement.cs (1)
358bool isNullableValueType = local.Type.IsNullableType();
Lowering\SyntheticBoundNodeFactory.cs (2)
1384arg.Type.IsNullableType() && 1654else if (exprType.IsNullableType())
Operations\CSharpOperationFactory.cs (2)
2672isLifted: boundIndex.Type.IsNullableType(), 2689isLifted: boundRange.Type.IsNullableType(),
Symbols\ConstraintsHelper.cs (2)
448else if (deducedBase.IsNullableType() && (typeParameter.HasValueTypeConstraint || typeParameter.HasReferenceTypeConstraint)) 1264conversions.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)
777else if (((conversion.IsNullable && !defaultExpression.Type.IsNullableType()) || 778(conversion.IsObjectCreation && convertedExpression.Type.IsNullableType())) &&
Symbols\Source\SourceComplexParameterSymbol.cs (1)
396if (parameterType.Type.IsNullableType())
Symbols\TypeSymbolExtensions.cs (7)
32return type.IsReferenceType || type.IsPointerOrFunctionPointer() || type.IsNullableType(); 122return type.IsNullableType(); 139&& !type.IsNullableType() 152RoslynDebug.Assert(IsNullableType(type)); 160return type.IsNullableType() ? type.GetNullableUnderlyingType() : type; 1244if (type.IsNullableType()) 2131if ((object)type != null && type.IsNullableType())
Symbols\TypeWithAnnotations.cs (15)
52Debug.Assert(defaultType?.IsNullableType() != true || nullableAnnotation == NullableAnnotation.Annotated); 94if (typeSymbol?.IsNullableType() == true) 107if (NullableAnnotation.IsAnnotated() || (Type.IsValueType && Type.IsNullableType())) 117if (NullableAnnotation.IsNotAnnotated() || (Type.IsValueType && !Type.IsNullableType())) 255public bool IsNullableType() => Type.IsNullableType(); 367bool isValueType = type.IsValueType && !type.IsNullableType(); 439Debug.Assert(newTypeWithModifiers.NullableAnnotation.IsOblivious() || (typeSymbol.IsNullableType() && newTypeWithModifiers.NullableAnnotation.IsAnnotated())); 448else if ((NullableAnnotation.IsOblivious() || (typeSymbol.IsNullableType() && NullableAnnotation.IsAnnotated())) && 587return type.IsNullableType(); 682!(result.NullableAnnotation.IsAnnotated() && oldTypeSymbol.IsNullableType())) // Preserve nullable annotation on Nullable<T>. 699if (NullableAnnotation.IsNotAnnotated() || (typeSymbol.IsValueType && !typeSymbol.IsNullableType())) 899return CreateNonLazyType(defaultType, defaultType.IsNullableType() ? type.NullableAnnotation : NullableAnnotation.NotAnnotated, _customModifiers); 969Debug.Assert(resolvedType.IsNullableType() && CustomModifiers.IsEmpty); 985if (resolvedType.IsNullableType()) 995if (typeSymbol.IsNullableType())
Microsoft.CodeAnalysis.CSharp.Emit2.UnitTests (1)
Emit\NumericIntPtrTests.cs (1)
1571return type.IsNullableType() && isNativeInt(type.GetNullableUnderlyingType(), signed);
Microsoft.CodeAnalysis.CSharp.Semantic.UnitTests (84)
Semantics\InheritanceBindingTests.cs (22)
8443Assert.True(c2Goo.Parameters[0].Type.IsNullableType()); 8470Assert.True(((ArrayTypeSymbol)c2Goo.Parameters[0].Type).ElementType.IsNullableType()); 8497Assert.True(c2Goo.Parameters[0].Type.IsNullableType()); 8499Assert.False(tuple.TupleElements[0].Type.IsNullableType()); 8500Assert.True(tuple.TupleElements[1].Type.IsNullableType()); 8527Assert.True(c2Goo.ReturnType.IsNullableType()); 8554Assert.True(((ArrayTypeSymbol)c2Goo.ReturnType).ElementType.IsNullableType()); 8581Assert.True(c2Goo.ReturnType.IsNullableType()); 8583Assert.False(tuple.TupleElements[0].Type.IsNullableType()); 8584Assert.True(tuple.TupleElements[1].Type.IsNullableType()); 8606Assert.True(dGoo.Parameters[0].Type.IsNullableType()); 8628Assert.True(((ArrayTypeSymbol)dGoo.Parameters[0].Type).ElementType.IsNullableType()); 8650Assert.True(dGoo.Parameters[0].Type.IsNullableType()); 8652Assert.False(tuple.TupleElements[0].Type.IsNullableType()); 8653Assert.True(tuple.TupleElements[1].Type.IsNullableType()); 8675Assert.True(dGoo.ReturnType.IsNullableType()); 8697Assert.True(((ArrayTypeSymbol)dGoo.ReturnType).ElementType.IsNullableType()); 8719Assert.True(dGoo.ReturnType.IsNullableType()); 8721Assert.False(tuple.TupleElements[0].Type.IsNullableType()); 8722Assert.True(tuple.TupleElements[1].Type.IsNullableType()); 8748Assert.True(c2Goo.Parameters[0].Type.IsNullableType()); 8777Assert.True(dGoo.Parameters[0].Type.IsNullableType());
Semantics\NativeIntegerTests.cs (1)
4821return type.IsNullableType() && isNativeInt(type.GetNullableUnderlyingType(), signed);
Semantics\NullableReferenceTypesTests.cs (61)
11443Assert.True(m1.Parameters[0].Type.IsNullableType()); 11445Assert.True(m1.OverriddenMethod.Parameters[0].Type.IsNullableType()); 11494Assert.True(m1.Parameters[0].Type.IsNullableType()); 11499Assert.True(m2.ReturnType.IsNullableType()); 11501Assert.False(m2.OverriddenMethod.ReturnType.IsNullableType()); 11557Assert.True(m1.Parameters[0].Type.IsNullableType()); 11558Assert.True(m1.OverriddenMethod.Parameters[0].Type.IsNullableType()); 11561Assert.False(m2.Parameters[0].Type.IsNullableType()); 11562Assert.False(m2.OverriddenMethod.Parameters[0].Type.IsNullableType()); 11565Assert.True(m3.Parameters[0].Type.IsNullableType()); 11566Assert.True(m3.OverriddenMethod.Parameters[0].Type.IsNullableType()); 11616Assert.True(m1.Parameters[0].Type.IsNullableType()); 11617Assert.True(m1.OverriddenMethod.Parameters[0].Type.IsNullableType()); 11621Assert.True(m2.Parameters[0].Type.IsNullableType()); 11622Assert.True(m2.OverriddenMethod.Parameters[0].Type.IsNullableType()); 11721Assert.True(m1.Parameters[0].Type.IsNullableType()); 11756Assert.True(m1.Parameters[0].Type.IsNullableType()); 11840Assert.True(m1.Parameters[0].Type.IsNullableType()); 11841Assert.True(m2.Parameters[0].Type.IsNullableType()); 11842Assert.True(m3.Parameters[0].Type.IsNullableType()); 11843Assert.True(m4.Parameters[0].Type.IsNullableType()); 11881Assert.True(m1.Parameters[0].Type.IsNullableType()); 12004Assert.False(m1.ReturnType.IsNullableType()); 12005Assert.False(m1.OverriddenMethod.ReturnType.IsNullableType()); 12008Assert.False(m4.ReturnType.IsNullableType()); 12009Assert.True(m4.OverriddenMethod.ReturnType.IsNullableType()); 12012Assert.False(m5.ReturnType.IsNullableType()); 12087Assert.False(m1.Parameters[0].Type.IsNullableType()); 12090Assert.False(m1.OverriddenMethod.Parameters[0].Type.IsNullableType()); 12093Assert.False(m4.Parameters[0].Type.IsNullableType()); 12097Assert.False(m5.Parameters[0].Type.IsNullableType()); 12174Assert.True(b.GetMember<MethodSymbol>("M1").ReturnType.IsNullableType()); 12175Assert.True(b.GetMember<MethodSymbol>("M2").ReturnType.IsNullableType()); 12176Assert.False(b.GetMember<MethodSymbol>("M3").ReturnType.IsNullableType()); 12177Assert.True(b.GetMember<MethodSymbol>("M4").ReturnType.IsNullableType()); 12178Assert.True(b.GetMember<MethodSymbol>("M5").ReturnType.IsNullableType()); 12246Assert.True(b.GetMember<MethodSymbol>("M1").Parameters[0].Type.IsNullableType()); 12247Assert.True(b.GetMember<MethodSymbol>("M2").Parameters[0].Type.IsNullableType()); 12248Assert.False(b.GetMember<MethodSymbol>("M3").Parameters[0].Type.IsNullableType()); 12249Assert.True(b.GetMember<MethodSymbol>("M4").Parameters[0].Type.IsNullableType()); 12250Assert.True(b.GetMember<MethodSymbol>("M5").Parameters[0].Type.IsNullableType()); 13886Assert.False(m1.Parameters[0].Type.IsNullableType()); 13889Assert.False(m1.OverriddenMethod.Parameters[0].Type.IsNullableType()); 13892Assert.False(m2.ReturnType.IsNullableType()); 13895Assert.False(m2.OverriddenMethod.ReturnType.IsNullableType()); 14217Assert.False(m1.Parameters[0].Type.IsNullableType()); 14218Assert.False(m1.OverriddenMethod.Parameters[0].Type.IsNullableType()); 14222Assert.False(m2.Parameters[0].Type.IsNullableType()); 14223Assert.False(m2.OverriddenMethod.Parameters[0].Type.IsNullableType()); 14273Assert.True(m1.Parameters[0].Type.IsNullableType()); 14274Assert.True(m1.OverriddenMethod.Parameters[0].Type.IsNullableType()); 14278Assert.True(m2.Parameters[0].Type.IsNullableType()); 14279Assert.True(m2.OverriddenMethod.Parameters[0].Type.IsNullableType()); 17801Assert.False(tp.IsNullableType()); 135163Assert.False(dGoo.Parameters[0].Type.IsNullableType()); 135247Assert.True(c2Goo.Parameters[0].Type.IsNullableType()); 135335Assert.True(c2Goo.ReturnType.IsNullableType()); 135408Assert.True(dGoo.Parameters[0].Type.IsNullableType()); 135481Assert.True(dGoo.ReturnType.IsNullableType()); 135513Assert.True(dGoo.Parameters[0].Type.IsNullableType()); 135518Assert.True(tuple.TupleElements[1].Type.IsNullableType());
Microsoft.CodeAnalysis.CSharp.Symbol.UnitTests (3)
Symbols\TypeTests.cs (3)
1516Assert.True(memType.IsNullableType()); 1566Assert.True(memType.IsNullableType()); 1629Assert.True(memType.IsNullableType());