2 writes to Type
Microsoft.CodeAnalysis.CSharp (2)
Generated\BoundNodes.xml.Generated.cs (2)
417this.Type = type; 423this.Type = type;
1541 references to Type
Microsoft.CodeAnalysis.CSharp (1508)
Binder\Binder.cs (2)
855RoslynDebug.Assert(expression.Type is object); 856return expression.Type;
Binder\Binder.ValueChecks.cs (30)
529Debug.Assert(!checkingReceiver || expr.Type.IsValueType || expr.Type.IsTypeParameter()); 556if ((expr.ConstantValueOpt != null) || (expr.Type.GetSpecialTypeSafe() == SpecialType.System_Void)) 778indices[0].Type, 811Error(diagnostics, ErrorCode.ERR_BadSKunknown, expr.Syntax, expr.Type, MessageID.IDS_SK_TYPE.Localize()); 1418&& receiver?.Type?.IsValueType == true; 1650if (receiver is BoundObjectOrCollectionValuePlaceholder && receiver.Type.IsAnonymousType) 1822if (receiver?.Type?.IsRefLikeType == true) 1981if (receiver?.Type?.IsRefLikeType == true) 2077Debug.Assert(receiver.Type is { }); 2078if (receiver is not BoundValuePlaceholderBase && method is not null && receiver.Type?.IsValueType == true) 2089receiver = new BoundCapturedReceiverPlaceholder(receiver.Syntax, receiver, _localScopeDepth, receiver.Type).MakeCompilerGenerated(); 2326if (argument.Type?.IsRefLikeType == true) 2447var receiverType = receiverOpt?.Type; 2478&& argument.Type?.IsRefLikeType == true) 2893Debug.Assert(expr.Type is not null); 2921if (expr.Type?.GetSpecialTypeSafe() == SpecialType.System_Void) 3150Debug.Assert(!checkingReceiver || expr.Type.IsValueType || expr.Type.IsTypeParameter()); 3165if (expr.Type?.GetSpecialTypeSafe() == SpecialType.System_Void) 3485if (expr.Type?.IsRefLikeType != true) 3811Debug.Assert(false, $"{expr.Kind} expression of {expr.Type} type"); 3871Debug.Assert(!checkingReceiver || expr.Type.IsValueType || expr.Type.IsTypeParameter()); 3892if (expr.Type?.IsRefLikeType != true) 3957Error(diagnostics, inUnsafeRegion ? ErrorCode.WRN_EscapeStackAlloc : ErrorCode.ERR_EscapeStackAlloc, node, expr.Type); 4289Debug.Assert(false, $"{expr.Kind} expression of {expr.Type} type"); 4596if (addressKind == AddressKind.ReadOnly && !expression.Type.IsValueType && peVerifyCompatEnabled) 4610var type = expression.Type; 4771if (receiver?.Type.IsValueType == true)
Binder\Binder.WithQueryLambdaParametersBinder.cs (4)
66return new BoundRangeVariable(node, qv, translation, translation.Type); 74var receiverType = receiver.Type as NamedTypeSymbol; 80if (receiver.Type?.IsErrorType() != true) 96LookupMembersWithFallback(lookupResult, receiver.Type, name, 0, ref useSiteInfo, basesBeingResolved: null, options: options);
Binder\Binder_AnonymousTypes.cs (1)
214TypeSymbol? expressionType = expression.Type;
Binder\Binder_Attributes.cs (4)
934RoslynDebug.Assert(node.Type is object); 935var typedConstantKind = node.Type.GetAttributeParameterTypedConstantKind(_binder.Compilation); 984var operandType = operand.Type; 1080var type = node.Type;
Binder\Binder_Await.cs (13)
31var placeholder = new BoundAwaitableValuePlaceholder(expression.Syntax, expression.Type); 84var type = expression.Type; 262Debug.Assert(TypeSymbol.Equals(expression.Type, getAwaiterArgument.Type, TypeCompareKind.ConsiderEverything)); 286TypeSymbol awaiterType = getAwaiter.Type!; 287return GetIsCompletedProperty(awaiterType, node, expression.Type!, diagnostics, out isCompleted) 289&& GetGetResultMethod(getAwaiter, node, expression.Type!, diagnostics, out getResult, out getAwaiterGetResultCall); 303if (expression.Type is null) 325RoslynDebug.Assert(expression.Type is object); 326if (expression.Type.IsVoidType()) 342Error(diagnostics, ErrorCode.ERR_BadAwaitArg, node, expression.Type); 352Error(diagnostics, ErrorCode.ERR_BadAwaitArg, node, expression.Type); 436var awaiterType = awaiterExpression.Type;
Binder\Binder_Conversions.cs (15)
73else if (source.Type is not null && filterConversion(conversion)) 75var placeholder2 = new BoundValuePlaceholder(source.Syntax, source.Type); 117RoslynDebug.Assert(source.Type is object); 121if (!isCast && source.Type.Equals(destination, TypeCompareKind.IgnoreNullableModifiersForReferenceTypes)) 194unconvertedSource.Type, 213TypeSymbol? type = source.Type; 235Debug.Assert(source.Type is null); 455Debug.Assert(targetTyped || destination.IsErrorType() || destination.Equals(source.Type, TypeCompareKind.ConsiderEverything)); 473source.Syntax, source.Type, targetTyped, source.Expression, newSwitchArms, source.ReachabilityDecisionDag, 559conversion: Conversions.ClassifyStandardConversion(convertedOperand.Type, conversionParameterType, ref useSiteInfo), 1146RoslynDebug.Assert(receiverOpt.Type is object); 1148diagnostics.Add(ErrorCode.ERR_QueryNoProvider, node.Location, receiverOpt.Type, memberSymbol.Name); 1166RoslynDebug.Assert(receiverOpt.Type is object); 1167diagnostics.Add(ErrorCode.ERR_BadAwaitArg, node.Location, receiverOpt.Type); 1307(Conversions.ConvertExtensionMethodThisArg(methodParameters[0].Type, receiverOpt!.Type, ref useSiteInfo).Exists && useSiteInfo.Diagnostics.IsNullOrEmpty()));
Binder\Binder_Deconstruct.cs (20)
122if ((object?)boundRHS.Type == null || boundRHS.Type.IsErrorType()) 128var type = boundRHS.Type ?? voidType; 143boundRHS.Type, 158Debug.Assert(hasErrors || lhsTuple.Type is object); 159TypeSymbol returnType = hasErrors ? CreateErrorType() : lhsTuple.Type!; 226else if ((object?)boundRHS.Type == null) 321Debug.Assert(single.Type is not null); 323nestedConversion = this.Conversions.ClassifyConversionFromType(tupleOrDeconstructedTypes[i], single.Type, isChecked: CheckOverflowAtRuntime, ref useSiteInfo); 329GenerateImplicitConversionError(diagnostics, Compilation, single.Syntax, nestedConversion, tupleOrDeconstructedTypes[i], single.Type); 336nestedConversion, isCast: false, conversionGroupOpt: null, single.Type, diagnostics))); 357if ((object?)pending.Type != null) 421Debug.Assert((object?)variables[i].Single!.Type != null); 481TypeSymbol? mergedType = element.Type; 502if ((object?)variable.Single.Type != null) 505mergedType = variable.Single.Type; 569typesWithAnnotationsBuilder.Add(TypeWithAnnotations.Create(value.Type)); 622if (receiver.Type?.IsDynamic() ?? false) 717if (receiver.Type?.IsErrorType() == false) 719Error(diagnostics, ErrorCode.ERR_MissingDeconstruct, rightSyntax, receiver.Type!, numParameters);
Binder\Binder_Expressions.cs (75)
196TypeSymbol resultType = expr.Type; 289var commonType = expr.Type; 361case BoundStackAllocArrayCreation { Type: null } boundStackAlloc: 544TypeSymbol exprType = expr.Type; 944subExpressions.SelectAsArray(e => TypeWithAnnotations.Create(e.Type)), 1001if (boundArgument.Type?.SpecialType == SpecialType.System_Void) 1011var elementTypeWithAnnotations = TypeWithAnnotations.Create(boundArgument.Type); 1210if ((object)argument.Type != null && argument.Type.IsRestrictedType()) 1213Error(diagnostics, ErrorCode.ERR_MethodArgCantBeRefAny, node, argument.Type); 1556type: expression.Type, 2332(object)operand.Type != null && 2333!operand.Type.IsNullableType() && 2334!TypeSymbol.Equals(targetType.GetNullableUnderlyingType(), operand.Type, TypeCompareKind.ConsiderEverything2)) 2355if ((object)boundOperand.Type != null && boundOperand.Type.IsNullableType()) 2434if (left?.Type.IsNullableType() == true || right?.Type.IsNullableType() == true) 2462if (boundOperand.Type?.IsNullableType() == true) 2554SymbolDistinguisher distinguisher1 = new SymbolDistinguisher(this.Compilation, operand.Type, targetType); 2603case BoundKind.UnconvertedConditionalOperator when operand.Type is null: 2604case BoundKind.UnconvertedSwitchExpression when operand.Type is null: 2623Debug.Assert((object)operand.Type != null); 2624SymbolDistinguisher distinguisher = new SymbolDistinguisher(this.Compilation, operand.Type, targetType); 2665Debug.Assert((object)operand.Type != null && !operand.Type.IsNullableType()); 2671var underlyingConversion = Conversions.ClassifyBuiltInConversion(operand.Type, underlyingTargetTypeWithAnnotations.Type, isChecked: CheckOverflowAtRuntime, ref discardedUseSiteInfo); 3517if ((object)boundExpression.Type == null || !boundExpression.Type.IsErrorType()) 3601Debug.Assert(init.Type.IsErrorType()); 4011if (constantValue == null || constantValue.IsBad || expression.Type.SpecialType != SpecialType.System_Int32) 4034var type = expression.Type.SpecialType; 4588else if ((object)argument.Type == null) 4600else if (argument.Type.TypeKind == TypeKind.Delegate) 4602var sourceDelegate = (NamedTypeSymbol)argument.Type; 4606if (ReportDelegateInvokeUseSiteDiagnostic(diagnostics, argument.Type, node: node)) 4885Debug.Assert((object)boundLeft.Type != null); 4894type: boundLeft.Type, 5113type: boundMember.Type, 6404var leftType = boundValue.Type; 6412if (TypeSymbol.Equals(boundType.Type, leftType, TypeCompareKind.AllIgnoreOptions)) 6442TypeSymbol.Equals(BindNamespaceOrType(id, BindingDiagnosticBag.Discarded).Type, type, TypeCompareKind.AllIgnoreOptions); 6546TypeSymbol leftType = boundLeft.Type; 6584leftType = boundLeft.Type; 6811Error(diagnostics, ErrorCode.WRN_DotOnDefault, node, boundLeft.Type); 6868var leftType = boundLeft.Type; 6988if ((object)boundLeft.Type == null) 6996Error(diagnostics, ErrorCode.ERR_NoSuchMember, name, boundLeft.Type, plainName); 6998else if (WouldUsingSystemFindExtension(boundLeft.Type, plainName)) 7000Error(diagnostics, ErrorCode.ERR_NoSuchMemberOrExtensionNeedUsing, name, boundLeft.Type, plainName, "System"); 7004Error(diagnostics, ErrorCode.ERR_NoSuchMemberOrExtension, name, boundLeft.Type, plainName); 7299if ((object)methodGroup.Methods[i].ReduceExtensionMethod(left.Type, this.Compilation) == null) 7464TypeSymbol receiverType = receiver.Type; 7667bool isUsableAsField = eventSymbol.HasAssociatedField && this.IsAccessible(eventSymbol.AssociatedField, ref useSiteInfo, (receiver != null) ? receiver.Type : null); 7900if ((object)expr.Type == null) 7940Debug.Assert((object)expr.Type != null); 7943var exprType = expr.Type; 7986var arrayType = (ArrayTypeSymbol)expr.Type; 8033var receiverPlaceholder = new BoundImplicitIndexerReceiverPlaceholder(expr.Syntax, isEquivalentToThisReference: expr.IsEquivalentToThisReference, expr.Type) { WasCompilerGenerated = true }; 8197Debug.Assert(expr.Type.IsPointerType()); 8198PointerTypeSymbol pointerType = (PointerTypeSymbol)expr.Type; 8244Debug.Assert((object)expr.Type != null); 8250this.LookupMembersWithFallback(lookupResult, expr.Type, WellKnownMemberNames.Indexer, arity: 0, useSiteInfo: ref useSiteInfo, options: lookupOptions); 8542var argType = argument.Type; 8548Debug.Assert(receiver.Type is not null); 8555var receiverPlaceholder = new BoundImplicitIndexerReceiverPlaceholder(receiver.Syntax, isEquivalentToThisReference: receiver.IsEquivalentToThisReference, receiver.Type) { WasCompilerGenerated = true }; 8564Debug.Assert(indexerOrSliceAccess.Type is not null); 8574indexerOrSliceAccess.Type); 8780Debug.Assert(receiverPlaceholder.Type is not null); 8781if (TryLookupLengthOrCount(syntax, receiverPlaceholder.Type, lookupResult, out var lengthOrCountProperty, diagnostics)) 9140if (m.ReduceExtensionMethod(receiver.Type, Compilation) is { } reduced && 9348var receiverType = receiver.Type; 9357var accessType = access.Type; 9488var receiverType = receiver.Type; 9519var receiverType = receiver.Type;
Binder\Binder_Initializers.cs (2)
259((object?)expression.Type == null || !expression.Type.IsVoidType()))
Binder\Binder_InterpolatedString.cs (12)
243Debug.Assert(unconvertedInterpolatedString.Parts.All(static part => part.Type is null or { SpecialType: SpecialType.System_String })); 269unconvertedInterpolatedString.Type, 295&& unconvertedInterpolatedString.Parts.All(p => p is not BoundStringInsert { Value.Type.TypeKind: TypeKind.Dynamic }); 298=> parts.All(p => p is BoundLiteral or BoundStringInsert { Value.Type.SpecialType: SpecialType.System_String, Alignment: null, Format: null }); 390expression.Type, 451unconvertedInterpolatedString.Type, 538if (value.Type is not null) 692if (insert.Value.Type is null) 719Debug.Assert(part is BoundLiteral { Type: { SpecialType: SpecialType.System_String } }); 787argumentsBuilder.Add(boundLiteral.Update(ConstantValue.Create(literalText), boundLiteral.Type)); 960Debug.Assert(receiver!.Type is not null); 962placeholderType = receiver.Type;
Binder\Binder_Invocation.cs (24)
205else if ((object)argument.Type == null && !argument.HasAnyErrors) 216else if (argument.Type.IsVoidType()) 260if ((object)boundExpression.Type != null && boundExpression.Type.IsDynamic()) 284else if (boundExpression.Type?.Kind == SymbolKind.FunctionPointerType) 500Debug.Assert((object)arg.Type != null); 503Error(diagnostics, ErrorCode.ERR_BadDynamicMethodArg, arg.Syntax, arg.Type); 657Debug.Assert(methodGroup.InstanceOpt != null && (object)methodGroup.InstanceOpt.Type != null); 659Error(diagnostics, ErrorCode.ERR_BadArgTypeDynamicExtension, syntax, methodGroup.InstanceOpt.Type, methodGroup.Name); 881if (!call.HasAnyErrors && call.ReceiverOpt != null && (object)call.ReceiverOpt.Type != null) 886if (call.ReceiverOpt.Type.IsRestrictedType() && !TypeSymbol.Equals(call.Method.ContainingType, call.ReceiverOpt.Type, TypeCompareKind.ConsiderEverything2)) 888SymbolDistinguisher distinguisher = new SymbolDistinguisher(compilation, call.ReceiverOpt.Type, call.Method.ContainingType); 904(object)dynInvoke.Expression.Type != null && 905dynInvoke.Expression.Type.IsRestrictedType()) 909Error(diagnostics, ErrorCode.ERR_BadDynamicMethodArg, dynInvoke.Expression.Syntax, dynInvoke.Expression.Type); 986case BoundUnconvertedSwitchExpression { Type: { } naturalType } switchExpr: 1476receiver.Type.IsValueType && 1581var type = expr.Type as NamedTypeSymbol; 1621var methodContainer = (object)receiver != null && (object)receiver.Type != null 1622? receiver.Type 1837var methodContainer = expr.Type ?? this.ContainingType; 2009RoslynDebug.Assert(boundExpression.Type is FunctionPointerTypeSymbol); 2011var funcPtr = (FunctionPointerTypeSymbol)boundExpression.Type;
Binder\Binder_Operators.cs (77)
63var placeholder = new BoundValuePlaceholder(right.Syntax, left.HasDynamicType() ? left.Type : right.Type).MakeCompilerGenerated(); 64var finalDynamicConversion = this.Compilation.Conversions.ClassifyConversionFromExpression(placeholder, left.Type, isChecked: CheckOverflowAtRuntime, ref useSiteInfo); 66var conversion = (BoundConversion)CreateConversion(node, placeholder, finalDynamicConversion, isCast: true, conversionGroupOpt: null, left.Type, diagnostics); 75left.Type, 76right.Type, 84left.Type, 197var leftType = left.Type; 347TypeSymbol type = operand.Type; 375Debug.Assert((object)left.Type != null && left.Type.IsDynamic() || (object)right.Type != null && right.Type.IsDynamic()); 399Error(diagnostics, ErrorCode.ERR_InvalidDynamicCondition, node.Left, left.Type, kind == BinaryOperatorKind.LogicalAnd ? "false" : "true"); 405Debug.Assert(left.Type is not TypeParameterSymbol); 521TypeSymbol leftType = left.Type; 522TypeSymbol rightType = right.Type; 557Debug.Assert(right.Type.SpecialType == SpecialType.System_String); 558var stringConstant = FoldBinaryOperator(node, BinaryOperatorKind.StringConcatenation, left, right, right.Type, diagnostics); 559return new BoundBinaryOperator(node, BinaryOperatorKind.StringConcatenation, BoundBinaryOperator.UncommonData.UnconvertedInterpolatedStringAddition(stringConstant), LookupResultKind.Empty, left, right, right.Type); 696TypeSymbol leftType = left.Type; 697TypeSymbol rightType = right.Type; 785(object)left.Type != null && left.Type.TypeKind == TypeKind.Delegate) 789var conversion = this.Conversions.ClassifyConversionFromExpression(right, left.Type, isChecked: CheckOverflowAtRuntime, ref discardedUseSiteInfo); 791GenerateImplicitConversionError(diagnostics, right.Syntax, conversion, right, left.Type); 813case (BoundKind.DefaultLiteral, _) when right.Type is TypeParameterSymbol: 814Debug.Assert(!right.Type.IsReferenceType); 815Error(diagnostics, ErrorCode.ERR_AmbigBinaryOpsOnUnconstrainedDefault, node, operatorToken.Text, right.Type); 817case (_, BoundKind.DefaultLiteral) when left.Type is TypeParameterSymbol: 818Debug.Assert(!left.Type.IsReferenceType); 819Error(diagnostics, ErrorCode.ERR_AmbigBinaryOpsOnUnconstrainedDefault, node, operatorToken.Text, left.Type); 838case LookupResultKind.OverloadResolutionFailure when operatorToken.Kind() is SyntaxKind.PlusToken && isReadOnlySpanOfByte(left.Type) && isReadOnlySpanOfByte(right.Type): 905if ((object)left.Type != null && left.Type.SpecialType == SpecialType.System_Boolean && 906(object)right.Type != null && right.Type.SpecialType == SpecialType.System_Boolean) 908var constantValue = FoldBinaryOperator(node, kind | BinaryOperatorKind.Bool, left, right, left.Type, diagnostics); 912resultKind: LookupResultKind.Viable, left, right, type: left.Type, hasErrors: constantValue != null && constantValue.IsBad); 1024var type = left.Type; 1041if (left.Type is not null) 1043var operandPlaceholder = new BoundValuePlaceholder(left.Syntax, left.Type).MakeCompilerGenerated(); 1419(object)operand.Type != null && 1420(operand.Type.SpecialType == SpecialType.System_UInt64 || isNuint(operand.Type))) 1645return left.Type; 1648return right.Type; 1712BinaryOperatorKind newKind = kind.Operator().WithType(newLeftOperand.Type!.SpecialType); 2256var operandType = operand.Type; 2326var operandPlaceholder = new BoundValuePlaceholder(operand.Syntax, operand.Type).MakeCompilerGenerated(); 2445var operandType = operand.Type as PointerTypeSymbol; 2500TypeSymbol operandType = operand.Type; 2579if (receiver.Type.IsReferenceType) 2693if (isOperandNullOrNew || operand.Type?.IsErrorType() == true) 2721type: operand.Type!); 2770var underlyingType = operand.Type.GetEnumUnderlyingType()!; 3129if ((object)operand.Type == null && !operand.IsLiteralNull()) 3188if ((object)operand.Type == null) 3199var convertedExpression = BindExpressionForPattern(operand.Type, node.Right, ref hasErrors, isPatternDiagnostics, out var constantValueOpt, out var wasExpression, out _); 3206node.Right, convertedExpression, constantValueOpt ?? ConstantValue.Bad, operand.Type, convertedExpression.Type ?? operand.Type, hasErrors) 3226if (operandHasErrors || IsOperatorErrors(node, operand.Type, typeExpression, diagnostics)) 3247operand.Type.IsVoidType()) 3277var operandType = operand.Type; 3648if ((object)operand.Type == null) 3710Debug.Assert(operand.Type is null); 3711operandPlaceholder = new BoundValuePlaceholder(operand.Syntax, operand.Type).MakeCompilerGenerated(); 3725var operandType = operand.Type; 3758operandPlaceholder = new BoundValuePlaceholder(operand.Syntax, operand.Type).MakeCompilerGenerated(); 3932TypeSymbol optLeftType = leftOperand.Type; // "A" 3933TypeSymbol optRightType = rightOperand.Type; // "B" 4108TypeSymbol leftType = leftOperand.Type; 4126if (underlyingRightConversion.Exists && rightOperand.Type?.IsDynamic() != true) 4272TypeSymbol trueType = trueExpr.Type; 4273TypeSymbol falseType = falseExpr.Type;
Binder\Binder_Patterns.cs (23)
24TypeSymbol? expressionType = expression.Type; 37Debug.Assert(expression.Type is { }); 38BoundPattern pattern = BindPattern(node.Pattern, expression.Type, permitDesignations: true, hasErrors, diagnostics, underIsPattern: true); 65Debug.Assert(expression.Type is object); 66diagnostics.Add(ErrorCode.ERR_IsPatternImpossible, node.Location, expression.Type); 82Debug.Assert(expression.Type is object); 83diagnostics.Add(ErrorCode.WRN_IsPatternAlways, node.Location, expression.Type); 248Debug.Assert(indexerAccess.Type is not null); 249sliceType = indexerAccess.Type; 322Debug.Assert(indexerAccess!.Type is not null); 323elementType = indexerAccess.Type; 427var convertedType = convertedExpression.Type ?? inputType; 515Debug.Assert(expression is { Kind: BoundKind.TypeExpression, Type: { } }); 516hasErrors |= CheckValidPatternType(patternExpression, inputType, expression.Type, diagnostics: diagnostics); 569if (convertedExpression.Type is null && constantValueOpt != ConstantValue.Null) 610RoslynDebug.Assert(expression.Type is { }); 611ConstantValue match = ExpressionOfTypeMatchesPatternType(Conversions, inputType, expression.Type, ref useSiteInfo, out _, operandConstantValue: null); 643if (expression.Type?.SpecialType == SpecialType.System_String && inputType.IsSpanOrReadOnlySpanChar()) 698(conversion.ConversionKind == ConversionKind.NoConversion && convertedExpression.Type?.IsErrorType() == true)) 1624RoslynDebug.Assert(value.Type is { }); 1632BinaryOperatorKind opType = RelationalOperatorType(value.Type.EnumUnderlyingTypeOrSelf()); 1648diagnostics.Add(ErrorCode.ERR_UnsupportedTypeForRelationalPattern, node.Location, value.Type.ToDisplayString()); 1667return new BoundRelationalPattern(node, operation | opType, value, constantValueOpt, inputType, value.Type, hasErrors);
Binder\Binder_Query.cs (14)
300Debug.Assert(state.fromExpression.Type is { }); 303ImmutableArray.Create(state.fromExpression), state.fromExpression.Type); 737else if (!yExpression.HasAnyErrors && yExpression.Type!.IsVoidType()) 739Error(d, ErrorCode.ERR_QueryRangeVariableAssignedBadValue, errorLocation, yExpression.Type!); 740Debug.Assert(yExpression.Type is { }); 741yExpression = new BoundBadExpression(yExpression.Syntax, LookupResultKind.Empty, ImmutableArray<Symbol?>.Empty, ImmutableArray.Create(yExpression), yExpression.Type); 802field2Value = new BoundBadExpression(field2Value.Syntax, LookupResultKind.Empty, ImmutableArray<Symbol?>.Empty, ImmutableArray.Create(field2Value), field2Value.Type, true); 822return e.Type ?? CreateErrorType(); 927Debug.Assert(receiver.Type is object || ultimateReceiver.Type is null); 928if ((object?)ultimateReceiver.Type == null) 978if (ultimateReceiver.Type.TypeKind == TypeKind.TypeParameter) 981Error(diagnostics, ErrorCode.ERR_BadSKunknown, ultimateReceiver.Syntax, ultimateReceiver.Type, MessageID.IDS_SK_TYVAR.Localize()); 989else if (receiver.Type!.IsVoidType())
Binder\Binder_QueryErrors.cs (7)
45if (instanceArgument.Type.IsDynamic()) 52else if (ImplementsStandardQueryInterface(instanceArgument.Type, name, ref useSiteInfo)) 57new object[] { instanceArgument.Type, name }, 60else if (fromClause != null && fromClause.Type == null && HasCastToQueryProvider(instanceArgument.Type, ref useSiteInfo)) 65new object[] { instanceArgument.Type, name, fromClause.Identifier.ValueText }, 73new object[] { instanceArgument.Type, name }, 238TypeSymbol receiverType = receiver?.Type;
Binder\Binder_Statements.cs (26)
404var type = boundExpr.Type; 754Debug.Assert(expr.Type is object); 755Debug.Assert(expr.Type.IsRefLikeType || hasAwait); // pattern dispose lookup is only valid on ref structs or asynchronous usings 777diagnostics.Add(ErrorCode.WRN_PatternBadSignature, syntaxNode.Location, expr.Type, MessageID.IDS_Disposable.Localize(), disposeMethod); 1023TypeSymbol initializerType = initializerOpt?.Type; 1241TypeSymbol initializerType = initializerOpt.Type; 1257elementType = ((BoundAddressOfOperator)initializerOpt).Operand.Type; 1331if (initializer.Type.IsVoidType()) 1351additionalDiagnostics.Add(ErrorCode.WRN_PatternBadSignature, initializer.Syntax.Location, initializer.Type, "fixed", patternMethodSymbol); 1468var inferredType = op2.Type; 1498var conversion = GenerateConversionForAssignment(op1.Type, op2, diagnostics, isRef ? ConversionForAssignmentFlags.RefAssignment : ConversionForAssignmentFlags.None); 1528type = op1.Type; 1549Debug.Assert(op1.Type is { }); 1582Debug.Assert(leftEscape == rightEscape || op1.Type.IsRefLikeType); 1601if (!hasErrors && op1.Type.IsRefLikeType) 1806Debug.Assert((object)receiver.Type != null); 1807return receiver.Type; 1932this.Conversions.ClassifyConversionFromType(expression.Type, targetType, isChecked: CheckOverflowAtRuntime, ref useSiteInfo); 2393var sourceType = operand.Type; 2940hasErrors |= arg.HasErrors || ((object)arg.Type != null && arg.Type.IsErrorType()); 3015if ((object)arg?.Type != null && arg.Type.IsVoidType()) 3079&& TypeSymbol.Equals(argument.Type, this.GetCurrentReturnType(out unusedRefKind), TypeCompareKind.ConsiderEverything2)) 3082Error(diagnostics, ErrorCode.ERR_BadAsyncReturnExpression, argument.Syntax, returnType, argument.Type); 3414else if (expression.Type?.SpecialType == SpecialType.System_Void)
Binder\Binder_Symbols.cs (1)
1449receiver = new BoundBadExpression(receiver.Syntax, LookupResultKind.Ambiguous, ImmutableArray<Symbol>.Empty, ImmutableArray.Create(receiver), receiver.Type, hasErrors: true).MakeCompilerGenerated();
Binder\Binder_TupleOperators.cs (16)
85TypeSymbol leftType = left.Type; 86TypeSymbol rightType = right.Type; 111return new TupleBinaryOperatorInfo.Single(binary.Left.Type, binary.Right.Type, binary.OperatorKind, binary.Method, binary.ConstrainedToType, 183Debug.Assert((object)left.Type != null && left.Type.IsDynamic() || (object)right.Type != null && right.Type.IsDynamic()); 205left = GiveTupleTypeToDefaultLiteralIfNeeded(left, right.Type); 206right = GiveTupleTypeToDefaultLiteralIfNeeded(right, left.Type); 217Debug.Assert((object)left.Type != null || left.Kind == BoundKind.TupleLiteral); 218Debug.Assert((object)right.Type != null || right.Kind == BoundKind.TupleLiteral); 247bool leftNullable = left.Type?.IsNullableType() == true; 248bool rightNullable = right.Type?.IsNullableType() == true; 356TypeSymbol type = expr.Type; 383TypeSymbol tupleType = expr.Type.StrippedType();
Binder\Binder_WithExpression.cs (1)
20var receiverType = receiver.Type;
Binder\DecisionDagBuilder.cs (6)
404Debug.Assert(variableAccess.Type!.Equals(input.Type, TypeCompareKind.AllIgnoreOptions) || variableAccess.Type.IsErrorType()); 497Debug.Assert(constant.Value.Type is not null || constant.HasErrors); 498output = input = constant.Value.Type is { } type ? MakeConvertToType(input, constant.Syntax, type, isExplicitTest: false, tests) : input; 679Debug.Assert(rel.Value.Type is not null); 682output = MakeConvertToType(input, rel.Syntax, rel.Value.Type, isExplicitTest: false, tests);
Binder\ForEachLoopBinder.cs (11)
521(builder.ElementType.IsPointerOrFunctionPointer() && collectionExpr.Type.IsArray()) || 522(builder.ElementType.IsNullableType() && builder.ElementType.GetMemberTypeArgumentsNoUseSiteDiagnostics().Single().IsErrorType() && collectionExpr.Type.IsArray())); 572(collectionConversionClassification.Kind == ConversionKind.ExplicitReference && collectionExpr.Type.SpecialType == SpecialType.System_String)); 629else if (collectionExpr.Type.SpecialType == SpecialType.System_String && builder.CollectionType.SpecialType == SpecialType.System_Collections_IEnumerable) 647TypeSymbol collectionExprType = collectionExpr.Type; 715TypeSymbol collectionExprType = collectionExpr.Type; 748TypeSymbol collectionExprType = collectionExpr.Type; 788var unwrappedCollectionExprType = unwrappedCollectionExpr.Type; 852: collectionExpr.Type; 1129getEnumeratorInfo = FindForEachPatternMethod(collectionExpr.Type, methodName, lookupResult, warningsOnly: true, diagnostics, isAsync); 1347diagnostics.Add(ErrorCode.WRN_PatternIsAmbiguous, _syntax.Expression.Location, collectionExpr.Type, MessageID.IDS_Collection.Localize(),
Binder\LockBinder.cs (1)
40TypeSymbol exprType = expr.Type;
Binder\RefSafetyAnalysis.cs (2)
465if (node.ExpressionOpt is { Type: { } } expr) 475if (node.Expression is { Type: { } } expr)
Binder\Semantics\BestTypeInferrer.cs (2)
127TypeSymbol? type1 = expr1.Type; 143TypeSymbol? type2 = expr2.Type;
Binder\Semantics\Conversions\Conversions.cs (2)
359if (method.RequiresInstanceReceiver && methodGroup.Receiver?.Type?.IsRestrictedType() == true) 389Debug.Assert((object)sourceExpression.Type == null);
Binder\Semantics\Conversions\ConversionsBase.cs (12)
95var sourceType = sourceExpression.Type; 280if (TryGetVoidConversion(sourceExpression.Type, destination, out var conversion)) 625Debug.Assert(sourceExpression == null || (object)sourceExpression.Type == (object)source); 996Debug.Assert(sourceExpression == null || (object)sourceExpression.Type == (object)source); 1038var innerConversion = ClassifyImplicitBuiltInConversionFromExpression(innerExpression, innerExpression.Type, destination, ref useSiteInfo); 1278if (constantValue == null || (object)source.Type == null) 1288var specialSource = source.Type.GetSpecialTypeSafe(); 1344var sourceType = sourceExpression.Type; 1387source.Type is object && 1388IsNumericType(source.Type) && 1782Debug.Assert(sourceExpressionOpt == null || (object)sourceExpressionOpt.Type == sourceType); 1814conversions.ClassifyImplicitExtensionMethodThisArgConversion(s, s.Type, d.Type, ref u),
Binder\Semantics\Operators\BinaryOperatorEasyOut.cs (9)
288var leftType = left.Type; 294var rightType = right.Type; 326Debug.Assert((object?)left.Type != null); 328Debug.Assert((object?)right.Type != null); 348if (left.Type.SpecialType != right.Type.SpecialType) 354if (left.Type.SpecialType == SpecialType.System_Int32 || 355left.Type.SpecialType == SpecialType.System_Boolean || 356left.Type.SpecialType == SpecialType.System_String)
Binder\Semantics\Operators\BinaryOperatorOverloadResolution.cs (24)
67TypeSymbol leftOperatorSourceOpt = left.Type?.StrippedType(); 68TypeSymbol rightOperatorSourceOpt = right.Type?.StrippedType(); 360var leftType = left.Type; 362var rightType = right.Type; 505bool isExactSubtraction = TypeSymbol.Equals(right.Type?.StrippedType(), underlying, TypeCompareKind.ConsiderEverything2); 609var leftType = left.Type; 615var rightType = right.Type; 684var leftType = left.Type as PointerTypeSymbol; 685var rightType = right.Type as PointerTypeSymbol; 700if ((object)leftType != null || (object)rightType != null || left.Type is FunctionPointerTypeSymbol || right.Type is FunctionPointerTypeSymbol) 723this.Compilation.builtInOperators.GetSimpleBuiltInOperators(kind, operators, skipNativeIntegerOperators: !left.Type.IsNativeIntegerOrNullableThereof() && !right.Type.IsNativeIntegerOrNullableThereof()); 738this.Compilation.builtInOperators.GetUtf8ConcatenationBuiltInOperator(left.Type, operators); 749BuiltInOperators.IsValidObjectEquality(conversions, left.Type, left.IsLiteralNull(), leftIsDefault: false, right.Type, right.IsLiteralNull(), rightIsDefault: false, ref useSiteInfo) && 750((object)left.Type == null || (!left.Type.IsDelegateType() && left.Type.SpecialType != SpecialType.System_String && left.Type.SpecialType != SpecialType.System_Delegate)) && 751((object)right.Type == null || (!right.Type.IsDelegateType() && right.Type.SpecialType != SpecialType.System_String && right.Type.SpecialType != SpecialType.System_Delegate));
Binder\Semantics\Operators\UnaryOperatorEasyOut.cs (1)
99var operandType = operand.Type;
Binder\Semantics\Operators\UnaryOperatorOverloadResolution.cs (5)
255this.Compilation.builtInOperators.GetSimpleBuiltInOperators(kind, operators, skipNativeIntegerOperators: !operand.Type.IsNativeIntegerOrNullableThereof()); 294var enumType = operand.Type; 325var pointerType = operand.Type as PointerTypeSymbol; 349if ((object)operand.Type == null) 377TypeSymbol type0 = operand.Type.StrippedType();
Binder\Semantics\OverloadResolution\AnalyzedArguments.cs (2)
101if ((object?)argument.Type != null && argument.Type.IsDynamic() && (!hasRefKinds || RefKinds[i] == Microsoft.CodeAnalysis.RefKind.None))
Binder\Semantics\OverloadResolution\MethodTypeInference.cs (3)
362sb.AppendFormat("Argument types ({0})\n", string.Join(", ", from a in _arguments select a.Type)); 787if (argument.Kind == BoundKind.TupleLiteral && (object)argument.Type == null) 3043TypeSymbol source = argument.Type;
Binder\Semantics\OverloadResolution\OverloadResolution.cs (4)
2519if ((object)node.Type != null && Conversions.HasIdentityConversion(node.Type, t)) 3790var argType = argument.Type; 3804Conversions.ClassifyImplicitExtensionMethodThisArgConversion(argument, argument.Type, parameterType, ref useSiteInfo) :
Binder\Semantics\OverloadResolution\OverloadResolutionResult.cs (4)
641diagnostics.Add(ErrorCode.ERR_QueryNoProvider, location, receiverOpt.Type, symbol.Name); 649diagnostics.Add(ErrorCode.ERR_BadAwaitArg, location, receiverOpt.Type); 758new object[] { instanceArgument.Type, inferenceFailed.Member.Name }, 1336diagnostics.Add(ErrorCode.ERR_QueryMultipleProviders, location, receiver.Type, name);
Binder\SwitchBinder.cs (4)
47protected TypeSymbol SwitchGoverningType => SwitchGoverningExpression.Type; 376var switchGoverningType = switchGoverningExpression.Type; 438Debug.Assert((object)switchGoverningExpression.Type == null || switchGoverningExpression.Type.IsVoidType());
Binder\SwitchExpressionBinder.cs (6)
140var type = @case.Value.Type; 177Debug.Assert(inputExpression.Type is not null); 188Debug.Assert(inputExpression.Type is not null); 189return inputExpression.Type; 195if (switchGoverningExpression.Type == (object?)null || switchGoverningExpression.Type.IsVoidType())
Binder\UsingStatementBinder.cs (4)
120if (expressionOpt.Type is not null) 122CheckRestrictedTypeInAsyncMethod(originalBinder.ContainingMemberOrLambda, expressionOpt.Type, diagnostics, expressionOpt.Syntax, forUsingExpression: true); 207TypeSymbol? type = fromExpression ? expressionOpt!.Type : declarationTypeOpt; 277Debug.Assert(expressionOpt.Type?.IsDynamic() != true || result.Kind == ConversionKind.ImplicitDynamic);
BoundTree\BoundDagEvaluation.cs (2)
57return arrayAccess.Expression.Type; 61return arrayAccess.Expression.Type;
BoundTree\BoundDecisionDag.cs (1)
187var f = ValueSetFactory.ForType(input.Type);
BoundTree\BoundExpression.cs (2)
68return this.Type is null; 125=> Type?.GetITypeSymbol(TopLevelNullability.FlowState.ToAnnotation());
BoundTree\BoundExpressionExtensions.cs (4)
108return node.Type is { }; 113var type = node.Type; 128if (expr.Type is { } type) 246TypeSymbol? receiverType = expressionOpt.Type;
BoundTree\BoundFunctionPointerInvocation.cs (2)
16Debug.Assert(InvokedExpression.Type is FunctionPointerTypeSymbol); 17return (FunctionPointerTypeSymbol)InvokedExpression.Type;
BoundTree\BoundNode.cs (1)
104return expression?.Type?.IsErrorType() == true;
BoundTree\BoundNullCoalescingAssignmentOperator.cs (2)
15var leftType = LeftOperand.Type; 22return nullableUnderlying.Equals(RightOperand.Type);
BoundTree\Constructors.cs (1)
651public static BoundDagTemp ForOriginalInput(BoundExpression expr) => new BoundDagTemp(expr.Syntax, expr.Type!, source: null);
BoundTree\Formatting.cs (4)
21Debug.Assert(this.Type is { }, $"Unexpected null type in {this.GetType().Name}"); 22return this.Type; 155=> (Type is null) ? FormattableStringFactory.Create("stackalloc {0}[{1}]", ElementType, Count.WasCompilerGenerated ? null : Count.Syntax.ToString()) : base.Display; 161=> (Type is null) ? MessageID.IDS_FeatureSwitchExpression.Localize() : base.Display;
BoundTree\UnboundLambda.cs (1)
379expression.Type?.SetUnknownNullabilityForReferenceTypes();
CodeGen\EmitAddress.cs (14)
43Debug.Assert(!expression.Type.IsReferenceType); 44Debug.Assert(!expression.Type.IsValueType || expression.Type.IsNullableType()); 67Debug.Assert(expression.Type.IsValueType || IsAnyReadOnly(addressKind), "'this' is readonly in classes"); 69if (expression.Type.IsValueType) 104Debug.Assert(operand.Type.IsPointerType()); 138var type = expression.Type; 328var value = this.AllocateTemp(expression.Type, expression.Syntax); 369if (!receiver.Type.IsReferenceType) 386TreatLongsAsNative(index.Type.PrimitiveTypeCode); 400if (((ArrayTypeSymbol)arrayAccess.Expression.Type).IsSZArray) 408_builder.EmitArrayElementAddress(_module.Translate((ArrayTypeSymbol)arrayAccess.Expression.Type), 501var receiverType = receiver.Type; 527EmitBox(receiver.Type, receiver.Syntax);
CodeGen\EmitArrayInitializer.cs (1)
224TypeSymbol type = init.Type.EnumUnderlyingTypeOrSelf();
CodeGen\EmitConversion.cs (11)
73Debug.Assert((operand.Type.IsArray()) && 139var fromType = conversion.Operand.Type; 213var fromType = conversion.Operand.Type; 229if (!conversion.Operand.Type.IsVerifierReference()) 231EmitBox(conversion.Operand.Type, conversion.Operand.Syntax); 261if (!conversion.Operand.Type.IsVerifierReference()) 263EmitBox(conversion.Operand.Type, conversion.Operand.Syntax); 289var fromType = conversion.Operand.Type; 336EmitSymbolToken(receiver.Type, receiver.Syntax); 342if (!receiver.Type.IsVerifierReference()) 344EmitBox(receiver.Type, receiver.Syntax);
CodeGen\EmitExpression.cs (49)
51if ((object)expression.Type == null || 52(expression.Type.SpecialType != SpecialType.System_Decimal && 53!expression.Type.IsNullableType())) 55EmitConstantExpression(expression.Type, constantValue, used, expression.Syntax); 359EmitDefaultValue(node.Type, used, node.Syntax); 394var receiverType = receiver.Type; 507Debug.Assert(receiver.Type.IsNullableType()); 668EmitSymbolToken(expression.Operand.Type, expression.Operand.Syntax); 723Debug.Assert(argument.Type.IsDynamic(), "passing args byref should not clone them into temps"); 778EmitLoadIndirect(expression.Type, expression.Syntax); 787var meth = expression.MethodOpt ?? receiver.Type.DelegateInvokeMethod(); 985if (((ArrayTypeSymbol)arrayAccess.Expression.Type).IsSZArray) 1072_builder.EmitArrayElementLoad(_module.Translate((ArrayTypeSymbol)arrayAccess.Expression.Type), arrayAccess.Expression.Syntax, _diagnostics.DiagnosticBag); 1092if (!field.IsVolatile && !field.IsStatic && fieldAccess.ReceiverOpt.Type.IsVerifierValue() && field.RefKind == RefKind.None) 1131if (fieldType.IsValueType && (object)fieldType == (object)receiver.Type) 1187if (receiver == null || !receiver.Type.IsValueType) 1198EmitSymbolToken(receiver.Type, receiver.Syntax); 1227if (!receiver.Type.IsVerifierValue()) 1279var type = expr.Type; 1470if (receiver.Type.IsTypeParameter()) 1475Debug.Assert(receiver.Type.IsVerifierReference(), "this is not a reference"); 1605Debug.Assert(TypeSymbol.Equals(method.ContainingType, receiver.Type, TypeCompareKind.ConsiderEverything2)); 1634EmitSymbolToken(receiver.Type, receiver.Syntax); 1657var receiverType = receiver.Type; 1758Debug.Assert(receiver.Type.IsVerifierReference()); 1769Debug.Assert(receiver.Type.IsVerifierReference()); 1788EmitSymbolToken(receiver.Type, receiver.Syntax); 1804var receiverType = receiver.Type; 1866var receiverType = receiver.Type; 2381var rightType = right.Type; 2437if (left.Kind == BoundKind.ArrayAccess && left.Type.TypeKind == TypeKind.TypeParameter && !left.Type.IsValueType) 2461EmitSymbolToken(target.Type, target.Syntax); 2832assignmentOperator.Left.Type, 2879var arrayType = (ArrayTypeSymbol)array.Type; 2893EmitIndirectStore(expression.Type, expression.Syntax); 2898EmitIndirectStore(expression.Type, expression.Syntax); 2904EmitIndirectStore(expression.Type, expression.Syntax); 2916EmitIndirectStore(expression.Type, expression.Syntax); 2921EmitIndirectStore(expression.Type, expression.Syntax); 3167Debug.Assert((object)operand.Type != null); 3168if (!operand.Type.IsVerifierReference()) 3171EmitBox(operand.Type, operand.Syntax); 3190var operandType = operand.Type; 3633if (!(expr.Type.IsInterfaceType() || expr.Type.IsDelegateType())) 3635return expr.Type; 3680return expr.Type; 3751temp = AllocateTemp(ptrInvocation.InvokedExpression.Type, ptrInvocation.Syntax);
CodeGen\EmitOperators.cs (19)
305Debug.Assert(binOp.Left.Type.SpecialType == SpecialType.System_Boolean); 306Debug.Assert(binOp.Right.Type.SpecialType == SpecialType.System_Boolean); 314Debug.Assert(binOp.Left.Type.SpecialType == SpecialType.System_Boolean); 315Debug.Assert(binOp.Right.Type.SpecialType == SpecialType.System_Boolean); 331Debug.Assert(binOp.Left.Type.SpecialType == SpecialType.System_Boolean); 332Debug.Assert(binOp.Right.Type.SpecialType == SpecialType.System_Boolean); 337Debug.Assert(binOp.Left.Type.SpecialType == SpecialType.System_Boolean); 338Debug.Assert(binOp.Right.Type.SpecialType == SpecialType.System_Boolean); 343Debug.Assert(binOp.Left.Type.SpecialType == SpecialType.System_Boolean); 344Debug.Assert(binOp.Right.Type.SpecialType == SpecialType.System_Boolean); 438var comparandType = comparand.Type; 452var comparandType = comparand.Type; 482Debug.Assert(condition.Type.SpecialType == SpecialType.System_Boolean); 582enumType = expression.Left.Type; 587Debug.Assert(TypeSymbol.Equals(expression.Left.Type, expression.Right.Type, TypeCompareKind.ConsiderEverything2)); 592enumType = expression.Right.Type; 714return IsUnsigned(Binder.GetEnumPromotedType(op.Left.Type.GetEnumUnderlyingType().SpecialType)); 717return IsUnsigned(Binder.GetEnumPromotedType(op.Right.Type.GetEnumUnderlyingType().SpecialType));
CodeGen\EmitStatement.cs (28)
178var exprType = thrown.Type; 252var nonConstType = nonConstOp.Type; 530var receiverType = receiver.Type; 589Debug.Assert((object)operand.Type != null); 590if (!operand.Type.IsVerifierReference()) 593EmitBox(operand.Type, operand.Syntax); 610var conditionType = condition.Type; 890_module.Translate(expressionOpt.Type, boundReturnStatement.Syntax, _diagnostics.DiagnosticBag); 1102if (!exceptionSourceOpt.Type.IsVerifierReference()) 1104Debug.Assert(exceptionSourceOpt.Type.IsTypeParameter()); // only expecting type parameters 1106EmitSymbolToken(exceptionSourceOpt.Type, exceptionSourceOpt.Syntax); 1133Debug.Assert(!left.ReceiverOpt.Type.IsTypeParameter()); 1144var temp = AllocateTemp(exceptionSource.Type, exceptionSource.Syntax); 1207Debug.Assert((object)dispatch.Expression.Type != null); 1208Debug.Assert(dispatch.Expression.Type.IsValidV6SwitchGoverningType() || dispatch.Expression.Type.IsSpanOrReadOnlySpanChar()); 1211Debug.Assert(!dispatch.Expression.Type.IsNullableType()); 1230Debug.Assert((object)expression.Type != null && 1231(expression.Type.IsValidV6SwitchGoverningType() || expression.Type.IsSpanOrReadOnlySpanChar())); 1276temp = AllocateTemp(expression.Type, expression.Syntax); 1283expression.Type.SpecialType == SpecialType.System_String || expression.Type.IsSpanOrReadOnlySpanChar()); 1286if (expression.Type.SpecialType == SpecialType.System_String || expression.Type.IsSpanOrReadOnlySpanChar()) 1290this.EmitStringSwitchJumpTable(switchCaseLabels, fallThroughLabel, key, expression.Syntax, expression.Type); 1294this.EmitLengthBasedStringSwitchJumpTable(lengthBasedSwitchStringJumpTableOpt, fallThroughLabel, key, expression.Syntax, expression.Type); 1299_builder.EmitIntegerSwitchJumpTable(switchCaseLabels, fallThroughLabel, key, expression.Type.EnumUnderlyingTypeOrSelf().PrimitiveTypeCode);
CodeGen\Optimizer.cs (11)
610node.Type); 950right.Type.IsVerifierValue() && 973node.Left.Type.Equals(node.Right.Type, TypeCompareKind.AllIgnoreOptions) || 1019left.Type.Equals(((PointerTypeSymbol)right.Type).PointedAtType, TypeCompareKind.AllIgnoreOptions); 1036Debug.Assert(lhs.Type.IsValueType, "'this' is assignable only in structs"); 1143var receiverType = receiver.Type; 1281if (receiver.Type.IsTypeParameter()) 1290if (receiver.Type.IsValueType && ( 1591PushEvalStack(new BoundDefaultExpression(node.Syntax, node.Operand.Type), ExprContext.Value);
Compilation\CSharpCompilation.cs (2)
2019(result!.Type!.IsVoidType() || result.Type!.SpecialType == SpecialType.System_Int32);
Compilation\CSharpSemanticModel.cs (16)
2072type = boundExpr.Type; 2263static (TypeSymbol, NullabilityInfo) getTypeAndNullability(BoundExpression expr) => (expr.Type, expr.TopLevelNullability); 3369else if (expr.Type.IsDelegateType()) 3674var thisParam = GetThisParameter(boundNode.Type, containingType, containingMember, out resultKind); 3798symbols = ImmutableArray.Create<Symbol>(new SynthesizedIntrinsicOperatorSymbol(unaryOperator.Operand.Type.StrippedType(), 3821symbols = ImmutableArray.Create<Symbol>(new SynthesizedIntrinsicOperatorSymbol(increment.Operand.Type.StrippedType(), 3847((binaryOperator.Left.IsLiteralNull() && binaryOperator.Right.Type.IsNullableType()) || 3848(binaryOperator.Right.IsLiteralNull() && binaryOperator.Left.Type.IsNullableType())) && 3862binaryOperator.Left.Type, 3863binaryOperator.Right.Type, 4073TypeSymbol type = boundNode.Type; 4622receiver.Type, 4734extensionThisType = call.ReceiverOpt.Type; 4738extensionThisType = call.Arguments[0].Type; 4768MethodSymbol reduced = method.ReduceExtensionMethod(receiver.Type, Compilation); 4783MethodSymbol reduced = method.ReduceExtensionMethod(receiverOpt.Type, Compilation);
Compilation\MemberSemanticModel.cs (1)
1135return (bound as BoundTupleExpression)?.Type as NamedTypeSymbol;
Compiler\MethodBodySynthesizer.Lowered.cs (2)
360TypeSymbol system_Int32 = currentHashValue.Type!; 385NamedTypeSymbol constructedEqualityComparer = equalityComparerType.Construct(valueToHash.Type);
Emitter\Model\PEModuleBuilder.cs (1)
1286Translate(optArgList.Arguments[i].Type, syntaxNodeOpt, diagnostics));
FlowAnalysis\AbstractFlowPass.cs (5)
637else if ((object)node.Type == null || node.Type.SpecialType != SpecialType.System_Boolean) 2066(object)receiverOpt.Type != null && 2067!receiverOpt.Type.IsPrimitiveRecursiveStruct()); 2440&& conv.Operand.Type!.IsNonNullableValueType());
FlowAnalysis\AbstractFlowPass_Switch.cs (1)
101if (!node.Expression.Type.IsValidV6SwitchGoverningType())
FlowAnalysis\DefiniteAssignment.cs (5)
1081MayRequireTrackingReceiverType(receiver.Type); 1098MayRequireTrackingReceiverType(receiverOpt.Type) && 1099!receiverOpt.Type.IsPrimitiveRecursiveStruct(); 1320if (_emptyStructTypeCache.IsEmptyStructType(node.Type)) return true; 2419if (refKind != RefKind.None && ((object)method == null || method.IsExtern) && arg.Type is TypeSymbol type)
FlowAnalysis\NullableWalker.cs (54)
372expr.Type?.Equals(result.RValueType.Type, TypeCompareKind.AllIgnoreOptions) == true ? result.RValueType.Type : expr.Type); 505Debug.Assert(AreCloseEnough(placeholder.Type, result.RValueType.Type)); 1946receiver.Type is object; 1957TypeSymbol? nodeType = node.Type; 1993var operandType = operand.Type; 2011TypeSymbol.Equals(conv.Type, conv.Operand.Type, TypeCompareKind.IgnoreNullableModifiersForReferenceTypes): 3337Debug.Assert(AreCloseEnough(resultType.Type, node.Type)); 3953SetAnalyzedNullability(node.ImplicitReceiverOpt, new VisitResult(node.ImplicitReceiverOpt.Type, NullableAnnotation.NotAnnotated, NullableFlowState.NotNull)); 4010SetResultType(node, TypeWithState.Create(node.Type, NullableFlowState.NotNull)); 4055Debug.Assert(node.Type is object); 4056if (IsEmptyStructType(node.Type)) 4061return GetOrCreatePlaceholderSlot(node, TypeWithAnnotations.Create(node.Type, NullableAnnotation.NotAnnotated)); 4381Debug.Assert(!node.Expression.Type!.IsValueType); 4395TypeSymbol.Equals(node.Indices[0].Type, compilation.GetWellKnownType(WellKnownType.System_Range), TypeCompareKind.ConsiderEverything2)) 4707if (expr.Type is null) 4717TypeWithAnnotations.Create(expr.Type), 4902var receiverType = conditional.Receiver.Type!; 4931if (slot > 0 && PossiblyNullableType(operand.Type)) 5001LearnFromNullTest(slot, expressionWithoutConversion.Type, ref state, markDependentSlotsNotNull: false); 5110targetType = TypeWithAnnotations.Create(node.Type, NullableAnnotation.NotAnnotated); 5396if (slot > 0 && receiver.Type?.IsNullableType() == true) 5397slot = GetNullableOfTValueSlot(receiver.Type, slot, out _); 5433TypeSymbol? refResultType = node.Type?.SetUnknownNullabilityForReferenceTypes(); 5486resultType ??= node.Type?.SetUnknownNullabilityForReferenceTypes(); 6324TrackAnalyzedNullabilityThroughConversionGroup(TypeWithState.Create(argument.Type, result.RValueType.State), argument as BoundConversion, argumentNoConversion); 7292if (value.Type is null || value.Type.IsDynamic() || value.ConstantValueOpt != null) 7574var tupleOpt = (NamedTypeSymbol?)node.Type; 8717case BoundExpression arg when arg.Type is { TypeKind: TypeKind.Delegate }: 8831Debug.Assert(arg.Type is not null); 8832TypeSymbol argType = arg.Type; 8850Debug.Assert(arg.Type is not null); 8851TypeSymbol argType = arg.Type; 9019var rvalueResult = TypeWithState.Create(node.Type, NullableFlowState.NotNull); 9020var lvalueResult = TypeWithAnnotations.Create(node.Type, NullableAnnotation.NotAnnotated); 9516if (expr.Type is NamedTypeSymbol { IsTupleType: true } tupleType) 9716SetResultType(node.Expression, TypeWithState.Create(node.Expression.Type, ResultType.State)); 10027if (node.Expression.Type!.SpecialType == SpecialType.System_Collections_IEnumerable) 10030targetTypeWithAnnotations = TypeWithAnnotations.Create(node.Expression.Type); 10032else if (ForEachLoopBinder.IsIEnumerableT(node.Expression.Type.OriginalDefinition, isAsync, compilation)) 10277var type = TypeWithAnnotations.Create(node.Type); 10675SetResultType(node, TypeWithState.Create(node.Type, node.Type?.CanContainNull() != false && node.ConstantValueOpt?.IsNull == true ? NullableFlowState.MaybeDefault : NullableFlowState.NotNull)); 10852SetResultType(expression, TypeWithState.Create(expression.Type, default)); 10886Debug.Assert(receiverOpt.Type is null || AreCloseEnough(receiverOpt.Type, resultTypeSymbol)); 10974SetResultType(node, TypeWithState.Create(node.Type, NullableFlowState.NotNull)); 11007Debug.Assert(node.Type is null || node.Type.IsErrorType() || node.Type.IsRefLikeType); 11023SetResultType(node, TypeWithState.Create(node.Type, NullableFlowState.NotNull)); 11027Debug.Assert(node.Type is not null); 11028var type = VisitArrayInitialization(node.Type, initialization, node.HasErrors);
FlowAnalysis\NullableWalker_Patterns.cs (4)
29LearnFromAnyNullPatterns(slot, expression.Type, pattern); 241var originalInputType = node.Expression.Type; 843var originalInputType = node.Expression.Type; 910?? node.Type?.SetUnknownNullabilityForReferenceTypes();
FlowAnalysis\ReadWriteWalker.cs (1)
206if (receiver.Type.IsStructType() && receiverSyntax.Span.OverlapsWith(RegionSpan))
Generated\BoundNodes.xml.Generated.cs (178)
475if (!TypeSymbol.Equals(type, this.Type, TypeCompareKind.ConsiderEverything)) 505if (receiver != this.Receiver || localScopeDepth != this.LocalScopeDepth || !TypeSymbol.Equals(type, this.Type, TypeCompareKind.ConsiderEverything)) 537public new TypeSymbol Type => base.Type!; 574public new TypeSymbol Type => base.Type!; 603public new TypeSymbol? Type => base.Type; 638public new TypeSymbol Type => base.Type!; 675public new TypeSymbol Type => base.Type!; 711public new TypeSymbol Type => base.Type!; 748public new TypeSymbol Type => base.Type!; 784public new TypeSymbol Type => base.Type!; 819public new TypeSymbol Type => base.Type!; 854public new TypeSymbol Type => base.Type!; 889public new TypeSymbol Type => base.Type!; 927if (refKind != this.RefKind || !TypeSymbol.Equals(type, this.Type, TypeCompareKind.ConsiderEverything)) 955if (expression != this.Expression || !TypeSymbol.Equals(type, this.Type, TypeCompareKind.ConsiderEverything)) 988if (resultKind != this.ResultKind || symbols != this.Symbols || childBoundNodes != this.ChildBoundNodes || !TypeSymbol.Equals(type, this.Type, TypeCompareKind.ConsiderEverything)) 1071public new TypeSymbol Type => base.Type!; 1109public new TypeSymbol Type => base.Type!; 1149public new TypeSymbol? Type => base.Type; 1186public new TypeSymbol Type => base.Type!; 1231public new TypeSymbol Type => base.Type!; 1271public new TypeSymbol Type => base.Type!; 1302public new TypeSymbol? Type => base.Type; 1345public new TypeSymbol Type => base.Type!; 1375public new TypeSymbol Type => base.Type!; 1410public new TypeSymbol Type => base.Type!; 1447public new TypeSymbol Type => base.Type!; 1481public new TypeSymbol Type => base.Type!; 1512public new TypeSymbol Type => base.Type!; 1543public new TypeSymbol Type => base.Type!; 1575public new TypeSymbol Type => base.Type!; 1607public new TypeSymbol Type => base.Type!; 1641public new TypeSymbol Type => base.Type!; 1697public new TypeSymbol Type => base.Type!; 1784public new TypeSymbol Type => base.Type!; 1824public new TypeSymbol Type => base.Type!; 1859public new TypeSymbol Type => base.Type!; 1897public new TypeSymbol Type => base.Type!; 1941if (leftOperand != this.LeftOperand || rightOperand != this.RightOperand || !TypeSymbol.Equals(type, this.Type, TypeCompareKind.ConsiderEverything)) 1968public new TypeSymbol? Type => base.Type; 2010public new TypeSymbol Type => base.Type!; 2048public new TypeSymbol Type => base.Type!; 2079public new TypeSymbol Type => base.Type!; 2144public new TypeSymbol Type => base.Type!; 2183public new TypeSymbol Type => base.Type!; 2272public new TypeSymbol Type => base.Type!; 2314public new TypeSymbol Type => base.Type!; 2357public new TypeSymbol Type => base.Type!; 2394public new TypeSymbol Type => base.Type!; 2429public new TypeSymbol Type => base.Type!; 2467public new TypeSymbol Type => base.Type!; 2502public new TypeSymbol Type => base.Type!; 2537public new TypeSymbol Type => base.Type!; 2576public new TypeSymbol Type => base.Type!; 2618public new TypeSymbol Type => base.Type!; 2661public new TypeSymbol Type => base.Type!; 2692public new TypeSymbol? Type => base.Type; 2715public new TypeSymbol Type => base.Type!; 2749public new TypeSymbol Type => base.Type!; 2785public new TypeSymbol Type => base.Type!; 2819public new TypeSymbol Type => base.Type!; 2857public new TypeSymbol Type => base.Type!; 2896public new TypeSymbol Type => base.Type!; 2933public new TypeSymbol Type => base.Type!; 2962public new TypeSymbol? Type => base.Type; 2998public new TypeSymbol Type => base.Type!; 4208if (constantValueOpt != this.ConstantValueOpt || !TypeSymbol.Equals(type, this.Type, TypeCompareKind.ConsiderEverything)) 4240public new TypeSymbol Type => base.Type!; 4276public new TypeSymbol Type => base.Type!; 4311public new TypeSymbol Type => base.Type!; 4346public new TypeSymbol Type => base.Type!; 4375public new TypeSymbol? Type => base.Type; 4420public new TypeSymbol Type => base.Type!; 4467public new TypeSymbol Type => base.Type!; 4500public new TypeSymbol Type => base.Type!; 4541public new TypeSymbol Type => base.Type!; 4686if (!Symbols.SymbolEqualityComparer.ConsiderEverything.Equals(label, this.Label) || !TypeSymbol.Equals(type, this.Type, TypeCompareKind.ConsiderEverything)) 4847if (expression != this.Expression || switchArms != this.SwitchArms || reachabilityDecisionDag != this.ReachabilityDecisionDag || !Symbols.SymbolEqualityComparer.ConsiderEverything.Equals(defaultLabel, this.DefaultLabel) || reportedNotExhaustive != this.ReportedNotExhaustive || !TypeSymbol.Equals(type, this.Type, TypeCompareKind.ConsiderEverything)) 4872public new TypeSymbol Type => base.Type!; 5619public new TypeSymbol? Type => base.Type; 5642if (expression != this.Expression || !TypeSymbol.Equals(type, this.Type, TypeCompareKind.ConsiderEverything)) 5668public new TypeSymbol Type => base.Type!; 5704public new TypeSymbol Type => base.Type!; 5741public new TypeSymbol Type => base.Type!; 5796public new TypeSymbol Type => base.Type!; 5830public new TypeSymbol Type => base.Type!; 5867public new TypeSymbol Type => base.Type!; 5910public new TypeSymbol Type => base.Type!; 5942public new TypeSymbol Type => base.Type!; 6054public new TypeSymbol Type => base.Type!; 6100public new TypeSymbol Type => base.Type!; 6142public new TypeSymbol Type => base.Type!; 6183public new TypeSymbol? Type => base.Type; 6223public new TypeSymbol Type => base.Type!; 6305public new TypeSymbol? Type => base.Type; 6342if (sourceTuple != this.SourceTuple || wasTargetTyped != this.WasTargetTyped || arguments != this.Arguments || argumentNamesOpt != this.ArgumentNamesOpt || inferredNamesOpt != this.InferredNamesOpt || !TypeSymbol.Equals(type, this.Type, TypeCompareKind.ConsiderEverything)) 6441public new TypeSymbol Type => base.Type!; 6495public new TypeSymbol Type => base.Type!; 6547public new TypeSymbol Type => base.Type!; 6614public new TypeSymbol Type => base.Type!; 6653public new TypeSymbol Type => base.Type!; 6689public new TypeSymbol Type => base.Type!; 6722public new TypeSymbol Type => base.Type!; 6764public new TypeSymbol Type => base.Type!; 6827public new TypeSymbol Type => base.Type!; 6861public new TypeSymbol Type => base.Type!; 6892public new TypeSymbol? Type => base.Type; 6947if (!TypeSymbol.Equals(elementType, this.ElementType, TypeCompareKind.ConsiderEverything) || count != this.Count || initializerOpt != this.InitializerOpt || !TypeSymbol.Equals(type, this.Type, TypeCompareKind.ConsiderEverything)) 6969public new TypeSymbol Type => base.Type!; 7003public new TypeSymbol Type => base.Type!; 7048public new TypeSymbol Type => base.Type!; 7080public new TypeSymbol Type => base.Type!; 7115public new TypeSymbol Type => base.Type!; 7157public new TypeSymbol Type => base.Type!; 7209public new TypeSymbol Type => base.Type!; 7250public new TypeSymbol Type => base.Type!; 7292public new TypeSymbol? Type => base.Type; 7336public new TypeSymbol? Type => base.Type; 7374public new TypeSymbol Type => base.Type!; 7437public new TypeSymbol Type => base.Type!; 7488if (parts != this.Parts || constantValueOpt != this.ConstantValueOpt || !TypeSymbol.Equals(type, this.Type, TypeCompareKind.ConsiderEverything)) 7516if (!interpolationData.Equals(this.InterpolationData) || parts != this.Parts || constantValueOpt != this.ConstantValueOpt || !TypeSymbol.Equals(type, this.Type, TypeCompareKind.ConsiderEverything)) 7544if (!TypeSymbol.Equals(type, this.Type, TypeCompareKind.ConsiderEverything)) 7574public new TypeSymbol Type => base.Type!; 7606public new TypeSymbol? Type => base.Type; 7659if (expression != this.Expression || pattern != this.Pattern || isNegated != this.IsNegated || reachabilityDecisionDag != this.ReachabilityDecisionDag || !Symbols.SymbolEqualityComparer.ConsiderEverything.Equals(whenTrueLabel, this.WhenTrueLabel) || !Symbols.SymbolEqualityComparer.ConsiderEverything.Equals(whenFalseLabel, this.WhenFalseLabel) || !TypeSymbol.Equals(type, this.Type, TypeCompareKind.ConsiderEverything)) 8223public new TypeSymbol? Type => base.Type; 8260if (expression != this.Expression || !TypeSymbol.Equals(type, this.Type, TypeCompareKind.ConsiderEverything)) 8282public new TypeSymbol? Type => base.Type; 8355public new TypeSymbol? Type => base.Type; 8453public new TypeSymbol? Type => base.Type; 8486public new TypeSymbol Type => base.Type!; 10442TypeSymbol? type = this.VisitType(node.Type); 10448TypeSymbol? type = this.VisitType(node.Type); 10508TypeSymbol? type = this.VisitType(node.Type); 10514TypeSymbol? type = this.VisitType(node.Type); 10520TypeSymbol? type = this.VisitType(node.Type); 10697TypeSymbol? type = this.VisitType(node.Type); 11048TypeSymbol? type = this.VisitType(node.Type); 11111TypeSymbol? type = this.VisitType(node.Type); 11136TypeSymbol? type = this.VisitType(node.Type); 11273TypeSymbol? type = this.VisitType(node.Type); 11386TypeSymbol? type = this.VisitType(node.Type); 11490TypeSymbol? type = this.VisitType(node.Type); 11584TypeSymbol? type = this.VisitType(node.Type); 11590TypeSymbol? type = this.VisitType(node.Type); 11595TypeSymbol? type = this.VisitType(node.Type); 11616TypeSymbol? type = this.VisitType(node.Type); 11733TypeSymbol? type = this.VisitType(node.Type); 11842updatedNode = node.Update(receiver, node.LocalScopeDepth, node.Type); 12008updatedNode = node.Update(expression, node.Type); 12026updatedNode = node.Update(node.ResultKind, node.Symbols, childBoundNodes, node.Type); 12421updatedNode = node.Update(leftOperand, rightOperand, node.Type); 13181updatedNode = node.Update(expression, switchArms, reachabilityDecisionDag, node.DefaultLabel, node.ReportedNotExhaustive, node.Type); 13276updatedNode = node.Update(expression, node.Type); 13586updatedNode = node.Update(sourceTuple, node.WasTargetTyped, arguments, node.ArgumentNamesOpt, node.InferredNamesOpt, node.Type); 13869updatedNode = node.Update(elementType, count, initializerOpt, node.Type); 14089updatedNode = node.Update(parts, node.ConstantValueOpt, node.Type); 14106updatedNode = node.Update(node.InterpolationData, parts, node.ConstantValueOpt, node.Type); 14168updatedNode = node.Update(expression, pattern, node.IsNegated, reachabilityDecisionDag, node.WhenTrueLabel, node.WhenFalseLabel, node.Type); 14317updatedNode = node.Update(expression, node.Type); 14459new TreeDumperNode("type", node.Type, null), 14468new TreeDumperNode("type", node.Type, null), 14557new TreeDumperNode("type", node.Type, null), 14565new TreeDumperNode("type", node.Type, null), 14575new TreeDumperNode("type", node.Type, null), 14845new TreeDumperNode("type", node.Type, null), 15385new TreeDumperNode("type", node.Type, null), 15487new TreeDumperNode("type", node.Type, null), 15523new TreeDumperNode("type", node.Type, null), 15709new TreeDumperNode("type", node.Type, null), 15916new TreeDumperNode("type", node.Type, null), 16081new TreeDumperNode("type", node.Type, null), 16233new TreeDumperNode("type", node.Type, null), 16243new TreeDumperNode("type", node.Type, null), 16250new TreeDumperNode("type", node.Type, null), 16282new TreeDumperNode("type", node.Type, null), 16436new TreeDumperNode("type", node.Type, null),
Lowering\AsyncRewriter\AsyncExceptionHandlerRewriter.cs (2)
643rewrittenSource.Type, 975this.returnValue = returnValue = new SynthesizedLocal(containingMethod, TypeWithAnnotations.Create(valueOpt.Type), SynthesizedLocalKind.AsyncMethodReturnValue, _syntaxOpt);
Lowering\AsyncRewriter\AsyncMethodToStateMachineRewriter.cs (1)
370var awaiterTemp = F.SynthesizedLocal(getAwaiter.Type, syntax: node.Syntax, kind: SynthesizedLocalKind.Awaiter);
Lowering\AsyncRewriter\AsyncRewriter.AsyncIteratorRewriter.cs (1)
236F.Call(parameterProxy, WellKnownMember.System_Threading_CancellationToken__Equals, F.Default(parameterProxy.Type)),
Lowering\ClosureConversion\ClosureConversion.cs (4)
572Debug.Assert(TypeSymbol.Equals(result.Type, frameType, TypeCompareKind.ConsiderEverything2)); 684BoundExpression assignment = new BoundAssignmentOperator(syntax, left, right, left.Type); 773var assignToProxy = new BoundAssignmentOperator(syntax, left, value, value.Type); 1235rewrittenExceptionSource.Type);
Lowering\ClosureConversion\ExpressionLambdaRewriter.cs (28)
120if (!node.Type.Equals(result.Type, TypeCompareKind.IgnoreNullableModifiersForReferenceTypes)) 300if (!TypeSymbol.Equals(index.Type, _int32Type, TypeCompareKind.ConsiderEverything2)) 302index = ConvertIndex(index, arg.Type, _int32Type); 318if (!TypeSymbol.Equals(index.Type, _int32Type, TypeCompareKind.ConsiderEverything2)) 320index = ConvertIndex(index, arg.Type, _int32Type); 369if (node.Operand.IsLiteralNull() && (object)node.Operand.Type == null) 427if ((object)left.Type == null && left.IsLiteralNull()) 429left = _bound.Default(right.Type); 431if ((object)right.Type == null && right.IsLiteralNull()) 433right = _bound.Default(left.Type); 444var promotedType = PromotedType(enumOperand.Type.StrippedType().GetEnumUnderlyingType()); 497return Convert(loweredOperand, operand.Type, promotedType, isChecked, false); 630var operandType = node.Operand.Type; 639? Convert(Visit(node.Operand), node.Operand.Type, method.Parameters[0].Type, node.Checked, false) 651if (node.Operand.Type.IsNullableType()) 653return Convert(Visit(node.Operand), node.Operand.Type, node.Type, node.Checked, node.ExplicitCastInCode); 660var e1 = Convert(Visit(node.Operand), node.Operand.Type, intermediate, node.Checked, false); 666return Convert(Visit(node.Operand), node.Operand.Type, node.Type, node.Checked, node.ExplicitCastInCode); 683receiver = requiresInstanceReceiver ? nullObject : receiver.Type.IsReferenceType ? receiver : _bound.Convert(_objectType, receiver); 719var d = node.Argument.Type as NamedTypeSymbol; 740if ((object)operand.Type == null && operand.ConstantValueOpt != null && operand.ConstantValueOpt.IsNull) 801TypeSymbol lambdaParamType = node.LeftPlaceholder.Type; 802return ExprFactory("Coalesce", left, right, MakeConversionLambda(leftConversion, lambdaParamType, node.LeftConversion.Type)); 1026if (node.ReceiverOpt?.Type.IsTypeParameter() == true && 1027!node.ReceiverOpt.Type.IsReferenceType) 1074var promotedType = PromotedType(arg.Type.StrippedType().GetEnumUnderlyingType()); 1076loweredArg = Convert(loweredArg, arg.Type, promotedType, isChecked, false); 1103_bound.Typeof(node.Type));
Lowering\DiagnosticsPass_ExpressionTrees.cs (4)
65if (e != null && (object)e.Type != null && e.Type.IsPointerOrFunctionPointer()) NoteUnsafe(e); 92node.Indices[0].Type!.SpecialType == SpecialType.None) 366expr.Type is TypeSymbol type &&
Lowering\DiagnosticsPass_Warnings.cs (18)
228Debug.Assert(TypeSymbol.Equals(expr1.Type, expr2.Type, TypeCompareKind.ConsiderEverything2)); 330if (node.Left.Type.SpecialType == SpecialType.System_Object && !IsExplicitCast(node.Left) && !(node.Left.ConstantValueOpt != null && node.Left.ConstantValueOpt.IsNull) && ConvertedHasEqual(node.OperatorKind, node.Right, out t)) 335else if (node.Right.Type.SpecialType == SpecialType.System_Object && !IsExplicitCast(node.Right) && !(node.Right.ConstantValueOpt != null && node.Right.ConstantValueOpt.IsNull) && ConvertedHasEqual(node.OperatorKind, node.Left, out t)) 356NamedTypeSymbol nt = conv.Operand.Type as NamedTypeSymbol; 447if (!conversion.Operand.Type.SpecialType.IsIntegralType() || !conversion.Type.SpecialType.IsIntegralType()) 452if (!Binder.CheckConstantBounds(conversion.Operand.Type.SpecialType, constantValue, out _)) 454Error(ErrorCode.WRN_VacuousIntegralComp, tree, conversion.Operand.Type); 612TypeSymbol from = conv.Operand.Type; 770Error(ErrorCode.WRN_NubExprIsConstBool, node, always, node.Left.Type.GetNullableUnderlyingType(), node.Left.Type); 774Error(ErrorCode.WRN_NubExprIsConstBool, node, always, node.Right.Type.GetNullableUnderlyingType(), node.Right.Type); 818Error(node.OperatorKind.IsUserDefined() ? ErrorCode.WRN_NubExprIsConstBool2 : ErrorCode.WRN_NubExprIsConstBool, node, always, node.Left.Type.GetNullableUnderlyingType(), GetTypeForLiftedComparisonWarning(node.Right)); 822Error(node.OperatorKind.IsUserDefined() ? ErrorCode.WRN_NubExprIsConstBool2 : ErrorCode.WRN_NubExprIsConstBool, node, always, node.Right.Type.GetNullableUnderlyingType(), GetTypeForLiftedComparisonWarning(node.Left)); 858if ((object)node.Type == null || !node.Type.IsNullableType()) 874return type ?? node.Type;
Lowering\Extensions.cs (8)
35if ((object)expr.Type == null) 40if (expr.Type.IsDynamic()) 45if (!expr.Type.IsNullableType()) 80if ((object)expr.Type == null && expr.ConstantValueOpt == ConstantValue.Null) 85if ((object)expr.Type == null || !expr.Type.IsNullableType()) 132if (expr.Type.IsNullableType() && expr.Type.GetNullableUnderlyingType().SpecialType != SpecialType.System_Boolean)
Lowering\InitializerRewriter.cs (2)
52(object)expression.Type != null && 53!expression.Type.IsVoidType())
Lowering\Instrumentation\DebugInfoInjector.cs (2)
430rewrittenFilter = AddConditionSequencePoint(new BoundSequencePointExpression(filterClause, rewrittenFilter, rewrittenFilter.Type), filterClause, factory); 442return new BoundSequencePointExpression(original.Syntax, base.InstrumentSwitchExpressionArmExpression(original, rewrittenExpression, factory), rewrittenExpression.Type);
Lowering\Instrumentation\DebugInfoInjector_SequencePoints.cs (4)
192Debug.Assert(condition.Type is not null); 201var local = factory.SynthesizedLocal(condition.Type, synthesizedVariableSyntax, kind: SynthesizedLocalKind.ConditionalBranchDiscriminator); 206new BoundSequencePointExpression(syntax: null!, expression: factory.Local(local), type: condition.Type) : 214condition.Type);
Lowering\Instrumentation\LocalStateTracingInstrumenter.cs (2)
557Debug.Assert(invocation.Type is not null); 567if (invocation.Type.SpecialType != SpecialType.System_Void)
Lowering\IteratorRewriter\IteratorMethodToStateMachineRewriter.cs (1)
302_methodValue = F.SynthesizedLocal(result.Type);
Lowering\LocalRewriter\LocalRewriter.cs (19)
228TypeSymbol? type = node.Type; 242Debug.Assert(visited == null || visited.HasErrors || ReferenceEquals(visited.Type, node.Type) || 243visited.Type is { } && visited.Type.Equals(node.Type, TypeCompareKind.IgnoreDynamicAndTupleNames | TypeCompareKind.IgnoreNullableModifiersForReferenceTypes) || 264type: visited.Type); 442Debug.Assert(value.Type is { } && (value.Type.Equals(placeholder.Type, TypeCompareKind.AllIgnoreOptions) || value.HasErrors)); 507Debug.Assert(node.Type is { }); 508return BadExpression(node.Syntax, node.Type, ImmutableArray.Create(node)); 708var indexType = VisitType(node.Indices[0].Type); 720Debug.Assert(node.Expression.Type is { TypeKind: TypeKind.Array }); 721var elementType = ((ArrayTypeSymbol)node.Expression.Type).ElementTypeWithAnnotations; 933Debug.Assert(eventAccess.ReceiverOpt.Type is { }); 934return !eventAccess.ReceiverOpt.Type.IsValueType || CanBePassedByReference(eventAccess.ReceiverOpt); 944Debug.Assert(fieldAccess.ReceiverOpt.Type is { }); 945return !fieldAccess.ReceiverOpt.Type.IsValueType || CanBePassedByReference(fieldAccess.ReceiverOpt);
Lowering\LocalRewriter\LocalRewriter.DecisionDagRewriter.cs (12)
174receiver.Type?.IsReferenceType == false && 747if (input.Type.IsValidV6SwitchGoverningType() || input.Type.IsSpanOrReadOnlySpanChar()) 753bool isStringInput = input.Type.SpecialType == SpecialType.System_String; 754bool isSpanInput = input.Type.IsSpanChar(); 755bool isReadOnlySpanInput = input.Type.IsReadOnlySpanChar(); 783else if (input.Type.IsNativeIntegerType) 788switch (input.Type.SpecialType) 803throw ExceptionUtilities.UnexpectedValue(input.Type); 813var lessThanOrEqualOperator = input.Type.SpecialType switch 818_ => throw ExceptionUtilities.UnexpectedValue(input.Type.SpecialType) 821var cases = node.Cases.Sort(new CasesComparer(input.Type));
Lowering\LocalRewriter\LocalRewriter.PatternLocalRewriter.cs (24)
198TypeSymbol inputType = input.Type; 211Conversion conversion = _factory.Compilation.Conversions.ClassifyBuiltInConversion(inputType, output.Type, isChecked: false, ref useSiteInfo); 219inputType.GetNullableUnderlyingType().Equals(output.Type, TypeCompareKind.AllIgnoreOptions) && 340Debug.Assert(input.Type is { }); 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()); 359Debug.Assert(input.Type.IsValueType); 369Debug.Assert(!rewrittenExpr.Type.IsSpanOrReadOnlySpanChar()); 371if (rewrittenExpr.Type.IsPointerOrFunctionPointer()) 389if (value.IsString && input.Type.IsSpanOrReadOnlySpanChar()) 394TypeSymbol comparisonType = input.Type.EnumUnderlyingTypeOrSelf(); 403if (input.Type.SpecialType == SpecialType.System_Double && double.IsNaN(value.DoubleValue) || 404input.Type.SpecialType == SpecialType.System_Single && float.IsNaN(value.SingleValue)) 410BoundExpression literal = _localRewriter.MakeLiteral(syntax, value, input.Type); 411TypeSymbol comparisonType = input.Type.EnumUnderlyingTypeOrSelf(); 433var isReadOnlySpan = input.Type.IsReadOnlySpanChar(); 475Debug.Assert(output.Type is { }); 477testExpression = _factory.ObjectNotEqual(output, _factory.Null(output.Type)); 511Debug.Assert(loweredInput.Type is { }); 552if (loweredInput.Type.IsTupleType && 553!loweredInput.Type.OriginalDefinition.Equals(_factory.Compilation.GetWellKnownType(WellKnownType.System_ValueTuple_TRest)) && 627var temp = new BoundDagTemp(expr.Syntax, expr.Type, fieldFetchEvaluation);
Lowering\LocalRewriter\LocalRewriter_AsOperator.cs (2)
51ConstantValue constantValue = Binder.GetAsOperatorConstantResult(rewrittenOperand.Type, rewrittenType, conversion.Kind, rewrittenOperand.ConstantValueOpt); 88Debug.Assert(result.Type!.Equals(rewrittenType, TypeCompareKind.ConsiderEverything));
Lowering\LocalRewriter\LocalRewriter_AssignmentOperator.cs (1)
331TypeSymbol? exprType = rewrittenRight.Type;
Lowering\LocalRewriter\LocalRewriter_BinaryOperator.cs (54)
331Debug.Assert(loweredLeft.Type is { }); 332Debug.Assert(loweredRight.Type is { }); 334return MakeUnaryOperator(UnaryOperatorKind.BoolLogicalNegation, syntax, method: null, constrainedToTypeOpt: null, loweredRight, loweredRight.Type); 337return MakeUnaryOperator(UnaryOperatorKind.BoolLogicalNegation, syntax, method: null, constrainedToTypeOpt: null, loweredLeft, loweredLeft.Type); 345Debug.Assert(loweredLeft.Type is { }); 346Debug.Assert(loweredRight.Type is { }); 348return MakeUnaryOperator(UnaryOperatorKind.BoolLogicalNegation, syntax, method: null, constrainedToTypeOpt: null, loweredRight, loweredRight.Type); 351return MakeUnaryOperator(UnaryOperatorKind.BoolLogicalNegation, syntax, method: null, constrainedToTypeOpt: null, loweredLeft, loweredLeft.Type); 359Debug.Assert(loweredLeft.Type is { }); 360Debug.Assert(loweredRight.Type is { }); 362return MakeUnaryOperator(UnaryOperatorKind.BoolLogicalNegation, syntax, method: null, constrainedToTypeOpt: null, loweredRight, loweredRight.Type); 365return MakeUnaryOperator(UnaryOperatorKind.BoolLogicalNegation, syntax, method: null, constrainedToTypeOpt: null, loweredLeft, loweredLeft.Type); 567Debug.Assert(loweredLeft.Type is { }); 568whenNullOpt = RewriteLiftedBinaryOperator(syntax, operatorKind, _factory.Default(loweredLeft.Type), loweredRight, type, method, constrainedToTypeOpt); 578type: result.Type! 877Debug.Assert(expression.Type is { }); 881if (expression.Type.IsNullableType()) 883return BoundCall.Synthesized(syntax, expression, UnsafeGetNullableMethod(syntax, expression.Type, SpecialMember.System_Nullable_T_GetValueOrDefault)); 896Debug.Assert(expression.Type is { }); 900if (expression.Type.IsNullableType()) 910Debug.Assert(expression.Type is { }); 911return BoundCall.Synthesized(syntax, expression, UnsafeGetNullableMethod(syntax, expression.Type, SpecialMember.System_Nullable_T_get_HasValue)); 1534Debug.Assert(TypeSymbol.Equals(conditional.Type, conditional.Consequence.Type, TypeCompareKind.ConsiderEverything2)); 1535Debug.Assert(TypeSymbol.Equals(conditional.Type, conditional.Alternative.Type, TypeCompareKind.ConsiderEverything2)); 1609Debug.Assert(alwaysNull.Type is { }); 1610BoundExpression nullBool = new BoundDefaultExpression(syntax, alwaysNull.Type); 1622rewrittenType: alwaysNull.Type, 1649rewrittenType: alwaysNull.Type, 1651Debug.Assert(conditionalExpression.Type is { }); 1657type: conditionalExpression.Type); 1711rewrittenType: newNullBool.Type!, 1718type: conditionalExpression.Type!); 1798rewrittenType: alternative.Type!, 1806type: conditionalExpression.Type!); 1904return conditionalAccess.Update(conditionalAccess.Receiver, conditionalAccess.HasValueMethodOpt, whenNotNull, whenNull, conditionalAccess.Id, conditionalAccess.ForceCopyOfNullableValueType, whenNotNull.Type!); 1960Debug.Assert(loweredLeft.Type is { SpecialType: SpecialType.System_Decimal }); 1961Debug.Assert(loweredRight.Type is { SpecialType: SpecialType.System_Decimal }); 1994TypeSymbol? exprType = rewrittenExpr.Type; 2057Debug.Assert(loweredRight.Type is { }); 2058TypeSymbol rightType = loweredRight.Type; 2124Debug.Assert(loweredLeft.Type is { }); 2125TypeSymbol leftType = loweredLeft.Type; 2129Debug.Assert(loweredRight.Type is { }); 2130TypeSymbol rightType = loweredRight.Type; 2180Debug.Assert(loweredLeft.Type is { TypeKind: TypeKind.Pointer }); 2181loweredRight = MakeSizeOfMultiplication(loweredRight, (PointerTypeSymbol)loweredLeft.Type, kind.IsChecked()); 2185Debug.Assert(loweredRight.Type is { TypeKind: TypeKind.Pointer }); 2186loweredLeft = MakeSizeOfMultiplication(loweredLeft, (PointerTypeSymbol)loweredRight.Type, kind.IsChecked()); 2225Debug.Assert(sizeOfExpression.Type is { SpecialType: SpecialType.System_Int32 }); 2235Debug.Assert(numericOperand.Type is { }); 2236var numericSpecialType = numericOperand.Type.SpecialType; 2372Debug.Assert(loweredLeft.Type is { TypeKind: TypeKind.Pointer }); 2373Debug.Assert(loweredRight.Type is { TypeKind: TypeKind.Pointer }); 2376PointerTypeSymbol pointerType = (PointerTypeSymbol)loweredLeft.Type;
Lowering\LocalRewriter\LocalRewriter_Call.cs (10)
103if (module != null && receiver != null && receiver.Type is { }) 105var assembly = receiver.Type.ContainingAssembly; 122if (module != null && receiver is { Type: { } }) 124var assembly = receiver.Type.ContainingAssembly; 443Debug.Assert(rewrittenReceiver.Type is { }); 457refKind = rewrittenReceiver.Type.IsValueType || rewrittenReceiver.Type.Kind == SymbolKind.TypeParameter ? RefKind.Ref : RefKind.None; 464!rewrittenReceiver.Type.IsReferenceType && 1425Debug.Assert(value.Type is { }); 1454value.Type);
Lowering\LocalRewriter\LocalRewriter_CompoundAssignmentOperator.cs (26)
24Debug.Assert(TypeSymbol.Equals(node.Right.Type, node.Operator.RightType, TypeCompareKind.ConsiderEverything2)); 92Debug.Assert(rewrittenAssignment.Type is { }); 95var condition = _factory.Conditional(isEvent, invokeEventAccessor.ToExpression(), rewrittenAssignment, rewrittenAssignment.Type); 97rewrittenAssignment = new BoundSequence(node.Syntax, eventTemps.ToImmutableAndFree(), sequence.ToImmutableAndFree(), condition, condition.Type!); 104Debug.Assert(rewrittenAssignment.Type is { }); 112rewrittenAssignment.Type); 144Debug.Assert(node.Left.Type is { }); 156return MakeAssignmentOperator(syntax, transformedLHS, opFinal, node.Left.Type, used: used, isChecked: isChecked, isCompoundAssignment: true); 201Debug.Assert(rewrittenReceiver.Type is { }); 202var variableRepresentsLocation = rewrittenReceiver.Type.IsValueType || rewrittenReceiver.Type.Kind == SymbolKind.TypeParameter; 406indexerAccess.Argument.Type, 413throw ExceptionUtilities.UnexpectedValue(indexerAccess.Argument.Type); 433if (isDynamicAssignment || !IsInvariantArray(arrayAccess.Expression.Type)) 461Debug.Assert(receiver is { Type: { } }); 466else if (!receiver.Type.IsReferenceType) 471Debug.Assert(receiver.Type.IsReferenceType); 475Debug.Assert(rewrittenReceiver.Type is { }); 476if (rewrittenReceiver.Type.IsTypeParameter()) 614Debug.Assert(implicitIndexerAccess.Argument.Type!.Equals(_compilation.GetWellKnownType(WellKnownType.System_Index)) 615|| implicitIndexerAccess.Argument.Type!.Equals(_compilation.GetWellKnownType(WellKnownType.System_Range))); 644if (isDynamicAssignment || !IsInvariantArray(arrayAccess.Expression.Type)) 821var type = expression.Type; 834var type = expression.Type; 889Debug.Assert(expression.Type is { }); 890if (expression.Type.IsNullableType())
Lowering\LocalRewriter\LocalRewriter_ConditionalAccess.cs (10)
41Debug.Assert(node.AccessExpression.Type is { }); 44Debug.Assert(loweredReceiver.Type is { }); 45var receiverType = loweredReceiver.Type; 55var lowerToConditional = node.AccessExpression.Type.IsDynamic(); 120Debug.Assert(loweredAccessExpression.Type is { }); 126TypeSymbol accessExpressionType = loweredAccessExpression.Type; 150Debug.Assert(loweredReceiver.Type is { }); 155UnsafeGetNullableMethod(node.Syntax, loweredReceiver.Type, SpecialMember.System_Nullable_T_get_HasValue) : 208Debug.Assert(newtarget is { Type: { } }); 210if (newtarget.Type.IsNullableType())
Lowering\LocalRewriter\LocalRewriter_Conversion.cs (61)
75Debug.Assert(result.Type!.Equals(toType, TypeCompareKind.IgnoreDynamicAndTupleNames | TypeCompareKind.IgnoreNullableModifiersForReferenceTypes)); 87Debug.Assert(node.Type is not null); 88Debug.Assert(_compilation.IsReadOnlySpanType(node.Type)); 89var byteType = ((NamedTypeSymbol)node.Type).TypeArgumentsWithAnnotationsNoUseSiteDiagnostics.Single().Type; 104result = BadExpression(node.Syntax, node.Type, ImmutableArray<BoundExpression>.Empty); 108result = new BoundObjectCreationExpression(node.Syntax, ctor.AsMember((NamedTypeSymbol)node.Type), utf8Bytes, _factory.Literal(0), _factory.Literal(length)); 219Debug.Assert(rewrittenNode.Type is { }); 220var type = rewrittenNode.Type; 266Debug.Assert(result.Type is { } rt && rt.Equals(rewrittenType, TypeCompareKind.AllIgnoreOptions)); 284type: result.Type); 305@checked = @checked && NeedsCheckedConversionInExpressionTree(rewrittenOperand.Type, rewrittenType, explicitCastInCode); 311Debug.Assert(rewrittenOperand.Type is { }); 324if (_inExpressionLambda || !rewrittenOperand.Type.Equals(rewrittenType, TypeCompareKind.ConsiderEverything)) 419Debug.Assert(rewrittenOperand.Type is { }); 425if (rewrittenType.SpecialType == SpecialType.System_Decimal || rewrittenOperand.Type.SpecialType == SpecialType.System_Decimal) 427return RewriteDecimalConversion(syntax, rewrittenOperand, rewrittenOperand.Type, rewrittenType, @checked, conversion.Kind.IsImplicitConversion(), constantValueOpt); 434Debug.Assert(rewrittenOperand.Type is { }); 437Debug.Assert(rewrittenOperand.Type.Equals(rewrittenType, TypeCompareKind.IgnoreDynamicAndTupleNames | TypeCompareKind.IgnoreNullableModifiersForReferenceTypes)); 480Debug.Assert(rewrittenOperand.Type is { }); 490Debug.Assert(rewrittenOperand.Type.IsEnumType()); 491var underlyingTypeFrom = rewrittenOperand.Type.GetEnumUnderlyingType()!; 495else if (rewrittenOperand.Type.SpecialType == SpecialType.System_Decimal) 503var rewrittenNode = RewriteDecimalConversion(syntax, rewrittenOperand, rewrittenOperand.Type, underlyingTypeTo, @checked, isImplicit: false, constantValueOpt: constantValueOpt); 548(symbolOpt.IsAbstract || symbolOpt.IsVirtual) ? mg.ReceiverOpt?.Type : null, 671Debug.Assert(rewrittenOperand.Type is { }); 673Conversion conversion = compilation.Conversions.ClassifyConversionFromType(rewrittenOperand.Type, rewrittenType, isChecked: @checked, ref useSiteInfo); 679rewrittenOperand.Type.SpecialType != SpecialType.System_Decimal && 680rewrittenOperand.Type.SpecialType != SpecialType.System_DateTime) 686rewrittenOperand.Type, 732if (!TypeSymbol.Equals(rewrittenOperand.Type, conversion.BestUserDefinedConversionAnalysis.FromType, TypeCompareKind.ConsiderEverything2)) 742if (!TypeSymbol.Equals(rewrittenOperand.Type, conversion.Method.GetParameterType(0), TypeCompareKind.ConsiderEverything2)) 755Debug.Assert(rewrittenOperand.Type is { }); 756if (rewrittenOperand.Type.IsNullableType() && 757conversion.Method.GetParameterType(0).Equals(rewrittenOperand.Type.GetNullableUnderlyingType(), TypeCompareKind.AllIgnoreOptions) && 761userDefinedConversionRewrittenType = ((NamedTypeSymbol)rewrittenOperand.Type.OriginalDefinition).Construct(userDefinedConversionRewrittenType); 771if (!TypeSymbol.Equals(userDefined.Type, conversion.BestUserDefinedConversionAnalysis.ToType, TypeCompareKind.ConsiderEverything2)) 780if (!TypeSymbol.Equals(userDefined.Type, rewrittenType, TypeCompareKind.ConsiderEverything2)) 812Debug.Assert(rewrittenOperand.Type is { }); 816var tupleTypeSymbol = (NamedTypeSymbol)rewrittenOperand.Type; 853Debug.Assert(expression.Type is { }); 854if (!expression.Type.IsNullableType()) 866when convertedArgument.Type!.Equals(expression.Type.StrippedType(), TypeCompareKind.AllIgnoreOptions): 871when underlying.Length == 1 && underlying[0].Kind == ConversionKind.ImplicitTuple && !convertedArgument.Type!.IsNullableType(): 906TypeSymbol? rewrittenOperandType = rewrittenOperand.Type; 956Debug.Assert(rewrittenOperand.Type is { }); 957TypeSymbol rewrittenOperandType = rewrittenOperand.Type; 1165Debug.Assert(TypeSymbol.Equals(conditional.Type, conditional.Consequence.Type, TypeCompareKind.ConsiderEverything2)); 1166Debug.Assert(TypeSymbol.Equals(conditional.Type, conditional.Alternative.Type, TypeCompareKind.ConsiderEverything2)); 1198Debug.Assert(rewrittenOperand.Type is { }); 1199if (rewrittenOperand.Type.IsNullableType()) 1202if (parameterType.Equals(rewrittenOperand.Type.GetNullableUnderlyingType(), TypeCompareKind.AllIgnoreOptions) && 1216if ((rewrittenOperand.Type.IsArray()) && _compilation.IsReadOnlySpanType(rewrittenType)) 1223Debug.Assert(TypeSymbol.Equals(result.Type, rewrittenType, TypeCompareKind.ConsiderEverything2)); 1246Debug.Assert(rewrittenOperand.Type is { }); 1249Conversion conv = TryMakeConversion(syntax, conversion, rewrittenOperand.Type, rewrittenType, @checked: @checked); 1261Debug.Assert(rewrittenOperand.Type.IsNullableType()); 1333Debug.Assert(rewrittenOperand.Type is { }); 1336TypeSymbol source = rewrittenOperand.Type; 1563Debug.Assert(operand.Type is { }); 1564return RewriteDecimalConversionCore(syntax, operand, operand.Type, toType, isImplicit, constantValueOpt);
Lowering\LocalRewriter\LocalRewriter_DeconstructionAssignmentOperator.cs (12)
42Debug.Assert(left.Type is { }); 43BoundExpression? result = RewriteDeconstruction(lhsTargets, conversion, left.Type, right, isUsed); 247Debug.Assert(leftTarget is { Type: { } }); 254effects.assignments.Add(MakeAssignmentOperator(resultPart.Syntax, leftTarget, resultPart, leftTarget.Type, 264var tupleType = NamedTypeSymbol.CreateTuple(locationOpt: null, elementTypesWithAnnotations: builder!.SelectAsArray(e => TypeWithAnnotations.Create(e.Type)), 318Debug.Assert(right.Type is { }); 319if (right.Type.IsTupleType) 337Debug.Assert(expression.Type is { }); 338Debug.Assert(expression.Type.IsTupleType); 339var tupleType = expression.Type; 462Debug.Assert(variable.Type is { }); 464effects, temps, isDynamicAssignment: variable.Type.IsDynamic());
Lowering\LocalRewriter\LocalRewriter_Event.cs (1)
179return new BoundSequence(syntax, tempSymbols, sideEffects.ToImmutableAndFree(), marshalCall, marshalCall.Type!);
Lowering\LocalRewriter\LocalRewriter_FixedStatement.cs (8)
209else if (fixedCollectionInitializer.Expression.Type is { SpecialType: SpecialType.System_String }) 213else if (fixedCollectionInitializer.Expression.Type is { TypeKind: TypeKind.Array }) 241Debug.Assert(initializerExpr.Type is { TypeKind: TypeKind.Pointer }); 247TypeSymbol initializerType = ((PointerTypeSymbol)initializerExpr.Type).PointedAtType; 308Debug.Assert(initializerExpr.Type is { }); 310var initializerType = initializerExpr.Type; 410TypeSymbol? initializerType = initializerExpr.Type; 479TypeSymbol? initializerType = initializerExpr.Type;
Lowering\LocalRewriter\LocalRewriter_ForEachStatement.cs (8)
38TypeSymbol? nodeExpressionType = collectionExpression.Type; 450Debug.Assert(receiver.Type is { }); 451if (!receiver.Type.IsReferenceType && method.ContainingType.IsInterface) 526NamedTypeSymbol? collectionType = (NamedTypeSymbol?)collectionExpression.Type; 703Debug.Assert(collectionExpression.Type is { TypeKind: TypeKind.Array }); 705ArrayTypeSymbol arrayType = (ArrayTypeSymbol)collectionExpression.Type; 828Debug.Assert(collectionExpression.Type is { TypeKind: TypeKind.Array }); 830ArrayTypeSymbol arrayType = (ArrayTypeSymbol)collectionExpression.Type;
Lowering\LocalRewriter\LocalRewriter_Index.cs (2)
24operand = new BoundDefaultExpression(operand.Syntax, operand.Type!.GetNullableUnderlyingType()); 72Debug.Assert(TypeSymbol.Equals(targetNullableType.GetNullableUnderlyingType(), underlyingValue.Type, TypeCompareKind.AllIgnoreOptions));
Lowering\LocalRewriter\LocalRewriter_IndexerAccess.cs (17)
208node.Argument.Type, 217node.Argument.Type, 253node.Argument.Type, 266Debug.Assert(receiver.Type is { }); 272receiver.Type.IsReferenceType ? RefKind.None : RefKind.Ref); 330Debug.Assert(integerArgument.Type!.SpecialType == SpecialType.System_Int32); 402Debug.Assert(loweredExpr.Type!.SpecialType == SpecialType.System_Int32); 413Debug.Assert(loweredExpr.Type!.SpecialType == SpecialType.System_Int32); 420loweredExpr.Type, 453unloweredExpr.Type, 461Debug.Assert(hatExpression.Operand is { Type: { SpecialType: SpecialType.System_Int32 } }); 465else if (unloweredExpr is BoundConversion { Operand: { Type: { SpecialType: SpecialType.System_Int32 } } operand }) 474arguments[0] is { Type.SpecialType: SpecialType.System_Int32, ConstantValueOpt.Value: int _ and >= 0 } index && 475arguments[1] is { Type.SpecialType: SpecialType.System_Boolean, ConstantValueOpt.Value: bool fromEnd }) 504node.Argument.Type, 574Debug.Assert(receiver.Type is { }); 580receiver.Type.IsReferenceType ? RefKind.None : RefKind.Ref);
Lowering\LocalRewriter\LocalRewriter_IsOperator.cs (1)
48var operandType = rewrittenOperand.Type;
Lowering\LocalRewriter\LocalRewriter_IsPatternOperator.cs (4)
119Debug.Assert(node.Type is { SpecialType: SpecialType.System_Boolean }); 120LocalSymbol resultTemp = _factory.SynthesizedLocal(node.Type, node.Syntax, kind: SynthesizedLocalKind.LoweringTemp); 175if (test.Type?.IsErrorType() != false) 178Debug.Assert(test.Type.SpecialType == SpecialType.System_Boolean);
Lowering\LocalRewriter\LocalRewriter_Literal.cs (1)
20return MakeLiteral(node.Syntax, node.ConstantValueOpt, node.Type, oldNodeOpt: node);
Lowering\LocalRewriter\LocalRewriter_LockStatement.cs (1)
27TypeSymbol? argumentType = rewrittenArgument.Type;
Lowering\LocalRewriter\LocalRewriter_NullCoalescingAssignmentOperator.cs (17)
16Debug.Assert(node.Type is { }); 20Debug.Assert(node.LeftOperand.Type is { }); 24Debug.Assert(transformedLHS.Type is { }); 41BoundExpression assignment = MakeAssignmentOperator(syntax, transformedLHS, loweredRight, node.LeftOperand.Type, used: true, isChecked: false, isCompoundAssignment: false); 44var leftPlaceholder = new BoundValuePlaceholder(lhsRead.Syntax, lhsRead.Type); 45BoundExpression conditionalExpression = MakeNullCoalescingOperator(syntax, lhsRead, assignment, leftPlaceholder: leftPlaceholder, leftConversion: leftPlaceholder, BoundNullCoalescingOperatorResultKind.LeftType, node.LeftOperand.Type); 46Debug.Assert(conditionalExpression.Type is { }); 55conditionalExpression.Type); 62Debug.Assert(node.LeftOperand.Type.IsNullableType()); 63Debug.Assert(node.Type.Equals(node.RightOperand.Type)); 72leftOperand.Type, 80leftOperand.Type, 110var tmpAssignment = MakeAssignmentOperator(node.Syntax, tmp, loweredRight, node.Type, used: true, isChecked: false, isCompoundAssignment: false); 112Debug.Assert(transformedLHS.Type.GetNullableUnderlyingType().Equals(tmp.Type.StrippedType(), TypeCompareKind.AllIgnoreOptions)); 119MakeConversionNode(tmp, transformedLHS.Type, @checked: false, markAsChecked: true), 120node.LeftOperand.Type,
Lowering\LocalRewriter\LocalRewriter_NullCoalescingOperator.cs (17)
37Debug.Assert(rewrittenRight.Type is { }); 38Debug.Assert(rewrittenRight.Type.Equals(rewrittenResultType, TypeCompareKind.IgnoreDynamicAndTupleNames | TypeCompareKind.IgnoreNullableModifiersForReferenceTypes)); 44Debug.Assert(rewrittenLeft.Type is { }); 61var isUnconstrainedTypeParameter = rewrittenLeft.Type is { IsReferenceType: false, IsValueType: false }; 92Debug.Assert(rewrittenLeft.Type is { }); 93if (rewrittenLeft.Type.IsReferenceType && 112if (whenNullOpt.Type.IsNullableType()) 117if (whenNullOpt.IsDefaultValue() && whenNullOpt.Type.SpecialType != SpecialType.System_Decimal) 136if (rewrittenLeft.Type.IsNullableType() 138&& rewrittenRight.Type.Equals(rewrittenLeft.Type.GetNullableUnderlyingType(), TypeCompareKind.AllIgnoreOptions) 139&& TryGetNullableMethod(rewrittenLeft.Syntax, rewrittenLeft.Type, SpecialMember.System_Nullable_T_GetValueOrDefault, out MethodSymbol getValueOrDefault)) 158Debug.Assert(convertedLeft.HasErrors || convertedLeft.Type!.Equals(rewrittenResultType, TypeCompareKind.IgnoreDynamicAndTupleNames | TypeCompareKind.IgnoreNullableModifiersForReferenceTypes)); 171Debug.Assert(conditionalExpression.Type!.Equals(rewrittenResultType, TypeCompareKind.IgnoreDynamicAndTupleNames | TypeCompareKind.IgnoreNullableModifiersForReferenceTypes)); 229Debug.Assert(rewrittenLeft.Type is { }); 233TypeSymbol rewrittenLeftType = rewrittenLeft.Type; 241var conversionTakesNullableType = leftPlaceholder?.Type?.IsNullableType() == true;
Lowering\LocalRewriter\LocalRewriter_ObjectCreationExpression.cs (5)
80Debug.Assert(TypeSymbol.Equals(rewrittenObjectCreation.Type, ((NamedTypeSymbol)node.Type).ComImportCoClass, TypeCompareKind.ConsiderEverything2)); 92rewrittenObjectCreation = new BoundDefaultExpression(rewrittenObjectCreation.Syntax, rewrittenObjectCreation.Type!); 107Debug.Assert(TypeSymbol.Equals(rewrittenObjectCreation.Type, ((NamedTypeSymbol)node.Type).ComImportCoClass, TypeCompareKind.ConsiderEverything2)); 128Debug.Assert(receiver.Type!.Equals(type, TypeCompareKind.ConsiderEverything)); 313return MakeExpressionWithInitializer(node.Syntax, rewrittenNewT, node.InitializerExpressionOpt, rewrittenNewT.Type!);
Lowering\LocalRewriter\LocalRewriter_ObjectOrCollectionInitializerExpression.cs (1)
505Debug.Assert(_compilation.Conversions.ClassifyConversionFromType(rewrittenReceiver.Type, memberSymbol.ContainingType, isChecked: false, ref discardedUseSiteInfo).IsImplicit);
Lowering\LocalRewriter\LocalRewriter_PointerElementAccess.cs (5)
46Debug.Assert(rewrittenExpression.Type is { }); 47Debug.Assert(rewrittenIndex.Type is { }); 48switch (rewrittenIndex.Type.SpecialType) 63throw ExceptionUtilities.UnexpectedValue(rewrittenIndex.Type.SpecialType); 78rewrittenExpression.Type,
Lowering\LocalRewriter\LocalRewriter_PropertyAccess.cs (2)
37if (rewrittenReceiverOpt is { Type: { TypeKind: TypeKind.Array } } && !isLeftOfAssignment) 39var asArrayType = (ArrayTypeSymbol)rewrittenReceiverOpt.Type;
Lowering\LocalRewriter\LocalRewriter_Range.cs (8)
56Debug.Assert(operand.Type is { }); 60operand = new BoundDefaultExpression(operand.Syntax, operand.Type.GetNullableUnderlyingType()); 65Debug.Assert(operand.Type is { }); 67if (operand.Type.IsNullableType()) 80Debug.Assert(left?.Type?.IsNullableType() == true || right?.Type?.IsNullableType() == true); 131Debug.Assert(tempOperand.Type is { }); 133if (tempOperand.Type.IsNullableType())
Lowering\LocalRewriter\LocalRewriter_StackAlloc.cs (1)
28var type = stackAllocNode.Type;
Lowering\LocalRewriter\LocalRewriter_StringConcat.cs (37)
52Debug.Assert(loweredLeft.Type is { } && (loweredLeft.Type.IsStringType() || loweredLeft.Type.IsErrorType()) || loweredLeft.ConstantValueOpt?.IsNull == true); 53Debug.Assert(loweredRight.Type is { } && (loweredRight.Type.IsStringType() || loweredRight.Type.IsErrorType()) || loweredRight.ConstantValueOpt?.IsNull == true); 302Debug.Assert(loweredLeft.HasAnyErrors || loweredLeft.Type is { } && loweredLeft.Type.IsStringType()); 303Debug.Assert(loweredRight.HasAnyErrors || loweredRight.Type is { } && loweredRight.Type.IsStringType()); 313Debug.Assert(loweredFirst.HasAnyErrors || loweredFirst.Type is { } && loweredFirst.Type.IsStringType()); 314Debug.Assert(loweredSecond.HasAnyErrors || loweredSecond.Type is { } && loweredSecond.Type.IsStringType()); 315Debug.Assert(loweredThird.HasAnyErrors || loweredThird.Type is { } && loweredThird.Type.IsStringType()); 325Debug.Assert(loweredFirst.HasAnyErrors || loweredFirst.Type is { } && loweredFirst.Type.IsStringType()); 326Debug.Assert(loweredSecond.HasAnyErrors || loweredSecond.Type is { } && loweredSecond.Type.IsStringType()); 327Debug.Assert(loweredThird.HasAnyErrors || loweredThird.Type is { } && loweredThird.Type.IsStringType()); 328Debug.Assert(loweredFourth.HasAnyErrors || loweredFourth.Type is { } && loweredFourth.Type.IsStringType()); 339Debug.Assert(loweredArgs.All(a => a.HasErrors || a.Type is { } && a.Type.IsStringType())); 382Debug.Assert(expr.Type is { }); 401if (expr.Type.IsStringType()) 413if (expr.Type.IsValueType && !expr.Type.IsTypeParameter()) 415var type = (NamedTypeSymbol)expr.Type; 432if (structToStringMethod != null && (expr.Type.SpecialType != SpecialType.None && !isFieldOfMarshalByRef(expr, _compilation))) 447bool callWithoutCopy = expr.Type.IsReferenceType || 449(structToStringMethod == null && !expr.Type.IsTypeParameter()) || 453if (expr.Type.IsValueType) 457expr = new BoundPassByCopy(expr.Syntax, expr, expr.Type); 489new BoundConditionalReceiver(syntax, currentConditionalAccessID, expr.Type),
Lowering\LocalRewriter\LocalRewriter_StringInterpolation.cs (16)
46Debug.Assert(rewrittenOperand.Type is object); 49Conversion conversion = _compilation.Conversions.ClassifyConversionFromType(rewrittenOperand.Type, rewrittenType, isChecked: false, ref useSiteInfo); 57rewrittenOperand.Type, 151if (actualCall.Type!.IsDynamic()) 196fillin.Value.Type?.SpecialType != SpecialType.System_String || 235if (value.Type?.TypeKind == TypeKind.Dynamic) 279Debug.Assert(node.Type is { SpecialType: SpecialType.System_String }); // if target-converted, we should not get here. 285return LowerPartsToString(data, node.Parts, node.Syntax, node.Type); 319_factory.Binary(BinaryOperatorKind.StringConcatenation, node.Type, result, part); 328Debug.Assert(result.Type is not null); 329Debug.Assert(result.Type.SpecialType == SpecialType.System_String || result.Type.IsErrorType()); 330var placeholder = new BoundValuePlaceholder(result.Syntax, result.Type); 331result = new BoundNullCoalescingOperator(result.Syntax, result, _factory.StringLiteral(""), leftPlaceholder: placeholder, leftConversion: placeholder, BoundNullCoalescingOperatorResultKind.LeftType, @checked: false, result.Type) { WasCompilerGenerated = true }; 353var stringType = node.Type; 363result = MakeImplicitConversionForInterpolatedString(result, node.Type);
Lowering\LocalRewriter\LocalRewriter_TupleBinaryOperator.cs (32)
54Debug.Assert(expr.Type == (object?)o.Type || expr.Type is { } && expr.Type.Equals(o.Type, TypeCompareKind.AllIgnoreOptions)); 90expr.Type is { } exprType && exprType.IsNullableType() && exprType.StrippedType().Equals(o.Type, TypeCompareKind.AllIgnoreOptions): 107Debug.Assert(expr.Type is { }); 108var destElementTypes = expr.Type.TupleElementTypesWithAnnotations; 110Debug.Assert(boundConversion.Operand.Type is { }); 111var srcElementFields = boundConversion.Operand.Type.TupleElements; 127ImmutableArray<bool>.Empty, expr.Type, expr.HasErrors); 163ImmutableArray<bool>.Empty, tuple.Type, tuple.HasErrors); 206return new BoundLiteral(expr.Syntax, ConstantValue.Null, expr.Type); 356isNullable = !(expr is BoundTupleExpression) && expr.Type is { } && expr.Type.IsNullableType(); 368Debug.Assert(expr.Type is { }); 371value = new BoundDefaultExpression(expr.Syntax, expr.Type.StrippedType()); 398Debug.Assert(expr.Type is { }); 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: 440Debug.Assert(expr.Type is { }); 443Debug.Assert(operand.Type is { }); 444var types = expr.Type.GetNullableUnderlyingType().TupleElementTypesWithAnnotations; 445int tupleCardinality = operand.Type.TupleElementTypesWithAnnotations.Length; 461type: expr.Type, 524Debug.Assert(tuple.Type is { IsTupleType: true }); 530return MakeTupleFieldAccessAndReportUseSiteDiagnostics(tuple, tuple.Syntax, tuple.Type.TupleElements[i]);
Lowering\LocalRewriter\LocalRewriter_TupleCreationExpression.cs (2)
39Debug.Assert(node.Type is { }); 40return MakeTupleCreationExpression(node.Syntax, (NamedTypeSymbol)node.Type, rewrittenArguments);
Lowering\LocalRewriter\LocalRewriter_UnaryOperator.cs (19)
127var underlyingType = loweredOperand.Type.GetEnumUnderlyingType(); 271Debug.Assert(result.Type is { }); 280type: result.Type 323Debug.Assert(TypeSymbol.Equals(conditional.Type, conditional.Consequence.Type, TypeCompareKind.ConsiderEverything2)); 324Debug.Assert(TypeSymbol.Equals(conditional.Type, conditional.Alternative.Type, TypeCompareKind.ConsiderEverything2)); 434TypeSymbol? operandType = transformedLHS.Type; //type of the variable being incremented 537Debug.Assert(tempValue.Type is { }); 546tempValue.Type); 755Debug.Assert(binaryOperand.Type is { TypeKind: TypeKind.Pointer }); 756Debug.Assert(boundOne.Type is { SpecialType: SpecialType.System_Int32 }); 757return MakeBinaryOperator(node.Syntax, binaryOperatorKind, binaryOperand, boundOne, binaryOperand.Type, method: null, constrainedToTypeOpt: null); 809Debug.Assert(operand.Type is { SpecialType: SpecialType.System_Decimal }); 816Debug.Assert(operand.Type is { } && operand.Type.IsNullableType() && operand.Type.GetNullableUnderlyingType().SpecialType == SpecialType.System_Decimal); 820MethodSymbol getValueOrDefault = UnsafeGetNullableMethod(syntax, operand.Type, SpecialMember.System_Nullable_T_GetValueOrDefault); 821MethodSymbol ctor = UnsafeGetNullableMethod(syntax, operand.Type, SpecialMember.System_Nullable_T__ctor); 832BoundExpression alternative = new BoundDefaultExpression(syntax, operand.Type); 835return RewriteConditionalOperator(syntax, condition, consequence, alternative, ConstantValue.NotAvailable, operand.Type, isRef: false);
Lowering\LocalRewriter\LocalRewriter_UsingStatement.cs (2)
148Debug.Assert(rewrittenExpression.Type is { }); 149TypeSymbol expressionType = rewrittenExpression.Type;
Lowering\LocalRewriter\LoweredDynamicOperationFactory.cs (6)
544Debug.Assert(loweredReceiver.Type is { }); 545if (!loweredReceiver.Type.IsValueType) 840var argType = boundArgument.Type; 919result[j++] = receiver.Type ?? systemObjectType; 925result[j++] = arguments[i].Type ?? systemObjectType; 931result[j++] = right.Type ?? systemObjectType;
Lowering\SpillSequenceSpiller.cs (16)
46: base(SpillSequenceBuilderKind, syntax, value?.Type) 175new TreeDumperNode("type", this.Type, null) 381if (refKind != RefKind.None || expression.Type.IsReferenceType) 433if (expression.Type.IsVoidType() || sideEffectsOnly) 963Debug.Assert(refKind == RefKind.None || !receiver.Type.IsReferenceType); 972var receiverType = receiver.Type; 1003if (!receiver.Type.IsReferenceType && LocalRewriter.CanBePassedByReference(receiver)) 1005result = receiver.Type.IsReadOnly ? RefKind.In : RefKind.Ref; 1099type: node.Type)); 1156_F.ObjectEqual(_F.Local(tmp), _F.Null(left.Type)), 1188if (receiver.Type.IsReferenceType || receiver.Type.IsValueType || receiverRefKind == RefKind.None) 1210var clone = _F.SynthesizedLocal(receiver.Type, _F.Syntax, refKind: RefKind.None, kind: SynthesizedLocalKind.Spill); 1215_F.Convert(_F.SpecialType(SpecialType.System_Object), _F.Default(receiver.Type)), 1386return UpdateExpression(builder, node.Update(operand, node.Type)); 1430return UpdateExpression(builder, node.Update(expression, node.Type));
Lowering\StateMachineRewriter\CapturedSymbol.cs (2)
42var field = this.HoistedField.AsMember((NamedTypeSymbol)frame.Type); 60var field = this.HoistedField.AsMember((NamedTypeSymbol)frame.Type);
Lowering\StateMachineRewriter\MethodToStateMachineRewriter.cs (5)
145Debug.Assert(thisProxyReplacement.Type is not null); 146this.cachedThis = F.SynthesizedLocal(thisProxyReplacement.Type, syntax: F.Syntax, kind: SynthesizedLocalKind.FrameCache); 526Debug.Assert(TypeSymbol.Equals(type, replacement.Type, TypeCompareKind.ConsiderEverything2)); 643TypeSymbol fieldType = expr.Type; 670hoistedField = F.StateMachineField(expr.Type, fieldName, new LocalSlotDebugInfo(kind, id), slotIndex);
Lowering\SyntheticBoundNodeFactory.cs (53)
306Debug.Assert(receiverOpt is null || receiverOpt.Type is { } && 307receiverOpt.Type.GetMembers(propertySym.Name).OfType<PropertySymbol>().Single() == propertySym); 318Debug.Assert(!(receiverOpt is { Type: ArrayTypeSymbol { IsSZArray: true } } && 436Debug.Assert(left.Type is { } && right.Type is { } && 437(left.Type.Equals(right.Type, TypeCompareKind.AllIgnoreOptions) || 439right.Type.IsErrorType() || left.Type.IsErrorType())); 441return AssignmentExpression(Syntax, left, right, left.Type, isRef: isRef, wasCompilerGenerated: true); 524var conversion = Compilation.Conversions.ClassifyConversionFromType(expression.Type, CurrentFunction.ReturnType, isChecked: false, ref useSiteInfo); 612Conversion c = Compilation.Conversions.ClassifyBuiltInConversion(operand.Type, type, isChecked: false, ref discardedUseSiteInfo); 618Debug.Assert(left.Type?.SpecialType == CodeAnalysis.SpecialType.System_Boolean); 619Debug.Assert(right.Type?.SpecialType == CodeAnalysis.SpecialType.System_Boolean); 625Debug.Assert(left.Type?.SpecialType == CodeAnalysis.SpecialType.System_Boolean); 626Debug.Assert(right.Type?.SpecialType == CodeAnalysis.SpecialType.System_Boolean); 719switch (input.Type) 728throw ExceptionUtilities.UnexpectedValue(input.Type); 838Debug.Assert(valueTypeReceiver.Type is { }); 839Debug.Assert(TypeSymbol.Equals(valueTypeReceiver.Type, referenceTypeReceiver.Type, TypeCompareKind.ConsiderEverything2)); 840return new BoundComplexConditionalReceiver(Syntax, valueTypeReceiver, referenceTypeReceiver, valueTypeReceiver.Type) { WasCompilerGenerated = true }; 845Debug.Assert(left.Type!.Equals(right.Type, TypeCompareKind.IgnoreCustomModifiersAndArraySizesAndLowerBounds | TypeCompareKind.IgnoreNullableModifiersForReferenceTypes) || left.Type.IsErrorType()); 846Debug.Assert(left.Type.IsReferenceType); 848return new BoundNullCoalescingOperator(Syntax, left, right, leftPlaceholder: null, leftConversion: null, BoundNullCoalescingOperatorResultKind.LeftType, @checked: false, left.Type) { WasCompilerGenerated = true }; 956Debug.Assert(result.Type is { }); 957var resultType = type ?? result.Type; 963Debug.Assert(result.Type is { }); 967: new BoundSequence(Syntax, locals, sideEffects, result, result.Type) { WasCompilerGenerated = true }; 972Debug.Assert(result.Type is { }); 973return new BoundSpillSequence(Syntax, locals, sideEffects, result, result.Type) { WasCompilerGenerated = true }; 1002Debug.Assert(ex.Type is { SpecialType: CodeAnalysis.SpecialType.System_Int32 }); 1097Debug.Assert(array.Type is { TypeKind: TypeKind.Array }); 1103Debug.Assert(array.Type is { TypeKind: TypeKind.Array }); 1104int rank = ((ArrayTypeSymbol)array.Type).Rank; 1116Debug.Assert(array.Type is { TypeKind: TypeKind.Array }); 1117return new BoundArrayAccess(Syntax, array, indices, ((ArrayTypeSymbol)array.Type).ElementType); 1349if (TypeSymbol.Equals(type, arg.Type, TypeCompareKind.ConsiderEverything2)) 1372if (conversion.Method is { } && !TypeSymbol.Equals(conversion.Method.Parameters[0].Type, arg.Type, TypeCompareKind.ConsiderEverything2)) 1382Debug.Assert(arg.Type is { }); 1384arg.Type.IsNullableType() && 1385arg.Type.GetNullableUnderlyingType().Equals(type, TypeCompareKind.AllIgnoreOptions)) 1389return this.Call(arg, this.SpecialMethod(CodeAnalysis.SpecialMember.System_Nullable_T_get_Value).AsMember((NamedTypeSymbol)arg.Type)); 1478return new BoundCatchBlock(Syntax, ImmutableArray<LocalSymbol>.Empty, source, source.Type, exceptionFilterPrologueOpt: null, exceptionFilterOpt: null, body: block, isSynthesizedAsyncCatchAll: false); 1498Debug.Assert(expression is { Type: { SpecialType: CodeAnalysis.SpecialType.System_Boolean } }); 1499return new BoundUnaryOperator(expression.Syntax, UnaryOperatorKind.BoolLogicalNegation, expression, null, null, constrainedToTypeOpt: null, LookupResultKind.Viable, expression.Type); 1519Debug.Assert(argument.Type is { }); 1552var type = argument.Type; 1622TypeSymbol exprType = rewrittenExpr.Type; 1672return BoundCall.Synthesized(syntax, expression, LocalRewriter.UnsafeGetNullableMethod(syntax, expression.Type, CodeAnalysis.SpecialMember.System_Nullable_T_get_HasValue, Compilation, Diagnostics)); 1736return conditionalAccess.Update(conditionalAccess.Receiver, conditionalAccess.HasValueMethodOpt, whenNotNull, whenNull, conditionalAccess.Id, conditionalAccess.ForceCopyOfNullableValueType, whenNotNull.Type);
Operations\CSharpOperationFactory.cs (3)
1076if (boundOperand.Kind == BoundKind.ConvertedTupleLiteral && TypeSymbol.Equals(boundOperand.Type, boundConversion.Type, TypeCompareKind.ConsiderEverything2)) 1097!TypeSymbol.Equals(nestedConversion.Type, nestedOperand.Type, TypeCompareKind.ConsiderEverything2)) 1529boundNullCoalescingOperator.Type.Equals(boundNullCoalescingOperator.LeftOperand.Type?.StrippedType(), TypeCompareKind.IgnoreCustomModifiersAndArraySizesAndLowerBounds | TypeCompareKind.IgnoreNullableModifiersForReferenceTypes))
Symbols\ConstantValueUtils.cs (2)
166if (!(expression.Type is null) && expression.Type.IsStringType())
Symbols\Source\ParameterHelpers.cs (7)
752conversion.IsIdentity && parameterType.SpecialType == SpecialType.System_Object && defaultExpression.Type.IsDynamic()) 766(object)defaultExpression.Type != null && 767defaultExpression.Type.SpecialType == SpecialType.System_String || 777else if (((conversion.IsNullable && !defaultExpression.Type.IsNullableType()) || 778(conversion.IsObjectCreation && convertedExpression.Type.IsNullableType())) && 795(defaultExpression.IsImplicitObjectCreation() ? convertedExpression.Type.StrippedType() : defaultExpression.Type), parameterSyntax.Identifier.ValueText);
Symbols\Source\SourceLocalSymbol.cs (1)
546return TypeWithAnnotations.Create(initializerOpt?.Type);
Symbols\Source\SourceMemberFieldSymbol.cs (3)
539if ((object)initializerOpt.Type != null && !initializerOpt.Type.IsErrorType()) 541type = TypeWithAnnotations.Create(initializerOpt.Type);
Symbols\Synthesized\Records\SynthesizedRecordPrintMembers.cs (2)
209Debug.Assert(value.Type is not null); 210if (value.Type.IsValueType)
Symbols\Synthesized\SynthesizedEntryPointSymbol.cs (1)
379public override TypeWithAnnotations ReturnTypeWithAnnotations => TypeWithAnnotations.Create(_getAwaiterGetResultCall.Type);
Microsoft.CodeAnalysis.CSharp.ExpressionEvaluator.ExpressionCompiler (5)
CompilationContext.cs (1)
709var expressionType = expression.Type;
Rewriters\CapturedVariableRewriter.cs (2)
63Debug.Assert(TypeSymbol.Equals(node.Type, result.Type, TypeCompareKind.ConsiderEverything2)); 78Debug.Assert(rewrittenThis.Type.Equals(node.Type, TypeCompareKind.IgnoreDynamicAndTupleNames | TypeCompareKind.IgnoreNullableModifiersForReferenceTypes));
Rewriters\PlaceholderLocalRewriter.cs (1)
35Debug.Assert(TypeSymbol.Equals(result.Type, node.Type, TypeCompareKind.ConsiderEverything2));
Symbols\EEMethodSymbol.cs (1)
740return ((BoundReturnStatement)bodyOpt).ExpressionOpt.Type;
Microsoft.CodeAnalysis.CSharp.Semantic.UnitTests (28)
Semantics\ForEachTests.cs (28)
1219Assert.Equal(SpecialType.System_Collections_IEnumerable, boundNode.Expression.Type.SpecialType); 1220Assert.Equal(SymbolKind.ArrayType, ((BoundConversion)boundNode.Expression).Operand.Type.Kind); 1257Assert.Equal(SpecialType.System_String, boundNode.Expression.Type.SpecialType); 1258Assert.Equal(SpecialType.System_String, ((BoundConversion)boundNode.Expression).Operand.Type.SpecialType); 1301Assert.Equal("Enumerable", boundNode.Expression.Type.ToTestDisplayString()); 1302Assert.Equal("Enumerable", ((BoundConversion)boundNode.Expression).Operand.Type.ToTestDisplayString()); 1345Assert.Equal("Enumerable", boundNode.Expression.Type.ToTestDisplayString()); 1346Assert.Equal("Enumerable", ((BoundConversion)boundNode.Expression).Operand.Type.ToTestDisplayString()); 1378Assert.Equal("System.Collections.IEnumerable", boundNode.Expression.Type.ToTestDisplayString()); 1379Assert.Equal("System.Collections.IEnumerable", ((BoundConversion)boundNode.Expression).Operand.Type.ToTestDisplayString()); 1418Assert.Equal("System.Collections.Generic.IEnumerable<System.Int32>", boundNode.Expression.Type.ToTestDisplayString()); 1419Assert.Equal("Enumerable", ((BoundConversion)boundNode.Expression).Operand.Type.ToTestDisplayString()); 1460Assert.Equal(SpecialType.System_Collections_IEnumerable, boundNode.Expression.Type.SpecialType); 1461Assert.Equal("Enumerable", ((BoundConversion)boundNode.Expression).Operand.Type.ToTestDisplayString()); 1499Assert.Equal(SpecialType.System_Collections_IEnumerable, boundNode.Expression.Type.SpecialType); 1500Assert.Equal("Enumerable", ((BoundConversion)boundNode.Expression).Operand.Type.ToTestDisplayString()); 1680Assert.Equal(SpecialType.System_Collections_IEnumerable, boundNode.Expression.Type.SpecialType); 1681Assert.Equal(TypeKind.Dynamic, ((BoundConversion)boundNode.Expression).Operand.Type.TypeKind); 1713Assert.Equal(SpecialType.System_Collections_IEnumerable, boundNode.Expression.Type.SpecialType); 1714Assert.Equal(SymbolKind.DynamicType, ((BoundConversion)boundNode.Expression).Operand.Type.Kind); 1754Assert.Equal("Enumerable<T>", boundNode.Expression.Type.ToTestDisplayString()); 1755Assert.Equal("Enumerable<T>", ((BoundConversion)boundNode.Expression).Operand.Type.ToTestDisplayString()); 1838Assert.Equal("Enumerable<T>", boundNode.Expression.Type.ToTestDisplayString()); 1839Assert.Equal("Enumerable<T>", ((BoundConversion)boundNode.Expression).Operand.Type.ToTestDisplayString()); 1885Assert.Equal("Enumerable", boundNode.Expression.Type.ToTestDisplayString()); 1886Assert.Equal("Enumerable", ((BoundConversion)boundNode.Expression).Operand.Type.ToTestDisplayString()); 3237Assert.Equal("C", info.GetEnumeratorInfo.Arguments.Single().Type.ToTestDisplayString()); 3247Assert.Equal("C", boundNode.Expression.Type.ToDisplayString());