Binder\Binder.ValueChecks.cs (29)
706Debug.Assert(!checkingReceiver || expr.Type.IsValueType || expr.Type.IsTypeParameter());
733if ((expr.ConstantValueOpt != null) || (expr.Type.GetSpecialTypeSafe() == SpecialType.System_Void))
923getItemOrSliceHelper = getItemOrSliceHelper.AsMember(getItemOrSliceHelper.ContainingType.Construct(ImmutableArray.Create(elementAccess.Expression.Type.TryGetInlineArrayElementField().TypeWithAnnotations)));
994indices[0].Type,
1027Error(diagnostics, ErrorCode.ERR_BadSKunknown, expr.Syntax, expr.Type, MessageID.IDS_SK_TYPE.Localize());
1658&& receiver?.Type?.IsValueType == true;
1890if (receiver is BoundObjectOrCollectionValuePlaceholder && receiver.Type.IsAnonymousType)
2074if (methodInfo.Method?.RequiresInstanceReceiver == true && receiver?.Type?.IsRefLikeOrAllowsRefLikeType() == true)
2286if (receiver?.Type?.IsRefLikeOrAllowsRefLikeType() == true)
2383Debug.Assert(receiver.Type is { });
2388Debug.Assert(receiver is not BoundValuePlaceholderBase && method is not null && receiver.Type?.IsReferenceType == false);
2393receiver = new BoundCapturedReceiverPlaceholder(receiver.Syntax, receiver, _localScopeDepth, receiver.Type).MakeCompilerGenerated();
2508if (receiver.Type is TypeParameterSymbol typeParameter)
3401Debug.Assert(expr.Type is not null);
3433if (expr.Type?.GetSpecialTypeSafe() == SpecialType.System_Void)
3734Debug.Assert(!checkingReceiver || expr.Type.IsValueType || expr.Type.IsTypeParameter());
3749if (expr.Type?.GetSpecialTypeSafe() == SpecialType.System_Void)
4142if (expr.Type?.IsRefLikeOrAllowsRefLikeType() != true)
4611RoslynDebug.Assert(false, $"{expr.Kind} expression of {expr.Type} type");
4818Debug.Assert(!checkingReceiver || expr.Type.IsValueType || expr.Type.IsTypeParameter());
4839if (expr.Type?.IsRefLikeOrAllowsRefLikeType() != true)
4904Error(diagnostics, inUnsafeRegion ? ErrorCode.WRN_EscapeStackAlloc : ErrorCode.ERR_EscapeStackAlloc, node, expr.Type);
5213Error(diagnostics, ErrorCode.ERR_CollectionExpressionEscape, node, expr.Type);
5412RoslynDebug.Assert(false, $"{expr.Kind} expression of {expr.Type} type");
5585TypeWithAnnotations.Create(elementAccess.Expression.Type),
5625TypeWithAnnotations.Create(inlineArray.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);
353Error(diagnostics, ErrorCode.ERR_BadAwaitArg, node, expression.Type);
437var awaiterType = awaiterExpression.Type;
Binder\Binder_Conversions.cs (26)
75else if (source.Type is not null && filterConversion(conversion))
77var placeholder2 = new BoundValuePlaceholder(source.Syntax, source.Type);
120RoslynDebug.Assert(source.Type is object);
124if (!isCast && source.Type.Equals(destination, TypeCompareKind.IgnoreNullableModifiersForReferenceTypes))
211TypeSymbol? type = source.Type;
255Debug.Assert(source.Type is null);
281source.Type is { } sourceType &&
322switch (source.Type?.IsNullableType())
327new BoundValuePlaceholder(source.Syntax, source.Type.GetNullableUnderlyingType()),
352else if (source.Type?.IsNullableType() == true)
356new BoundValuePlaceholder(source.Syntax, source.Type.GetNullableUnderlyingType()),
373if (source.Type?.TryGetElementTypesWithAnnotationsIfTupleType(out sourceTypes) == true &&
446Debug.Assert(source.Type is { });
448FieldSymbol? elementField = source.Type.TryGetInlineArrayElementField();
481CheckInlineArrayTypeIsSupported(syntax, source.Type, elementField.Type, diagnostics);
485Debug.Assert(source.Type is not null);
494if (source.Type is ArrayTypeSymbol)
505if (source.Type.IsSpan())
509TryFindImplicitOperatorFromSpan(source.Type.OriginalDefinition, destination.OriginalDefinition),
510source.Type.OriginalDefinition,
517if (source.Type.IsSpan() || source.Type.IsReadOnlySpan())
520if (NeedsSpanCastUp(source.Type, destination))
525TypeSymbol sourceForCastUp = source.Type.IsSpan()
527: source.Type.OriginalDefinition;
538.Construct([((NamedTypeSymbol)source.Type).TypeArgumentsWithAnnotationsNoUseSiteDiagnostics[0]])
Binder\Binder_Expressions.cs (94)
204TypeSymbol resultType = expr.Type;
297var commonType = expr.Type;
369case BoundStackAllocArrayCreation { Type: null } boundStackAlloc:
570TypeSymbol exprType = expr.Type;
1044if (boundArgument.Type?.SpecialType == SpecialType.System_Void)
1054var elementTypeWithAnnotations = TypeWithAnnotations.Create(boundArgument.Type);
1253if ((object)argument.Type != null && argument.Type.IsRestrictedType())
1256Error(diagnostics, ErrorCode.ERR_MethodArgCantBeRefAny, node, argument.Type);
1682type: expression.Type,
2590(object)operand.Type != null &&
2591!operand.Type.IsNullableType() &&
2592!TypeSymbol.Equals(targetType.GetNullableUnderlyingType(), operand.Type, TypeCompareKind.ConsiderEverything2))
2613if ((object)boundOperand.Type != null && boundOperand.Type.IsNullableType())
2692if (left?.Type.IsNullableType() == true || right?.Type.IsNullableType() == true)
2720if (boundOperand.Type?.IsNullableType() == true)
2812SymbolDistinguisher distinguisher1 = new SymbolDistinguisher(this.Compilation, operand.Type, targetType);
2861case BoundKind.UnconvertedConditionalOperator when operand.Type is null:
2862case BoundKind.UnconvertedSwitchExpression when operand.Type is null:
2886Debug.Assert((object)operand.Type != null);
2887SymbolDistinguisher distinguisher = new SymbolDistinguisher(this.Compilation, operand.Type, targetType);
2928Debug.Assert((object)operand.Type != null && !operand.Type.IsNullableType());
2934var underlyingConversion = Conversions.ClassifyBuiltInConversion(operand.Type, underlyingTargetTypeWithAnnotations.Type, isChecked: CheckOverflowAtRuntime, ref discardedUseSiteInfo);
3786Debug.Assert(receiver!.Type is not null);
3788placeholderType = receiver.Type;
4225if ((object)boundExpression.Type == null || !boundExpression.Type.IsErrorType())
4309Debug.Assert(init.Type.IsErrorType());
4719if (constantValue == null || constantValue.IsBad || expression.Type.SpecialType != SpecialType.System_Int32)
4742var type = expression.Type.SpecialType;
5294Debug.Assert(expression.Type is { });
5296var expressionPlaceholder = new BoundCollectionExpressionSpreadExpressionPlaceholder(syntax.Expression, expression.Type);
5309_ = expression.Type.HasInlineArrayAttribute(out int length);
5439else if ((object)argument.Type == null)
5451else if (argument.Type.TypeKind == TypeKind.Delegate)
5453var sourceDelegate = (NamedTypeSymbol)argument.Type;
5457if (ReportDelegateInvokeUseSiteDiagnostic(diagnostics, argument.Type, node: node))
5738Debug.Assert((object)boundLeft.Type != null);
5747type: boundLeft.Type,
6035type: boundMember.Type,
6449({ Type: null } or BoundLiteral or BoundUnconvertedInterpolatedString or BoundBinaryOperator { IsUnconvertedInterpolatedStringAddition: true }) &&
7520var leftType = boundValue.Type;
7528if (TypeSymbol.Equals(boundType.Type, leftType, TypeCompareKind.AllIgnoreOptions))
7560TypeSymbol.Equals(BindNamespaceOrType(id, BindingDiagnosticBag.Discarded).Type, type, TypeCompareKind.AllIgnoreOptions);
7664TypeSymbol leftType = boundLeft.Type;
7702leftType = boundLeft.Type;
7945Error(diagnostics, ErrorCode.WRN_DotOnDefault, node, boundLeft.Type);
8071var leftType = boundLeft.Type;
8209if ((object)boundLeft.Type == null)
8218Error(diagnostics, ErrorCode.ERR_NoSuchMember, name, boundLeft.Type, plainName);
8220else if (WouldUsingSystemFindExtension(boundLeft.Type, plainName))
8222Error(diagnostics, ErrorCode.ERR_NoSuchMemberOrExtensionNeedUsing, name, boundLeft.Type, plainName, "System");
8226Error(diagnostics, ErrorCode.ERR_NoSuchMemberOrExtension, name, boundLeft.Type, plainName);
8516Debug.Assert(left.Type is not null);
8517Debug.Assert(!left.Type.IsDynamic());
8609Debug.Assert(left.Type is not null);
8645firstResult = makeErrorResult(left.Type, memberName, arity, lookupResult, expression, diagnostics);
8671result = makeErrorResult(left.Type, memberName, arity, lookupResult, expression, diagnostics);
8690result = makeErrorResult(left.Type, memberName, arity, lookupResult, expression, diagnostics);
8718TypeSymbol? receiverType = left.Type;
8925TypeSymbol receiverType = receiver.Type;
9096if (receiverOpt is { Type: TypeParameterSymbol { AllowsRefLikeType: true } } &&
9138bool isUsableAsField = eventSymbol.HasAssociatedField && this.IsAccessible(eventSymbol.AssociatedField, ref useSiteInfo, (receiver != null) ? receiver.Type : null);
9378if ((object)expr.Type == null)
9399expr.Type.HasInlineArrayAttribute(out int length) && expr.Type.TryGetPossiblyUnsupportedByLanguageInlineArrayElementField() is FieldSymbol elementField)
9411Debug.Assert(expr.Type.TryGetInlineArrayElementField() is not null);
9431{ Code: (int)ErrorCode.ERR_BadIndexLHS, Arguments: [TypeSymbol type] } && type.Equals(expr.Type, TypeCompareKind.ConsiderEverything))
9558CheckInlineArrayTypeIsSupported(node, expr.Type, elementField.Type, diagnostics);
9609if (TypeSymbol.Equals(convertedIndex.Type, compilation.GetWellKnownType(WellKnownType.System_Index), TypeCompareKind.AllIgnoreOptions))
9657Debug.Assert((object)expr.Type != null);
9660var exprType = expr.Type;
9703var arrayType = (ArrayTypeSymbol)expr.Type;
9750var receiverPlaceholder = new BoundImplicitIndexerReceiverPlaceholder(expr.Syntax, isEquivalentToThisReference: expr.IsEquivalentToThisReference, expr.Type) { WasCompilerGenerated = true };
9914Debug.Assert(expr.Type.IsPointerType());
9915PointerTypeSymbol pointerType = (PointerTypeSymbol)expr.Type;
9961Debug.Assert((object)expr.Type != null);
9967this.LookupMembersWithFallback(lookupResult, expr.Type, WellKnownMemberNames.Indexer, arity: 0, useSiteInfo: ref useSiteInfo, options: lookupOptions);
10288Debug.Assert(receiver.Type is not null);
10295var receiverPlaceholder = new BoundImplicitIndexerReceiverPlaceholder(receiver.Syntax, isEquivalentToThisReference: receiver.IsEquivalentToThisReference, receiver.Type) { WasCompilerGenerated = true };
10304Debug.Assert(indexerOrSliceAccess.Type is not null);
10314indexerOrSliceAccess.Type);
10527Debug.Assert(receiverPlaceholder.Type is not null);
10528if (TryLookupLengthOrCount(syntax, receiverPlaceholder.Type, lookupResult, out var lengthOrCountProperty, diagnostics))
10894if (m.ReduceExtensionMethod(receiver.Type, Compilation) is { } reduced)
11057Debug.Assert(node.ReceiverOpt!.Type is not null); // extensions are only considered on member access
11090var substituted = (MethodSymbol?)extensionMember.GetReducedAndFilteredSymbol(typeArguments, receiver.Type, Compilation, checkFullyInferred: true);
11339var receiverType = receiver.Type;
11348var accessType = access.Type;
11479var receiverType = receiver.Type;
11510var receiverType = receiver.Type;
Binder\Binder_InterpolatedString.cs (17)
219Debug.Assert(unconvertedInterpolatedString.Type?.SpecialType == SpecialType.System_String);
245Debug.Assert(unconvertedInterpolatedString.Parts.All(static part => part.Type is null or { SpecialType: SpecialType.System_String }));
259if (unconvertedInterpolatedString.Type.IsErrorType() || haveErrors || canLowerToStringConcatenation(parts))
264return BindUnconvertedInterpolatedExpressionToFactory(unconvertedInterpolatedString, parts, (NamedTypeSymbol)unconvertedInterpolatedString.Type, factoryMethod: "Format", unconvertedInterpolatedString.Type, diagnostics);
272unconvertedInterpolatedString.Type,
304fillin.Value.Type?.SpecialType != SpecialType.System_String ||
367unconvertedSource.Type,
397if (value.Type?.TypeKind == TypeKind.Dynamic)
433&& unconvertedInterpolatedString.Parts.All(p => p is not BoundStringInsert { Value.Type.TypeKind: TypeKind.Dynamic });
436=> parts.All(p => p is BoundLiteral or BoundStringInsert { Value.Type.SpecialType: SpecialType.System_String, Alignment: null, Format: null });
536expression.Type,
597unconvertedInterpolatedString.Type,
684if (value.Type is not null)
860if (insert.Value.Type is null)
887Debug.Assert(part is BoundLiteral { Type: { SpecialType: SpecialType.System_String }, ConstantValueOpt.IsString: true });
955argumentsBuilder.Add(boundLiteral.Update(ConstantValue.Create(literalText), boundLiteral.Type));
Binder\Binder_Invocation.cs (28)
278else if ((object)argument.Type == null && !argument.HasAnyErrors)
289else if (argument.Type.IsVoidType())
342if ((object)boundExpression.Type != null && boundExpression.Type.IsDynamic())
370else if (boundExpression.Type?.Kind == SymbolKind.FunctionPointerType)
557Debug.Assert(receiver.Type is not null);
558Error(diagnostics, ErrorCode.ERR_CannotDynamicInvokeOnExpression, receiver.Syntax, receiver.Type);
609Debug.Assert((object?)arg.Type != null);
612Error(diagnostics, ErrorCode.ERR_BadDynamicMethodArg, arg.Syntax, arg.Type);
832Debug.Assert(methodGroup.ReceiverOpt != null && (object)methodGroup.ReceiverOpt.Type != null);
834Error(diagnostics, ErrorCode.ERR_BadArgTypeDynamicExtension, syntax, methodGroup.ReceiverOpt.Type, methodGroup.Name);
1061if (!call.HasAnyErrors && call.ReceiverOpt != null && (object)call.ReceiverOpt.Type != null && !call.Method.GetIsNewExtensionMember())
1066if (call.ReceiverOpt.Type.IsRestrictedType() && !call.Method.ContainingType.IsInterface && !TypeSymbol.Equals(call.Method.ContainingType, call.ReceiverOpt.Type, TypeCompareKind.ConsiderEverything2))
1068SymbolDistinguisher distinguisher = new SymbolDistinguisher(compilation, call.ReceiverOpt.Type, call.Method.ContainingType);
1084(object)dynInvoke.Expression.Type != null &&
1085dynInvoke.Expression.Type.IsRestrictedType())
1089Error(diagnostics, ErrorCode.ERR_BadDynamicMethodArg, dynInvoke.Expression.Syntax, dynInvoke.Expression.Type);
1174case BoundUnconvertedSwitchExpression { Type: { } naturalType } switchExpr:
1392if (receiver is BoundValuePlaceholderBase || receiver?.Type is null or { IsReferenceType: true })
1840receiver.Type.IsValueType &&
1903!(d.Arguments is [ParameterSymbol shadowedParameter] && shadowedParameter.Type.Equals(typeOrValue.Data.ValueExpression.Type, TypeCompareKind.AllIgnoreOptions))) // If the type and the name match, we would resolve to the same type rather than a value at the end.
1958var type = expr.Type as NamedTypeSymbol;
1998var methodContainer = (object)receiver != null && (object)receiver.Type != null
1999? receiver.Type
2228var methodContainer = expr.Type ?? this.ContainingType;
2415RoslynDebug.Assert(boundExpression.Type is FunctionPointerTypeSymbol);
2417var 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);
726TypeSymbol leftType = left.Type;
727TypeSymbol rightType = right.Type;
816(object)left.Type != null && left.Type.TypeKind == TypeKind.Delegate)
820var conversion = this.Conversions.ClassifyConversionFromExpression(right, left.Type, isChecked: CheckOverflowAtRuntime, ref discardedUseSiteInfo);
822GenerateImplicitConversionError(diagnostics, right.Syntax, conversion, right, left.Type);
844case (BoundKind.DefaultLiteral, _) when right.Type is TypeParameterSymbol:
845Debug.Assert(!right.Type.IsReferenceType);
846Error(diagnostics, ErrorCode.ERR_AmbigBinaryOpsOnUnconstrainedDefault, node, operatorToken.Text, right.Type);
848case (_, BoundKind.DefaultLiteral) when left.Type is TypeParameterSymbol:
849Debug.Assert(!left.Type.IsReferenceType);
850Error(diagnostics, ErrorCode.ERR_AmbigBinaryOpsOnUnconstrainedDefault, node, operatorToken.Text, left.Type);
869case LookupResultKind.OverloadResolutionFailure when operatorToken.Kind() is SyntaxKind.PlusToken && isReadOnlySpanOfByte(left.Type) && isReadOnlySpanOfByte(right.Type):
936if ((object)left.Type != null && left.Type.SpecialType == SpecialType.System_Boolean &&
937(object)right.Type != null && right.Type.SpecialType == SpecialType.System_Boolean)
939var constantValue = FoldBinaryOperator(node, kind | BinaryOperatorKind.Bool, left, right, left.Type, diagnostics);
943resultKind: LookupResultKind.Viable, left, right, type: left.Type, hasErrors: constantValue != null && constantValue.IsBad);
1055var type = left.Type;
1072if (left.Type is not null)
1074var operandPlaceholder = new BoundValuePlaceholder(left.Syntax, left.Type).MakeCompilerGenerated();
1455(object)operand.Type != null &&
1456(operand.Type.SpecialType == SpecialType.System_UInt64 || isNuint(operand.Type)))
1681return left.Type;
1684return right.Type;
1748BinaryOperatorKind newKind = kind.Operator().WithType(newLeftOperand.Type!.SpecialType);
2292var operandType = operand.Type;
2362var operandPlaceholder = new BoundValuePlaceholder(operand.Syntax, operand.Type).MakeCompilerGenerated();
2481var operandType = operand.Type as PointerTypeSymbol;
2536TypeSymbol operandType = operand.Type;
2615if (receiver.Type.IsReferenceType)
2741if (isOperandNullOrNew || operand.Type?.IsErrorType() == true)
2769type: operand.Type!);
2818var underlyingType = operand.Type.GetEnumUnderlyingType()!;
3177if ((object)operand.Type == null && !operand.IsLiteralNull())
3236if ((object)operand.Type == null)
3247var convertedExpression = BindExpressionForPattern(operand.Type, node.Right, ref hasErrors, isPatternDiagnostics, out var constantValueOpt, out var wasExpression, out _);
3254node.Right, convertedExpression, constantValueOpt ?? ConstantValue.Bad, operand.Type, convertedExpression.Type ?? operand.Type, hasErrors)
3274if (operandHasErrors || IsOperatorErrors(node, operand.Type, typeExpression, diagnostics))
3295operand.Type.IsVoidType())
3325var operandType = operand.Type;
3725if ((object)operand.Type == null)
3787Debug.Assert(operand.Type is null);
3788operandPlaceholder = new BoundValuePlaceholder(operand.Syntax, operand.Type).MakeCompilerGenerated();
3802var operandType = operand.Type;
3835operandPlaceholder = new BoundValuePlaceholder(operand.Syntax, operand.Type).MakeCompilerGenerated();
4014TypeSymbol optLeftType = leftOperand.Type; // "A"
4015TypeSymbol optRightType = rightOperand.Type; // "B"
4190TypeSymbol leftType = leftOperand.Type;
4208if (underlyingRightConversion.Exists && rightOperand.Type?.IsDynamic() != true)
4349TypeSymbol trueType = trueExpr.Type;
4350TypeSymbol falseType = falseExpr.Type;
Binder\Binder_Patterns.cs (20)
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);
578if (convertedExpression.Type is null && constantValueOpt != ConstantValue.Null)
619RoslynDebug.Assert(expression.Type is { });
620ConstantValue match = ExpressionOfTypeMatchesPatternType(Conversions, inputType, expression.Type, ref useSiteInfo, out _, operandConstantValue: null);
652if (expression.Type?.SpecialType == SpecialType.System_String && inputType.IsSpanOrReadOnlySpanChar())
707(conversion.ConversionKind == ConversionKind.NoConversion && convertedExpression.Type?.IsErrorType() == true))
1633var type = value.Type ?? inputType;
Binder\Binder_Query.cs (14)
300Debug.Assert(state.fromExpression.Type is { });
303ImmutableArray.Create(state.fromExpression), state.fromExpression.Type);
738else if (!yExpression.HasAnyErrors && yExpression.Type!.IsVoidType())
740Error(d, ErrorCode.ERR_QueryRangeVariableAssignedBadValue, errorLocation, yExpression.Type!);
741Debug.Assert(yExpression.Type is { });
742yExpression = new BoundBadExpression(yExpression.Syntax, LookupResultKind.Empty, ImmutableArray<Symbol?>.Empty, ImmutableArray.Create(yExpression), yExpression.Type);
803field2Value = new BoundBadExpression(field2Value.Syntax, LookupResultKind.Empty, ImmutableArray<Symbol?>.Empty, ImmutableArray.Create(field2Value), field2Value.Type, true);
823return e.Type ?? CreateErrorType();
928Debug.Assert(receiver.Type is object || ultimateReceiver.Type is null);
929if ((object?)ultimateReceiver.Type == null)
963if (ultimateReceiver.Type.TypeKind == TypeKind.TypeParameter)
966Error(diagnostics, ErrorCode.ERR_BadSKunknown, ultimateReceiver.Syntax, ultimateReceiver.Type, MessageID.IDS_SK_TYVAR.Localize());
974else 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)
407var type = boundExpr.Type;
759Debug.Assert(expr.Type is object);
760Debug.Assert(expr.Type.IsRefLikeType || hasAwait); // pattern dispose lookup is only valid on ref structs or asynchronous usings
1022TypeSymbol initializerType = initializerOpt?.Type;
1232TypeSymbol initializerType = initializerOpt.Type;
1248elementType = ((BoundAddressOfOperator)initializerOpt).Operand.Type;
1322if (initializer.Type.IsVoidType())
1342additionalDiagnostics.Add(ErrorCode.WRN_PatternBadSignature, initializer.Syntax.Location, initializer.Type, "fixed", patternMethodSymbol);
1459var inferredType = op2.Type;
1485if (op1.Type is { } lhsType && !lhsType.IsErrorType())
1533type = op1.Type;
1554Debug.Assert(op1.Type is { });
1587Debug.Assert(leftEscape.Equals(rightEscape) || op1.Type.IsRefLikeOrAllowsRefLikeType());
1607if (!hasErrors && op1.Type.IsRefLikeOrAllowsRefLikeType())
1830Debug.Assert((object)receiver.Type != null);
1831return receiver.Type;
1957this.Conversions.ClassifyConversionFromType(expression.Type, targetType, isChecked: CheckOverflowAtRuntime, ref useSiteInfo);
1989expression.Type,
2449var sourceType = operand.Type;
3057hasErrors |= arg.HasErrors || ((object)arg.Type != null && arg.Type.IsErrorType());
3132if ((object)arg?.Type != null && arg.Type.IsVoidType())
3196&& TypeSymbol.Equals(argument.Type, this.GetCurrentReturnType(out unusedRefKind), TypeCompareKind.ConsiderEverything2))
3199Error(diagnostics, ErrorCode.ERR_BadAsyncReturnExpression, argument.Syntax, returnType, argument.Type);
3533else if (expression.Type?.SpecialType == SpecialType.System_Void)
Binder\ForEachLoopBinder.cs (21)
553(builder.ElementType.IsPointerOrFunctionPointer() && collectionExpr.Type.IsArray()) ||
554(builder.ElementType.IsNullableType() && builder.ElementType.GetMemberTypeArgumentsNoUseSiteDiagnostics().Single().IsErrorType() && collectionExpr.Type.IsArray()));
585(collectionConversionClassification.Kind == ConversionKind.ExplicitReference && collectionExpr.Type.SpecialType == SpecialType.System_String));
654Debug.Assert(collectionType.Equals(collectionExpr.Type, TypeCompareKind.AllIgnoreOptions)); // Should not create an Identity conversion that changes type.
693else if (collectionExpr.Type.SpecialType == SpecialType.System_String && builder.CollectionType.SpecialType == SpecialType.System_Collections_IEnumerable)
711TypeSymbol collectionExprType = collectionExpr.Type;
788TypeSymbol collectionExprType = collectionExpr.Type;
827if (!isAsync && collectionExpr.Type?.HasInlineArrayAttribute(out _) == true && collectionExpr.Type.TryGetPossiblyUnsupportedByLanguageInlineArrayElementField() is FieldSymbol elementField)
858diagnostics.Add(ErrorCode.ERR_InlineArrayForEachNotSupported, collectionExpr.Syntax.GetLocation(), collectionExpr.Type);
881builder.CollectionType = collectionExpr.Type;
898CheckInlineArrayTypeIsSupported(collectionExpr.Syntax, collectionExpr.Type, elementField.Type, diagnostics);
906diagnostics.Add(ErrorCode.ERR_InlineArrayForEachNotSupported, collectionExpr.Syntax.GetLocation(), collectionExpr.Type);
919(originalCollectionExpr.Type?.IsNullableType() == true && originalCollectionExpr.Type.StrippedType().Equals(collectionExpr.Type, TypeCompareKind.AllIgnoreOptions)));
930TypeSymbol collectionExprType = collectionExpr.Type;
970var unwrappedCollectionExprType = unwrappedCollectionExpr.Type;
1049builder.CollectionType = collectionExpr.Type;
1359getEnumeratorInfo = FindForEachPatternMethod(syntax, collectionSyntax, collectionExpr.Type, methodName, lookupResult, warningsOnly: true, diagnostics, isAsync);
1603diagnostics.Add(ErrorCode.WRN_PatternIsAmbiguous, collectionSyntax.Location, collectionExpr.Type, MessageID.IDS_Collection.Localize(),
Binder\Semantics\Conversions\ConversionsBase.cs (13)
104var sourceType = sourceExpression.Type;
289if (TryGetVoidConversion(sourceExpression.Type, destination, out var conversion))
609Debug.Assert(sourceExpression == null || (object)sourceExpression.Type == (object)source);
1033Debug.Assert(sourceExpression == null || (object)sourceExpression.Type == (object)source);
1075var innerConversion = ClassifyImplicitBuiltInConversionFromExpression(innerExpression, innerExpression.Type, destination, ref useSiteInfo);
1353if (constantValue == null || (object)source.Type == null)
1363var specialSource = source.Type.GetSpecialTypeSafe();
1419var sourceType = sourceExpression.Type;
1462source.Type is object &&
1463IsNumericType(source.Type) &&
1923Debug.Assert(sourceExpressionOpt == null || (object)sourceExpressionOpt.Type == sourceType);
1960conversions.ClassifyImplicitExtensionMethodThisArgConversion(s, s.Type, d.Type, ref u, isMethodGroupConversion: false),
3043if (expressionToCheck.Type is TypeSymbol typeToCheck && IsRefLikeOrAllowsRefLikeTypeImplementingVarianceCompatibleInterface(typeToCheck, targetInterfaceType, ref useSiteInfo))
Binder\Semantics\Operators\BinaryOperatorOverloadResolution.cs (27)
67TypeSymbol leftOperatorSourceOpt = left.Type?.StrippedType();
68TypeSymbol rightOperatorSourceOpt = right.Type?.StrippedType();
360var leftType = left.Type;
362var rightType = right.Type;
504bool isExactSubtraction = TypeSymbol.Equals(right.Type?.StrippedType(), underlying, TypeCompareKind.ConsiderEverything2);
608var leftType = left.Type;
614var rightType = right.Type;
683var leftType = left.Type as PointerTypeSymbol;
684var rightType = right.Type as PointerTypeSymbol;
699if ((object)leftType != null || (object)rightType != null || left.Type is FunctionPointerTypeSymbol || right.Type is FunctionPointerTypeSymbol)
721if ((left.Type is TypeParameterSymbol { AllowsRefLikeType: true } && right.IsLiteralNull()) ||
722(right.Type is TypeParameterSymbol { AllowsRefLikeType: true } && left.IsLiteralNull()))
741this.Compilation.BuiltInOperators.GetSimpleBuiltInOperators(kind, operators, skipNativeIntegerOperators: !left.Type.IsNativeIntegerOrNullableThereof() && !right.Type.IsNativeIntegerOrNullableThereof());
756this.Compilation.BuiltInOperators.GetUtf8ConcatenationBuiltInOperator(left.Type, operators);
767BuiltInOperators.IsValidObjectEquality(conversions, left.Type, left.IsLiteralNull(), leftIsDefault: false, right.Type, right.IsLiteralNull(), rightIsDefault: false, ref useSiteInfo) &&
768((object)left.Type == null || (!left.Type.IsDelegateType() && left.Type.SpecialType != SpecialType.System_String && left.Type.SpecialType != SpecialType.System_Delegate)) &&
769((object)right.Type == null || (!right.Type.IsDelegateType() && right.Type.SpecialType != SpecialType.System_String && right.Type.SpecialType != SpecialType.System_Delegate));
779return (operand.Type is TypeParameterSymbol { AllowsRefLikeType: true }) ? Conversion.Boxing : Conversions.ClassifyConversionFromExpression(operand, objectType, isChecked: isChecked, ref useSiteInfo);
Binder\Semantics\OverloadResolution\OverloadResolutionResult.cs (6)
522diagnostics.Add(ErrorCode.ERR_CollectionExpressionMissingAdd, location, receiver.Type);
662diagnostics.Add(ErrorCode.ERR_QueryNoProvider, location, receiverOpt.Type, symbol.Name);
670diagnostics.Add(ErrorCode.ERR_BadAwaitArg, location, receiverOpt.Type);
1132diagnostics.Add(ErrorCode.ERR_CollectionExpressionMissingAdd, location, receiver.Type);
1371=> argument is BoundLiteral { Type.SpecialType: SpecialType.System_String } &&
1410diagnostics.Add(ErrorCode.ERR_QueryMultipleProviders, location, receiver.Type, name);
CodeGen\EmitExpression.cs (50)
52if ((object)expression.Type == null ||
53(expression.Type.SpecialType != SpecialType.System_Decimal &&
54!expression.Type.IsNullableType()))
56EmitConstantExpression(expression.Type, constantValue, used, expression.Syntax);
374EmitDefaultValue(node.Type, used, node.Syntax);
409var receiverType = receiver.Type;
522Debug.Assert(receiver.Type.IsNullableType());
680EmitSymbolToken(expression.Operand.Type, expression.Operand.Syntax);
737Debug.Assert(argument.Type.IsDynamic() || argument is BoundFieldAccess { FieldSymbol.RefKind: not RefKind.None }, "passing args byref should not clone them into temps");
792EmitLoadIndirect(expression.Type, expression.Syntax);
801var meth = expression.MethodOpt ?? receiver.Type.DelegateInvokeMethod();
1014if (((ArrayTypeSymbol)arrayAccess.Expression.Type).IsSZArray)
1101_builder.EmitArrayElementLoad(_module.Translate((ArrayTypeSymbol)arrayAccess.Expression.Type), arrayAccess.Expression.Syntax, _diagnostics.DiagnosticBag);
1132if (!field.IsVolatile && !field.IsStatic && fieldAccess.ReceiverOpt.Type.IsVerifierValue() && field.RefKind == RefKind.None)
1171if (fieldType.IsValueType && (object)fieldType == (object)receiver.Type)
1227if (receiver == null || !receiver.Type.IsValueType)
1238EmitSymbolToken(receiver.Type, receiver.Syntax);
1267if (!receiver.Type.IsVerifierValue())
1319var type = expr.Type;
1510if (receiver.Type.IsTypeParameter())
1515Debug.Assert(receiver.Type.IsVerifierReference(), "this is not a reference");
1645Debug.Assert(TypeSymbol.Equals(method.ContainingType, receiver.Type, TypeCompareKind.ConsiderEverything2));
1674EmitSymbolToken(receiver.Type, receiver.Syntax);
1831var receiverType = receiver.Type;
1917var receiverType = receiver.Type;
1977Debug.Assert(receiver.Type.IsVerifierReference());
1988Debug.Assert(receiver.Type.IsVerifierReference());
2008EmitSymbolToken(receiver.Type, receiver.Syntax);
2023var receiverType = receiver.Type;
2086var receiverType = receiver.Type;
2598var rightType = right.Type;
2654if (left.Kind == BoundKind.ArrayAccess && left.Type.TypeKind == TypeKind.TypeParameter && !left.Type.IsValueType)
2678EmitSymbolToken(target.Type, target.Syntax);
3050assignmentOperator.Left.Type,
3097var arrayType = (ArrayTypeSymbol)array.Type;
3111EmitIndirectStore(expression.Type, expression.Syntax);
3116EmitIndirectStore(expression.Type, expression.Syntax);
3122EmitIndirectStore(expression.Type, expression.Syntax);
3134EmitIndirectStore(expression.Type, expression.Syntax);
3139EmitIndirectStore(expression.Type, expression.Syntax);
3385Debug.Assert((object)operand.Type != null);
3386if (!operand.Type.IsVerifierReference())
3389EmitBox(operand.Type, operand.Syntax);
3412var operandType = operand.Type;
3933if (!(expr.Type.IsInterfaceType() || expr.Type.IsDelegateType()))
3935return expr.Type;
3980return expr.Type;
4051temp = AllocateTemp(ptrInvocation.InvokedExpression.Type, ptrInvocation.Syntax);
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;
915_module.Translate(expressionOpt.Type, boundReturnStatement.Syntax, _diagnostics.DiagnosticBag);
1127if (!exceptionSourceOpt.Type.IsVerifierReference())
1129Debug.Assert(exceptionSourceOpt.Type.IsTypeParameter()); // only expecting type parameters
1131EmitSymbolToken(exceptionSourceOpt.Type, exceptionSourceOpt.Syntax);
1158Debug.Assert(!left.ReceiverOpt.Type.IsTypeParameter());
1169var temp = AllocateTemp(exceptionSource.Type, exceptionSource.Syntax);
1232Debug.Assert((object)dispatch.Expression.Type != null);
1233Debug.Assert(dispatch.Expression.Type.IsValidV6SwitchGoverningType() || dispatch.Expression.Type.IsSpanOrReadOnlySpanChar());
1236Debug.Assert(!dispatch.Expression.Type.IsNullableType());
1255Debug.Assert((object)expression.Type != null &&
1256(expression.Type.IsValidV6SwitchGoverningType() || expression.Type.IsSpanOrReadOnlySpanChar()));
1301temp = AllocateTemp(expression.Type, expression.Syntax);
1308expression.Type.SpecialType == SpecialType.System_String || expression.Type.IsSpanOrReadOnlySpanChar());
1311if (expression.Type.SpecialType == SpecialType.System_String || expression.Type.IsSpanOrReadOnlySpanChar())
1315this.EmitStringSwitchJumpTable(switchCaseLabels, fallThroughLabel, key, expression.Syntax, expression.Type);
1319this.EmitLengthBasedStringSwitchJumpTable(lengthBasedSwitchStringJumpTableOpt, fallThroughLabel, key, expression.Syntax, expression.Type);
1324_builder.EmitIntegerSwitchJumpTable(switchCaseLabels, fallThroughLabel, key, expression.Type.EnumUnderlyingTypeOrSelf().PrimitiveTypeCode);
Compilation\CSharpSemanticModel.cs (18)
2059type = boundExpr.Type;
2178convertedType = highestBoundExpr.Type;
2184convertedType = highestBoundExpr.Type;
2273static (TypeSymbol, NullabilityInfo) getTypeAndNullability(BoundExpression expr) => (expr.Type, expr.TopLevelNullability);
3385else if (expr.Type.IsDelegateType())
3694var thisParam = GetThisParameter(boundNode.Type, containingType, containingMember, out resultKind);
3818symbols = OneOrMany.Create<Symbol>(new SynthesizedIntrinsicOperatorSymbol(unaryOperator.Operand.Type.StrippedType(),
3841TypeSymbol opType = increment.Operand.Type.StrippedType();
3868((binaryOperator.Left.IsLiteralNull() && binaryOperator.Right.Type.IsNullableType()) ||
3869(binaryOperator.Right.IsLiteralNull() && binaryOperator.Left.Type.IsNullableType())) &&
3883binaryOperator.Left.Type,
3884binaryOperator.Right.Type,
4094TypeSymbol type = boundNode.Type;
4618if (node.SearchExtensions && receiver.Type is { } receiverType)
4760receiverType = call.ReceiverOpt.Type;
4764receiverType = call.Arguments[0].Type;
4794MethodSymbol reduced = method.ReduceExtensionMethod(receiver.Type, Compilation);
4809MethodSymbol reduced = method.ReduceExtensionMethod(receiverOpt.Type, Compilation);
FlowAnalysis\NullableWalker.cs (62)
411expr.Type?.Equals(result.RValueType.Type, TypeCompareKind.AllIgnoreOptions) == true ? result.RValueType.Type : expr.Type);
547Debug.Assert(AreCloseEnough(placeholder.Type, result.RValueType.Type));
2077receiver.Type is object;
2088TypeSymbol? nodeType = node.Type;
2124var operandType = operand.Type;
2142TypeSymbol.Equals(conv.Type, conv.Operand.Type, TypeCompareKind.IgnoreNullableModifiersForReferenceTypes):
3689Debug.Assert(AreCloseEnough(resultType.Type, node.Type));
4498SetAnalyzedNullability(node.ImplicitReceiverOpt, new VisitResult(node.ImplicitReceiverOpt.Type, NullableAnnotation.NotAnnotated, NullableFlowState.NotNull));
4556SetResultType(node, TypeWithState.Create(node.Type, NullableFlowState.NotNull));
4561var resultType = TypeWithState.Create(node.Type, NullableFlowState.NotNull);
4608Debug.Assert(node.Type is object);
4609if (IsEmptyStructType(node.Type))
4614return GetOrCreatePlaceholderSlot(node, TypeWithAnnotations.Create(node.Type, NullableAnnotation.NotAnnotated));
4932Debug.Assert(!node.Expression.Type!.IsValueType);
4946TypeSymbol.Equals(node.Indices[0].Type, compilation.GetWellKnownType(WellKnownType.System_Range), TypeCompareKind.ConsiderEverything2))
5301if (expr.Type is null)
5311TypeWithAnnotations.Create(expr.Type),
5325Debug.Assert(binary.Type!.SpecialType == SpecialType.System_Boolean);
5495var receiverType = conditional.Receiver.Type!;
5524if (slot > 0 && PossiblyNullableType(operand.Type))
5594LearnFromNullTest(slot, expressionWithoutConversion.Type, ref state, markDependentSlotsNotNull: false);
5708node.Type?.ContainsErrorType() == true ||
5709TypeSymbol.Equals(targetType.Type.GetNullableUnderlyingType(), node.Type, TypeCompareKind.AllIgnoreOptions));
5715targetType = TypeWithAnnotations.Create(node.Type, NullableAnnotation.NotAnnotated);
6004if (slot > 0 && receiver.Type?.IsNullableType() == true)
6005slot = GetNullableOfTValueSlot(receiver.Type, slot, out _);
6049TypeSymbol? refResultType = node.Type?.SetUnknownNullabilityForReferenceTypes();
6115resultType ??= node.Type?.SetUnknownNullabilityForReferenceTypes();
7114TrackAnalyzedNullabilityThroughConversionGroup(TypeWithState.Create(argument.Type, result.RValueType.State), argument as BoundConversion, argumentNoConversion);
7232completion(TypeWithAnnotations.Create(argument.Type));
8286if (value.Type is null || value.Type.IsDynamic() || value.ConstantValueOpt != null)
8296value.Type.HasInlineArrayAttribute(out _) == true &&
8297value.Type.TryGetInlineArrayElementField() is not null)
8437if (TypeAllowsConditionalState(targetType.Type) && TypeAllowsConditionalState(operand.Type))
8585var tupleOpt = (NamedTypeSymbol?)node.Type;
9779case BoundExpression arg when arg.Type is { TypeKind: TypeKind.Delegate }:
9893Debug.Assert(arg.Type is not null);
9894TypeSymbol argType = arg.Type;
9912Debug.Assert(arg.Type is not null);
9913TypeSymbol argType = arg.Type;
10082var rvalueResult = TypeWithState.Create(node.Type, NullableFlowState.NotNull);
10083var lvalueResult = TypeWithAnnotations.Create(node.Type, NullableAnnotation.NotAnnotated);
10581if (expr.Type is NamedTypeSymbol { IsTupleType: true } tupleType)
10766SetResultType(node.Expression, TypeWithState.Create(node.Expression.Type, ResultType.State));
11107if (collectionExpression.Type!.SpecialType == SpecialType.System_Collections_IEnumerable)
11110targetTypeWithAnnotations = TypeWithAnnotations.Create(collectionExpression.Type);
11112else if (ForEachLoopBinder.IsIEnumerableT(collectionExpression.Type.OriginalDefinition, isAsync, compilation))
11376var type = TypeWithAnnotations.Create(node.Type);
11772SetResultType(node, TypeWithState.Create(node.Type, node.Type?.CanContainNull() != false && node.ConstantValueOpt?.IsNull == true ? NullableFlowState.MaybeDefault : NullableFlowState.NotNull));
11949SetResultType(expression, TypeWithState.Create(expression.Type, default));
11983Debug.Assert(receiverOpt.Type is null || AreCloseEnough(receiverOpt.Type, resultTypeSymbol));
12071SetResultType(node, TypeWithState.Create(node.Type, NullableFlowState.NotNull));
12104Debug.Assert(node.Type is null || node.Type.IsErrorType() || node.Type.IsRefLikeType);
12120SetResultType(node, TypeWithState.Create(node.Type, NullableFlowState.NotNull));
12124Debug.Assert(node.Type is not null);
12125var type = VisitArrayInitialization(node.Type, initialization, node.HasErrors);
Generated\BoundNodes.xml.Generated.cs (187)
488if (!TypeSymbol.Equals(type, this.Type, TypeCompareKind.ConsiderEverything))
518if (receiver != this.Receiver || localScopeDepth != this.LocalScopeDepth || !TypeSymbol.Equals(type, this.Type, TypeCompareKind.ConsiderEverything))
550public new TypeSymbol Type => base.Type!;
587public new TypeSymbol Type => base.Type!;
616public new TypeSymbol? Type => base.Type;
651public new TypeSymbol Type => base.Type!;
688public new TypeSymbol Type => base.Type!;
724public new TypeSymbol Type => base.Type!;
761public new TypeSymbol Type => base.Type!;
797public new TypeSymbol Type => base.Type!;
832public new TypeSymbol Type => base.Type!;
867public new TypeSymbol Type => base.Type!;
902public new TypeSymbol Type => base.Type!;
940if (refKind != this.RefKind || !TypeSymbol.Equals(type, this.Type, TypeCompareKind.ConsiderEverything))
968if (expression != this.Expression || !TypeSymbol.Equals(type, this.Type, TypeCompareKind.ConsiderEverything))
1001if (resultKind != this.ResultKind || symbols != this.Symbols || childBoundNodes != this.ChildBoundNodes || !TypeSymbol.Equals(type, this.Type, TypeCompareKind.ConsiderEverything))
1084public new TypeSymbol Type => base.Type!;
1122public new TypeSymbol Type => base.Type!;
1162public new TypeSymbol? Type => base.Type;
1199public new TypeSymbol Type => base.Type!;
1244public new TypeSymbol Type => base.Type!;
1284public new TypeSymbol Type => base.Type!;
1315public new TypeSymbol? Type => base.Type;
1358public new TypeSymbol Type => base.Type!;
1388public new TypeSymbol Type => base.Type!;
1423public new TypeSymbol Type => base.Type!;
1460public new TypeSymbol Type => base.Type!;
1494public new TypeSymbol Type => base.Type!;
1525public new TypeSymbol Type => base.Type!;
1556public new TypeSymbol Type => base.Type!;
1588public new TypeSymbol Type => base.Type!;
1620public new TypeSymbol Type => base.Type!;
1654public new TypeSymbol Type => base.Type!;
1710public new TypeSymbol Type => base.Type!;
1797public new TypeSymbol Type => base.Type!;
1837public new TypeSymbol Type => base.Type!;
1872public new TypeSymbol Type => base.Type!;
1910public new TypeSymbol Type => base.Type!;
1954if (leftOperand != this.LeftOperand || rightOperand != this.RightOperand || !TypeSymbol.Equals(type, this.Type, TypeCompareKind.ConsiderEverything))
1981public new TypeSymbol? Type => base.Type;
2023public new TypeSymbol Type => base.Type!;
2061public new TypeSymbol Type => base.Type!;
2091public new TypeSymbol? Type => base.Type;
2121public new TypeSymbol Type => base.Type!;
2187public new TypeSymbol Type => base.Type!;
2227public new TypeSymbol Type => base.Type!;
2314public new TypeSymbol Type => base.Type!;
2356public new TypeSymbol Type => base.Type!;
2399public new TypeSymbol Type => base.Type!;
2436public new TypeSymbol Type => base.Type!;
2471public new TypeSymbol Type => base.Type!;
2509public new TypeSymbol Type => base.Type!;
2544public new TypeSymbol Type => base.Type!;
2579public new TypeSymbol Type => base.Type!;
2614public new TypeSymbol Type => base.Type!;
2649public new TypeSymbol Type => base.Type!;
2688public new TypeSymbol Type => base.Type!;
2730public new TypeSymbol Type => base.Type!;
2773public new TypeSymbol Type => base.Type!;
2804public new TypeSymbol? Type => base.Type;
2827public new TypeSymbol Type => base.Type!;
2861public new TypeSymbol Type => base.Type!;
2897public new TypeSymbol Type => base.Type!;
2931public new TypeSymbol Type => base.Type!;
2968public new TypeSymbol Type => base.Type!;
3006public new TypeSymbol Type => base.Type!;
3043public new TypeSymbol Type => base.Type!;
3072public new TypeSymbol? Type => base.Type;
3108public new TypeSymbol Type => base.Type!;
4318if (constantValueOpt != this.ConstantValueOpt || !TypeSymbol.Equals(type, this.Type, TypeCompareKind.ConsiderEverything))
4350public new TypeSymbol Type => base.Type!;
4386public new TypeSymbol Type => base.Type!;
4421public new TypeSymbol Type => base.Type!;
4456public new TypeSymbol Type => base.Type!;
4485public new TypeSymbol? Type => base.Type;
4530public new TypeSymbol Type => base.Type!;
4577public new TypeSymbol Type => base.Type!;
4610public new TypeSymbol Type => base.Type!;
4651public new TypeSymbol Type => base.Type!;
4796if (!Symbols.SymbolEqualityComparer.ConsiderEverything.Equals(label, this.Label) || !TypeSymbol.Equals(type, this.Type, TypeCompareKind.ConsiderEverything))
4957if (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))
4982public new TypeSymbol Type => base.Type!;
5729public new TypeSymbol? Type => base.Type;
5752if (expression != this.Expression || !TypeSymbol.Equals(type, this.Type, TypeCompareKind.ConsiderEverything))
5778public new TypeSymbol Type => base.Type!;
5814public new TypeSymbol Type => base.Type!;
5851public new TypeSymbol Type => base.Type!;
5906public new TypeSymbol Type => base.Type!;
5940public new TypeSymbol Type => base.Type!;
5977public new TypeSymbol Type => base.Type!;
6020public new TypeSymbol Type => base.Type!;
6052public new TypeSymbol Type => base.Type!;
6165public new TypeSymbol Type => base.Type!;
6212public new TypeSymbol Type => base.Type!;
6254public new TypeSymbol Type => base.Type!;
6295public new TypeSymbol? Type => base.Type;
6335public new TypeSymbol Type => base.Type!;
6413public new TypeSymbol? Type => base.Type;
6450public new TypeSymbol Type => base.Type!;
6493if (!TypeSymbol.Equals(type, this.Type, TypeCompareKind.ConsiderEverything))
6571public new TypeSymbol? Type => base.Type;
6608if (sourceTuple != this.SourceTuple || wasTargetTyped != this.WasTargetTyped || arguments != this.Arguments || argumentNamesOpt != this.ArgumentNamesOpt || inferredNamesOpt != this.InferredNamesOpt || !TypeSymbol.Equals(type, this.Type, TypeCompareKind.ConsiderEverything))
6707public new TypeSymbol Type => base.Type!;
6762public new TypeSymbol Type => base.Type!;
6815public new TypeSymbol Type => base.Type!;
6882public new TypeSymbol Type => base.Type!;
6921public new TypeSymbol Type => base.Type!;
6957public new TypeSymbol Type => base.Type!;
6990public new TypeSymbol Type => base.Type!;
7032public new TypeSymbol Type => base.Type!;
7095public new TypeSymbol Type => base.Type!;
7129public new TypeSymbol Type => base.Type!;
7160public new TypeSymbol? Type => base.Type;
7215if (!TypeSymbol.Equals(elementType, this.ElementType, TypeCompareKind.ConsiderEverything) || count != this.Count || initializerOpt != this.InitializerOpt || !TypeSymbol.Equals(type, this.Type, TypeCompareKind.ConsiderEverything))
7237public new TypeSymbol Type => base.Type!;
7271public new TypeSymbol Type => base.Type!;
7316public new TypeSymbol Type => base.Type!;
7350public new TypeSymbol Type => base.Type!;
7387public new TypeSymbol Type => base.Type!;
7431public new TypeSymbol Type => base.Type!;
7485public new TypeSymbol Type => base.Type!;
7528public new TypeSymbol Type => base.Type!;
7567public new TypeSymbol Type => base.Type!;
7609public new TypeSymbol? Type => base.Type;
7653public new TypeSymbol? Type => base.Type;
7691public new TypeSymbol Type => base.Type!;
7754public new TypeSymbol Type => base.Type!;
7805if (parts != this.Parts || constantValueOpt != this.ConstantValueOpt || !TypeSymbol.Equals(type, this.Type, TypeCompareKind.ConsiderEverything))
7833if (!interpolationData.Equals(this.InterpolationData) || parts != this.Parts || constantValueOpt != this.ConstantValueOpt || !TypeSymbol.Equals(type, this.Type, TypeCompareKind.ConsiderEverything))
7861if (!TypeSymbol.Equals(type, this.Type, TypeCompareKind.ConsiderEverything))
7891public new TypeSymbol Type => base.Type!;
7923public new TypeSymbol? Type => base.Type;
7976if (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))
8576public new TypeSymbol? Type => base.Type;
8613if (expression != this.Expression || !TypeSymbol.Equals(type, this.Type, TypeCompareKind.ConsiderEverything))
8635public new TypeSymbol? Type => base.Type;
8708public new TypeSymbol? Type => base.Type;
8806public new TypeSymbol? Type => base.Type;
8839public new TypeSymbol Type => base.Type!;
10862TypeSymbol? type = this.VisitType(node.Type);
10868TypeSymbol? type = this.VisitType(node.Type);
10929TypeSymbol? type = this.VisitType(node.Type);
10935TypeSymbol? type = this.VisitType(node.Type);
10942TypeSymbol? type = this.VisitType(node.Type);
11135TypeSymbol? type = this.VisitType(node.Type);
11551TypeSymbol? type = this.VisitType(node.Type);
11625TypeSymbol? type = this.VisitType(node.Type);
11654TypeSymbol? type = this.VisitType(node.Type);
11802TypeSymbol? type = this.VisitType(node.Type);
11939TypeSymbol? type = this.VisitType(node.Type);
11962TypeSymbol? type = this.VisitType(node.Type);
12073TypeSymbol? type = this.VisitType(node.Type);
12184TypeSymbol? type = this.VisitType(node.Type);
12190TypeSymbol? type = this.VisitType(node.Type);
12195TypeSymbol? type = this.VisitType(node.Type);
12218TypeSymbol? type = this.VisitType(node.Type);
12343TypeSymbol? type = this.VisitType(node.Type);
12457updatedNode = node.Update(receiver, node.LocalScopeDepth, node.Type);
12623updatedNode = node.Update(expression, node.Type);
12641updatedNode = node.Update(node.ResultKind, node.Symbols, childBoundNodes, node.Type);
13036updatedNode = node.Update(leftOperand, rightOperand, node.Type);
13828updatedNode = node.Update(expression, switchArms, reachabilityDecisionDag, node.DefaultLabel, node.ReportedNotExhaustive, node.Type);
13923updatedNode = node.Update(expression, node.Type);
14285updatedNode = node.Update(sourceTuple, node.WasTargetTyped, arguments, node.ArgumentNamesOpt, node.InferredNamesOpt, node.Type);
14568updatedNode = node.Update(elementType, count, initializerOpt, node.Type);
14806updatedNode = node.Update(parts, node.ConstantValueOpt, node.Type);
14823updatedNode = node.Update(node.InterpolationData, parts, node.ConstantValueOpt, node.Type);
14885updatedNode = node.Update(expression, pattern, node.IsNegated, reachabilityDecisionDag, node.WhenTrueLabel, node.WhenFalseLabel, node.Type);
15034updatedNode = node.Update(expression, node.Type);
15176new TreeDumperNode("type", node.Type, null),
15185new TreeDumperNode("type", node.Type, null),
15274new TreeDumperNode("type", node.Type, null),
15282new TreeDumperNode("type", node.Type, null),
15292new TreeDumperNode("type", node.Type, null),
15562new TreeDumperNode("type", node.Type, null),
16124new TreeDumperNode("type", node.Type, null),
16226new TreeDumperNode("type", node.Type, null),
16262new TreeDumperNode("type", node.Type, null),
16448new TreeDumperNode("type", node.Type, null),
16665new TreeDumperNode("type", node.Type, null),
16699new TreeDumperNode("type", node.Type, null),
16865new TreeDumperNode("type", node.Type, null),
17032new TreeDumperNode("type", node.Type, null),
17042new TreeDumperNode("type", node.Type, null),
17049new TreeDumperNode("type", node.Type, null),
17081new TreeDumperNode("type", node.Type, null),
17235new TreeDumperNode("type", node.Type, null),
Lowering\ClosureConversion\ExpressionLambdaRewriter.cs (28)
118if (!node.Type.Equals(result.Type, TypeCompareKind.IgnoreNullableModifiersForReferenceTypes))
298if (!TypeSymbol.Equals(index.Type, _int32Type, TypeCompareKind.ConsiderEverything2))
300index = ConvertIndex(index, arg.Type, _int32Type);
316if (!TypeSymbol.Equals(index.Type, _int32Type, TypeCompareKind.ConsiderEverything2))
318index = ConvertIndex(index, arg.Type, _int32Type);
367if (node.Operand.IsLiteralNull() && (object)node.Operand.Type == null)
493if ((object)left.Type == null && left.IsLiteralNull())
495left = _bound.Default(right.Type);
497if ((object)right.Type == null && right.IsLiteralNull())
499right = _bound.Default(left.Type);
510var promotedType = PromotedType(enumOperand.Type.StrippedType().GetEnumUnderlyingType());
563return Convert(loweredOperand, operand.Type, promotedType, isChecked, false);
700var operandType = node.Operand.Type;
709? Convert(Visit(node.Operand), node.Operand.Type, method.Parameters[0].Type, node.Checked, false)
725if (node.Operand.Type.IsNullableType())
727return Convert(Visit(node.Operand), node.Operand.Type, node.Type, node.Checked, node.ExplicitCastInCode);
734var e1 = Convert(Visit(node.Operand), node.Operand.Type, intermediate, node.Checked, false);
740return Convert(Visit(node.Operand), node.Operand.Type, node.Type, node.Checked, node.ExplicitCastInCode);
760receiver = requiresInstanceReceiver ? nullObject : receiver.Type.IsReferenceType ? receiver : _bound.Convert(_objectType, receiver);
798var d = node.Argument.Type as NamedTypeSymbol;
819if ((object)operand.Type == null && operand.ConstantValueOpt != null && operand.ConstantValueOpt.IsNull)
880TypeSymbol lambdaParamType = node.LeftPlaceholder.Type;
881return _bound.StaticCall(WellKnownMember.System_Linq_Expressions_Expression__Coalesce_Lambda, left, right, MakeConversionLambda(leftConversion, lambdaParamType, node.LeftConversion.Type));
1117if (node.ReceiverOpt?.Type.IsTypeParameter() == true &&
1118!node.ReceiverOpt.Type.IsReferenceType)
1188var promotedType = PromotedType(arg.Type.StrippedType().GetEnumUnderlyingType());
1190loweredArg = Convert(loweredArg, arg.Type, promotedType, isChecked, false);
1207_bound.Typeof(node.Type, _bound.WellKnownType(WellKnownType.System_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\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_BinaryOperator.cs (54)
339Debug.Assert(loweredLeft.Type is { });
340Debug.Assert(loweredRight.Type is { });
342return MakeUnaryOperator(UnaryOperatorKind.BoolLogicalNegation, syntax, method: null, constrainedToTypeOpt: null, loweredRight, loweredRight.Type);
345return MakeUnaryOperator(UnaryOperatorKind.BoolLogicalNegation, syntax, method: null, constrainedToTypeOpt: null, loweredLeft, loweredLeft.Type);
353Debug.Assert(loweredLeft.Type is { });
354Debug.Assert(loweredRight.Type is { });
356return MakeUnaryOperator(UnaryOperatorKind.BoolLogicalNegation, syntax, method: null, constrainedToTypeOpt: null, loweredRight, loweredRight.Type);
359return MakeUnaryOperator(UnaryOperatorKind.BoolLogicalNegation, syntax, method: null, constrainedToTypeOpt: null, loweredLeft, loweredLeft.Type);
367Debug.Assert(loweredLeft.Type is { });
368Debug.Assert(loweredRight.Type is { });
370return MakeUnaryOperator(UnaryOperatorKind.BoolLogicalNegation, syntax, method: null, constrainedToTypeOpt: null, loweredRight, loweredRight.Type);
373return MakeUnaryOperator(UnaryOperatorKind.BoolLogicalNegation, syntax, method: null, constrainedToTypeOpt: null, loweredLeft, loweredLeft.Type);
575Debug.Assert(loweredLeft.Type is { });
576whenNullOpt = RewriteLiftedBinaryOperator(syntax, operatorKind, _factory.Default(loweredLeft.Type), loweredRight, type, method, constrainedToTypeOpt);
586type: result.Type!
896Debug.Assert(expression.Type is { });
900if (expression.Type.IsNullableType())
906UnsafeGetNullableMethod(syntax, expression.Type, SpecialMember.System_Nullable_T_GetValueOrDefault));
919Debug.Assert(expression.Type is { });
923if (expression.Type.IsNullableType())
933Debug.Assert(expression.Type is { });
938UnsafeGetNullableMethod(syntax, expression.Type, SpecialMember.System_Nullable_T_get_HasValue));
1621Debug.Assert(TypeSymbol.Equals(conditional.Type, conditional.Consequence.Type, TypeCompareKind.ConsiderEverything2));
1622Debug.Assert(TypeSymbol.Equals(conditional.Type, conditional.Alternative.Type, TypeCompareKind.ConsiderEverything2));
1695Debug.Assert(alwaysNull.Type is { });
1696BoundExpression nullBool = new BoundDefaultExpression(syntax, alwaysNull.Type);
1708rewrittenType: alwaysNull.Type,
1735rewrittenType: alwaysNull.Type,
1737Debug.Assert(conditionalExpression.Type is { });
1743type: conditionalExpression.Type);
1797rewrittenType: newNullBool.Type!,
1804type: conditionalExpression.Type!);
1884rewrittenType: alternative.Type!,
1892type: conditionalExpression.Type!);
1990return conditionalAccess.Update(conditionalAccess.Receiver, conditionalAccess.HasValueMethodOpt, whenNotNull, whenNull, conditionalAccess.Id, conditionalAccess.ForceCopyOfNullableValueType, whenNotNull.Type!);
2046Debug.Assert(loweredLeft.Type is { SpecialType: SpecialType.System_Decimal });
2047Debug.Assert(loweredRight.Type is { SpecialType: SpecialType.System_Decimal });
2080TypeSymbol? exprType = rewrittenExpr.Type;
2143Debug.Assert(loweredRight.Type is { });
2144TypeSymbol rightType = loweredRight.Type;
2210Debug.Assert(loweredLeft.Type is { });
2211TypeSymbol leftType = loweredLeft.Type;
2215Debug.Assert(loweredRight.Type is { });
2216TypeSymbol rightType = loweredRight.Type;
2266Debug.Assert(loweredLeft.Type is { TypeKind: TypeKind.Pointer });
2267loweredRight = MakeSizeOfMultiplication(loweredRight, (PointerTypeSymbol)loweredLeft.Type, kind.IsChecked());
2271Debug.Assert(loweredRight.Type is { TypeKind: TypeKind.Pointer });
2272loweredLeft = MakeSizeOfMultiplication(loweredLeft, (PointerTypeSymbol)loweredRight.Type, kind.IsChecked());
2311Debug.Assert(sizeOfExpression.Type is { SpecialType: SpecialType.System_Int32 });
2321Debug.Assert(numericOperand.Type is { });
2322var numericSpecialType = numericOperand.Type.SpecialType;
2458Debug.Assert(loweredLeft.Type is { TypeKind: TypeKind.Pointer });
2459Debug.Assert(loweredRight.Type is { TypeKind: TypeKind.Pointer });
2462PointerTypeSymbol pointerType = (PointerTypeSymbol)loweredLeft.Type;
Lowering\LocalRewriter\LocalRewriter_CollectionExpression.cs (26)
176Debug.Assert(singleSpread.Expression.Type is not null);
178if (!ShouldUseIEnumerableBulkAddMethod(singleSpread.Expression.Type, toListOfElementType.Parameters[0].Type, singleSpread.EnumeratorInfoOpt?.GetEnumeratorInfo.Method))
224Elements: [BoundCollectionExpressionSpreadElement { Expression: { Type: NamedTypeSymbol spreadType } expr }],
316Debug.Assert(list.Type is { });
317Debug.Assert(list.Type.OriginalDefinition.Equals(_compilation.GetWellKnownType(WellKnownType.System_Collections_Generic_List_T), TypeCompareKind.AllIgnoreOptions));
319var listToArray = ((MethodSymbol)_factory.WellKnownMember(WellKnownMember.System_Collections_Generic_List_T__ToArray)).AsMember((NamedTypeSymbol)list.Type);
328Debug.Assert(TypeSymbol.Equals(array.Type, spanConstructor.Parameters[0].Type, TypeCompareKind.AllIgnoreOptions));
665var spreadTypeOriginalDefinition = spreadExpression.Type!.OriginalDefinition;
671return _factory.Call(rewrittenSpreadExpression, listToArrayMethod.AsMember((NamedTypeSymbol)spreadExpression.Type!));
681&& ShouldUseIEnumerableBulkAddMethod(spreadExpression.Type!, linqToArrayMethod.Parameters[0].Type, spreadElement.EnumeratorInfoOpt?.GetEnumeratorInfo.Method))
688&& TryGetSpanConversion(spreadExpression.Type, writableOnly: false, out var asSpanMethod))
690var spanType = CallAsSpanMethod(spreadExpression, asSpanMethod).Type!.OriginalDefinition;
695return _factory.Call(rewrittenSpreadExpression, toArrayMethod.AsMember((NamedTypeSymbol)rewrittenSpreadExpression.Type!));
789Debug.Assert(arrayTemp.Type is ArrayTypeSymbol);
793var elementType = ((ArrayTypeSymbol)arrayTemp.Type).ElementType;
903var type = expression.Type;
970if (spreadOperandAsSpan.Type!.OriginalDefinition.Equals(this._compilation.GetWellKnownType(wellKnownSpanType))
1009var spreadLength = _factory.Call(spreadOperandAsSpan, getLengthMethod.AsMember((NamedTypeSymbol)spreadOperandAsSpan.Type!));
1010var targetSlice = _factory.Call(spanTemp, spanSliceMethod.AsMember((NamedTypeSymbol)spanTemp.Type!), indexTemp, spreadLength);
1011sideEffects.Add(_factory.Call(spreadOperandAsSpan, copyToMethod.AsMember((NamedTypeSymbol)spreadOperandAsSpan.Type!), targetSlice));
1125Debug.Assert(spanTemp.Type is NamedTypeSymbol);
1129var elementType = ((NamedTypeSymbol)spanTemp.Type).TypeArgumentsWithAnnotationsNoUseSiteDiagnostics[0].Type;
1178Debug.Assert(rewrittenSpreadOperand.Type is not null);
1183if (!ShouldUseIEnumerableBulkAddMethod(rewrittenSpreadOperand.Type, addRangeMethod.Parameters[0].Type, spreadElement.EnumeratorInfoOpt?.GetEnumeratorInfo.Method))
1318_factory.Binary(BinaryOperatorKind.Addition, sum.Type!, sum, value);
1353if (convertedExpression.Operand.Type is ArrayTypeSymbol arrayType)
Lowering\LocalRewriter\LocalRewriter_CompoundAssignmentOperator.cs (27)
24Debug.Assert(TypeSymbol.Equals(node.Right.Type, node.Operator.RightType, TypeCompareKind.ConsiderEverything2));
94Debug.Assert(rewrittenAssignment.Type is { });
97var condition = _factory.Conditional(isEvent, invokeEventAccessor.ToExpression(), rewrittenAssignment, rewrittenAssignment.Type);
99rewrittenAssignment = new BoundSequence(node.Syntax, eventTemps.ToImmutableAndFree(), sequence.ToImmutableAndFree(), condition, condition.Type!);
106Debug.Assert(rewrittenAssignment.Type is { });
114rewrittenAssignment.Type);
157Debug.Assert(node.Left.Type is { });
169Debug.Assert(TypeSymbol.Equals(transformedLHS.Type, node.Left.Type, TypeCompareKind.AllIgnoreOptions));
215Debug.Assert(rewrittenReceiver.Type is { });
216var variableRepresentsLocation = rewrittenReceiver.Type.IsValueType || rewrittenReceiver.Type.Kind == SymbolKind.TypeParameter;
426indexerAccess.Argument.Type,
433throw ExceptionUtilities.UnexpectedValue(indexerAccess.Argument.Type);
454if (isDynamicAssignment || !IsInvariantArray(arrayAccess.Expression.Type))
482Debug.Assert(receiver is { Type: { } });
487else if (!receiver.Type.IsReferenceType)
492Debug.Assert(receiver.Type.IsReferenceType);
496Debug.Assert(rewrittenReceiver.Type is { });
497if (rewrittenReceiver.Type.IsTypeParameter())
635Debug.Assert(implicitIndexerAccess.Argument.Type!.Equals(_compilation.GetWellKnownType(WellKnownType.System_Index))
636|| implicitIndexerAccess.Argument.Type!.Equals(_compilation.GetWellKnownType(WellKnownType.System_Range)));
665if (isDynamicAssignment || !IsInvariantArray(arrayAccess.Expression.Type))
846var type = expression.Type;
862var type = expression.Type;
918Debug.Assert(expression.Type is { });
919if (expression.Type.IsNullableType())
Lowering\LocalRewriter\LocalRewriter_Conversion.cs (65)
82Debug.Assert(result.Type!.Equals(toType, TypeCompareKind.IgnoreDynamicAndTupleNames | TypeCompareKind.IgnoreNullableModifiersForReferenceTypes));
94Debug.Assert(node.Type is not null);
95Debug.Assert(_compilation.IsReadOnlySpanType(node.Type));
96var byteType = ((NamedTypeSymbol)node.Type).TypeArgumentsWithAnnotationsNoUseSiteDiagnostics.Single().Type;
111result = BadExpression(node.Syntax, node.Type, ImmutableArray<BoundExpression>.Empty);
115result = new BoundObjectCreationExpression(node.Syntax, ctor.AsMember((NamedTypeSymbol)node.Type), utf8Bytes, _factory.Literal(0), _factory.Literal(length));
224Debug.Assert(rewrittenNode.Type is { });
225var type = rewrittenNode.Type;
271Debug.Assert(result.Type is { } rt && rt.Equals(rewrittenType, TypeCompareKind.AllIgnoreOptions));
289type: result.Type);
312@checked = @checked && NeedsCheckedConversionInExpressionTree(rewrittenOperand.Type, rewrittenType, explicitCastInCode);
318Debug.Assert(rewrittenOperand.Type is { });
331if (_inExpressionLambda || !rewrittenOperand.Type.Equals(rewrittenType, TypeCompareKind.ConsiderEverything))
426Debug.Assert(rewrittenOperand.Type is { });
432if (rewrittenType.SpecialType == SpecialType.System_Decimal || rewrittenOperand.Type.SpecialType == SpecialType.System_Decimal)
434return RewriteDecimalConversion(syntax, rewrittenOperand, rewrittenOperand.Type, rewrittenType, @checked, conversion.Kind.IsImplicitConversion(), constantValueOpt);
441Debug.Assert(rewrittenOperand.Type is { });
444Debug.Assert(rewrittenOperand.Type.Equals(rewrittenType, TypeCompareKind.IgnoreDynamicAndTupleNames | TypeCompareKind.IgnoreNullableModifiersForReferenceTypes));
487Debug.Assert(rewrittenOperand.Type is { });
497Debug.Assert(rewrittenOperand.Type.IsEnumType());
498var underlyingTypeFrom = rewrittenOperand.Type.GetEnumUnderlyingType()!;
502else if (rewrittenOperand.Type.SpecialType == SpecialType.System_Decimal)
510var rewrittenNode = RewriteDecimalConversion(syntax, rewrittenOperand, rewrittenOperand.Type, underlyingTypeTo, @checked, isImplicit: false, constantValueOpt: constantValueOpt);
555(symbolOpt.IsAbstract || symbolOpt.IsVirtual) ? mg.ReceiverOpt?.Type : null,
594Debug.Assert(rewrittenOperand.Type is not null);
609createSpan = createSpan.Construct(rewrittenOperand.Type, spanType.TypeArgumentsWithAnnotationsNoUseSiteDiagnostics.Single().Type);
610_ = rewrittenOperand.Type.HasInlineArrayAttribute(out int length);
618var sourceType = rewrittenOperand.Type;
811Debug.Assert(rewrittenOperand.Type is { });
813Conversion conversion = compilation.Conversions.ClassifyConversionFromType(rewrittenOperand.Type, rewrittenType, isChecked: @checked, ref useSiteInfo);
819rewrittenOperand.Type.SpecialType != SpecialType.System_Decimal &&
820rewrittenOperand.Type.SpecialType != SpecialType.System_DateTime)
826rewrittenOperand.Type,
872if (!TypeSymbol.Equals(rewrittenOperand.Type, conversion.BestUserDefinedConversionAnalysis.FromType, TypeCompareKind.ConsiderEverything2))
882if (!TypeSymbol.Equals(rewrittenOperand.Type, conversion.Method.GetParameterType(0), TypeCompareKind.ConsiderEverything2))
895Debug.Assert(rewrittenOperand.Type is { });
896if (rewrittenOperand.Type.IsNullableType() &&
897conversion.Method.GetParameterType(0).Equals(rewrittenOperand.Type.GetNullableUnderlyingType(), TypeCompareKind.AllIgnoreOptions) &&
901userDefinedConversionRewrittenType = ((NamedTypeSymbol)rewrittenOperand.Type.OriginalDefinition).Construct(userDefinedConversionRewrittenType);
911if (!TypeSymbol.Equals(userDefined.Type, conversion.BestUserDefinedConversionAnalysis.ToType, TypeCompareKind.ConsiderEverything2))
920if (!TypeSymbol.Equals(userDefined.Type, rewrittenType, TypeCompareKind.ConsiderEverything2))
952Debug.Assert(rewrittenOperand.Type is { });
956var tupleTypeSymbol = (NamedTypeSymbol)rewrittenOperand.Type;
993Debug.Assert(expression.Type is { });
994if (!expression.Type.IsNullableType())
1006when convertedArgument.Type!.Equals(expression.Type.StrippedType(), TypeCompareKind.AllIgnoreOptions):
1011when underlying.Length == 1 && underlying[0].Kind == ConversionKind.ImplicitTuple && !convertedArgument.Type!.IsNullableType():
1046TypeSymbol? rewrittenOperandType = rewrittenOperand.Type;
1096Debug.Assert(rewrittenOperand.Type is { });
1097TypeSymbol rewrittenOperandType = rewrittenOperand.Type;
1310Debug.Assert(TypeSymbol.Equals(conditional.Type, conditional.Consequence.Type, TypeCompareKind.ConsiderEverything2));
1311Debug.Assert(TypeSymbol.Equals(conditional.Type, conditional.Alternative.Type, TypeCompareKind.ConsiderEverything2));
1343Debug.Assert(rewrittenOperand.Type is { });
1344if (rewrittenOperand.Type.IsNullableType())
1347if (parameterType.Equals(rewrittenOperand.Type.GetNullableUnderlyingType(), TypeCompareKind.AllIgnoreOptions) &&
1361if ((rewrittenOperand.Type.IsArray()) && _compilation.IsReadOnlySpanType(rewrittenType))
1373Debug.Assert(TypeSymbol.Equals(result.Type, rewrittenType, TypeCompareKind.ConsiderEverything2));
1396Debug.Assert(rewrittenOperand.Type is { });
1399Conversion conv = TryMakeConversion(syntax, conversion, rewrittenOperand.Type, rewrittenType, @checked: @checked);
1411Debug.Assert(rewrittenOperand.Type.IsNullableType());
1488Debug.Assert(rewrittenOperand.Type is { });
1491TypeSymbol source = rewrittenOperand.Type;
1714Debug.Assert(operand.Type is { });
1715return RewriteDecimalConversionCore(syntax, operand, operand.Type, toType, isImplicit, constantValueOpt);
Lowering\LocalRewriter\LocalRewriter_IndexerAccess.cs (37)
119Debug.Assert(oldNode.Type is not null);
120Debug.Assert(oldNode.Type.Equals(type, TypeCompareKind.ConsiderEverything));
180Debug.Assert(call.Type is not null);
194call.Type);
203Debug.Assert(node.Expression.Type is object);
204Debug.Assert(node.Argument.Type is object);
219_ = node.Expression.Type.HasInlineArrayAttribute(out int length);
221if (node.Argument.Type.SpecialType == SpecialType.System_Int32)
229if (TypeSymbol.Equals(node.Argument.Type, _compilation.GetWellKnownType(WellKnownType.System_Index), TypeCompareKind.AllIgnoreOptions))
241Debug.Assert(TypeSymbol.Equals(node.Argument.Type, _compilation.GetWellKnownType(WellKnownType.System_Range), TypeCompareKind.AllIgnoreOptions));
323Debug.Assert(node.Expression.Type is object);
335return createSpan.Construct(node.Expression.Type, node.Expression.Type.TryGetInlineArrayElementField()!.Type);
340Debug.Assert(node.Expression.Type is object);
341Debug.Assert(index.Type?.SpecialType == SpecialType.System_Int32);
343var intType = (NamedTypeSymbol)index.Type;
362elementRef = elementRef.Construct(node.Expression.Type, node.Expression.Type.TryGetInlineArrayElementField()!.Type);
381elementRef = elementRef.Construct(node.Expression.Type, node.Expression.Type.TryGetInlineArrayElementField()!.Type);
436node.Argument.Type,
445node.Argument.Type,
483node.Argument.Type,
499Debug.Assert(receiver.Type is { });
505receiver.Type.IsReferenceType ? RefKind.None : RefKind.Ref);
563Debug.Assert(integerArgument.Type!.SpecialType == SpecialType.System_Int32);
659Debug.Assert(loweredExpr.Type!.SpecialType == SpecialType.System_Int32);
670Debug.Assert(loweredExpr.Type!.SpecialType == SpecialType.System_Int32);
677loweredExpr.Type,
710unloweredExpr.Type,
718Debug.Assert(hatExpression.Operand is { Type: { SpecialType: SpecialType.System_Int32 } });
722else if (unloweredExpr is BoundConversion { Operand: { Type: { SpecialType: SpecialType.System_Int32 } } operand })
731arguments[0] is { Type.SpecialType: SpecialType.System_Int32, ConstantValueOpt.Value: int _ and >= 0 } index &&
732arguments[1] is { Type.SpecialType: SpecialType.System_Boolean, ConstantValueOpt.Value: bool fromEnd })
775node.Argument.Type,
801Debug.Assert(receiver.Type is { });
807receiver.Type.IsReferenceType ? RefKind.None : RefKind.Ref);
Lowering\LocalRewriter\LocalRewriter_NullCoalescingAssignmentOperator.cs (16)
16Debug.Assert(node.Type is { });
20Debug.Assert(node.LeftOperand.Type is { });
24Debug.Assert(transformedLHS.Type is { });
41Debug.Assert(TypeSymbol.Equals(transformedLHS.Type, node.LeftOperand.Type, TypeCompareKind.AllIgnoreOptions));
45var leftPlaceholder = new BoundValuePlaceholder(lhsRead.Syntax, lhsRead.Type);
46BoundExpression conditionalExpression = MakeNullCoalescingOperator(syntax, lhsRead, assignment, leftPlaceholder: leftPlaceholder, leftConversion: leftPlaceholder, BoundNullCoalescingOperatorResultKind.LeftType, node.LeftOperand.Type);
47Debug.Assert(conditionalExpression.Type is { });
56conditionalExpression.Type);
63Debug.Assert(node.LeftOperand.Type.IsNullableType());
72leftOperand.Type,
80leftOperand.Type,
112Debug.Assert(transformedLHS.Type.GetNullableUnderlyingType().Equals(tmp.Type.StrippedType(), TypeCompareKind.AllIgnoreOptions));
115Debug.Assert(TypeSymbol.Equals(transformedLHS.Type, node.LeftOperand.Type, TypeCompareKind.AllIgnoreOptions));
120MakeConversionNode(tmp, transformedLHS.Type, @checked: false, markAsChecked: true),
Lowering\LocalRewriter\LocalRewriter_NullCoalescingOperator.cs (18)
35Debug.Assert(rewrittenRight.Type is { });
36Debug.Assert(rewrittenRight.Type.Equals(rewrittenResultType, TypeCompareKind.IgnoreDynamicAndTupleNames | TypeCompareKind.IgnoreNullableModifiersForReferenceTypes));
42Debug.Assert(rewrittenLeft.Type is { });
59var isUnconstrainedTypeParameter = rewrittenLeft.Type is { IsReferenceType: false, IsValueType: false };
90Debug.Assert(rewrittenLeft.Type is { });
91if (rewrittenLeft.Type.IsReferenceType &&
110if (whenNullOpt.Type.IsNullableType())
115if (whenNullOpt.IsDefaultValue() && whenNullOpt.Type.SpecialType != SpecialType.System_Decimal)
133if (rewrittenLeft.Type.IsNullableType() &&
134rewrittenRight.Type.Equals(rewrittenLeft.Type.GetNullableUnderlyingType(), TypeCompareKind.AllIgnoreOptions))
140TryGetNullableMethod(rewrittenLeft.Syntax, rewrittenLeft.Type, SpecialMember.System_Nullable_T_GetValueOrDefault, out MethodSymbol? getValueOrDefault, isOptional: true))
147TryGetNullableMethod(rewrittenLeft.Syntax, rewrittenLeft.Type, SpecialMember.System_Nullable_T_GetValueOrDefaultDefaultValue, out MethodSymbol? getValueOrDefaultDefaultValue, isOptional: true))
167Debug.Assert(convertedLeft.HasErrors || convertedLeft.Type!.Equals(rewrittenResultType, TypeCompareKind.IgnoreDynamicAndTupleNames | TypeCompareKind.IgnoreNullableModifiersForReferenceTypes));
180Debug.Assert(conditionalExpression.Type!.Equals(rewrittenResultType, TypeCompareKind.IgnoreDynamicAndTupleNames | TypeCompareKind.IgnoreNullableModifiersForReferenceTypes));
238Debug.Assert(rewrittenLeft.Type is { });
242TypeSymbol rewrittenLeftType = rewrittenLeft.Type;
250var conversionTakesNullableType = leftPlaceholder?.Type?.IsNullableType() == true;
Lowering\LocalRewriter\LocalRewriter_ObjectOrCollectionInitializerExpression.cs (8)
400Debug.Assert(assignment.Type.IsDynamic() || TypeSymbol.Equals(rewrittenAccess.Type, assignment.Type, TypeCompareKind.AllIgnoreOptions));
454Debug.Assert(TypeSymbol.Equals(rangeArgument.Type, _compilation.GetWellKnownType(WellKnownType.System_Range), TypeCompareKind.ConsiderEverything));
472Debug.Assert(TypeSymbol.Equals(rewrittenAccess.Type, assignment.Type, TypeCompareKind.AllIgnoreOptions));
505Debug.Assert(TypeSymbol.Equals(rewrittenAccess.Type, assignment.Type, TypeCompareKind.AllIgnoreOptions));
517if (TypeSymbol.Equals(implicitIndexer.Argument.Type, _compilation.GetWellKnownType(WellKnownType.System_Index), TypeCompareKind.ConsiderEverything))
539Debug.Assert(TypeSymbol.Equals(rewrittenAccess.Type, assignment.Type, TypeCompareKind.AllIgnoreOptions));
700Debug.Assert(_compilation.Conversions.ClassifyConversionFromType(rewrittenReceiver.Type, memberSymbol.ContainingType, isChecked: false, ref discardedUseSiteInfo).IsImplicit ||
701_compilation.Conversions.HasImplicitConversionToOrImplementsVarianceCompatibleInterface(rewrittenReceiver.Type, memberSymbol.ContainingType, ref discardedUseSiteInfo, out _));
Lowering\LocalRewriter\LocalRewriter_StringConcat.cs (18)
222not (BoundCall or BoundConversion { ConversionKind: ConversionKind.Boxing, Type.SpecialType: SpecialType.System_Object, Operand.Type.SpecialType: SpecialType.System_Char })
286if (argument is BoundConversion { ConversionKind: ConversionKind.Boxing, Type.SpecialType: SpecialType.System_Object, Operand: { Type.SpecialType: SpecialType.System_Char } operand })
307else if (argument is BoundNullCoalescingOperator { LeftOperand: { Type.SpecialType: SpecialType.System_String } left, RightOperand: BoundLiteral { ConstantValueOpt: { IsString: true, RopeValue.IsEmpty: true } } })
397if (call is { Arguments: [], ReceiverOpt.Type: NamedTypeSymbol { SpecialType: SpecialType.System_Char } charType, Method: { Name: "ToString" } method }
474Debug.Assert(arg.Type is not null);
476if (arg.Type.SpecialType == SpecialType.System_Char)
505Debug.Assert(arg.HasAnyErrors || arg.Type.SpecialType == SpecialType.System_String);
605Debug.Assert(expr.Type is not null);
608if (expr.Type.IsStringType())
620if (expr.Type.IsValueType && !expr.Type.IsTypeParameter())
622var type = (NamedTypeSymbol)expr.Type;
643expr.Type.SpecialType.CanOptimizeBehavior() &&
659bool callWithoutCopy = expr.Type.IsReferenceType ||
661(structToStringMethod == null && !expr.Type.IsTypeParameter()) ||
665if (expr.Type.IsValueType)
669expr = new BoundPassByCopy(syntax, expr, expr.Type);
701new BoundConditionalReceiver(syntax, currentConditionalAccessID, expr.Type),
Lowering\LocalRewriter\LocalRewriter_StringInterpolation.cs (8)
145Debug.Assert(node.Type is { SpecialType: SpecialType.System_String }); // if target-converted, we should not get here.
149return LowerPartsToString(data, node.Parts, node.Syntax, node.Type);
183_factory.Binary(BinaryOperatorKind.StringConcatenation, node.Type, result, part);
194Debug.Assert(result.Type is not null);
195Debug.Assert(result.Type.SpecialType == SpecialType.System_String || result.Type.IsErrorType());
196var placeholder = new BoundValuePlaceholder(result.Syntax, result.Type);
197result = new BoundNullCoalescingOperator(result.Syntax, result, _factory.StringLiteral(""), leftPlaceholder: placeholder, leftConversion: placeholder, BoundNullCoalescingOperatorResultKind.LeftType, @checked: false, result.Type) { WasCompilerGenerated = true };
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_UnaryOperator.cs (23)
132var underlyingType = loweredOperand.Type.GetEnumUnderlyingType();
276Debug.Assert(result.Type is { });
285type: result.Type
328Debug.Assert(TypeSymbol.Equals(conditional.Type, conditional.Consequence.Type, TypeCompareKind.ConsiderEverything2));
329Debug.Assert(TypeSymbol.Equals(conditional.Type, conditional.Alternative.Type, TypeCompareKind.ConsiderEverything2));
439TypeSymbol? operandType = transformedLHS.Type; //type of the variable being incremented
512Debug.Assert(boundTemp.Type is not null);
527type: boundTemp.Type);
540Debug.Assert(boundTemp.Type is not null);
543Debug.Assert(tempValue.Type is { });
552tempValue.Type);
566type: boundTemp.Type);
772Debug.Assert(binaryOperand.Type is { TypeKind: TypeKind.Pointer });
773Debug.Assert(boundOne.Type is { SpecialType: SpecialType.System_Int32 });
774return MakeBinaryOperator(node.Syntax, binaryOperatorKind, binaryOperand, boundOne, binaryOperand.Type, method: null, constrainedToTypeOpt: null);
826Debug.Assert(operand.Type is { SpecialType: SpecialType.System_Decimal });
833Debug.Assert(operand.Type is { } && operand.Type.IsNullableType() && operand.Type.GetNullableUnderlyingType().SpecialType == SpecialType.System_Decimal);
837MethodSymbol getValueOrDefault = UnsafeGetNullableMethod(syntax, operand.Type, SpecialMember.System_Nullable_T_GetValueOrDefault);
838MethodSymbol ctor = UnsafeGetNullableMethod(syntax, operand.Type, SpecialMember.System_Nullable_T__ctor);
849BoundExpression alternative = new BoundDefaultExpression(syntax, operand.Type);
852return RewriteConditionalOperator(syntax, condition, consequence, alternative, ConstantValue.NotAvailable, operand.Type, isRef: false);
Lowering\SpillSequenceSpiller.cs (19)
45: base(SpillSequenceBuilderKind, syntax, value?.Type)
174new TreeDumperNode("type", this.Type, null)
337if (refKind != RefKind.None || expression.Type?.IsRefLikeOrAllowsRefLikeType() == true)
380if (refKind != RefKind.None || expression.Type.IsReferenceType)
497if (expression.Type.IsVoidType() || sideEffectsOnly)
1034Debug.Assert(refKind == RefKind.None || !receiver.Type.IsReferenceType);
1043var receiverType = receiver.Type;
1074if (!receiver.Type.IsReferenceType && LocalRewriter.CanBePassedByReference(receiver))
1076result = receiver.Type.IsReadOnly ? RefKind.In : RefKind.Ref;
1147Debug.Assert(condition.Type.SpecialType == SpecialType.System_Boolean);
1150var tmp = _F.SynthesizedLocal(condition.Type, kind: SynthesizedLocalKind.Spill, syntax: _F.Syntax);
1197type: node.Type));
1254_F.ObjectEqual(_F.Local(tmp), _F.Null(left.Type)),
1286if (receiver.Type.IsReferenceType || receiver.Type.IsValueType || receiverRefKind == RefKind.None)
1306var clone = _F.SynthesizedLocal(receiver.Type, _F.Syntax, refKind: RefKind.None, kind: SynthesizedLocalKind.Spill);
1310var isNotClass = _F.IsNotNullReference(_F.Default(receiver.Type));
1478return UpdateExpression(builder, node.Update(operand, node.Type));
1522return UpdateExpression(builder, node.Update(expression, node.Type));
Lowering\SyntheticBoundNodeFactory.cs (54)
267Debug.Assert(receiverOpt is null || receiverOpt.Type is { } &&
268receiverOpt.Type.GetMembers(propertySym.Name).OfType<PropertySymbol>().Single() == propertySym);
279Debug.Assert(!(receiverOpt is { Type: ArrayTypeSymbol { IsSZArray: true } } &&
439Debug.Assert(left.Type is { } && right.Type is { } &&
440(left.Type.Equals(right.Type, TypeCompareKind.AllIgnoreOptions) ||
442right.Type.IsErrorType() || left.Type.IsErrorType()));
444var assignment = new BoundAssignmentOperator(syntax, left, right, isRef, left.Type, hasErrors) { WasCompilerGenerated = wasCompilerGenerated };
569var conversion = Compilation.Conversions.ClassifyConversionFromType(expression.Type, CurrentFunction.ReturnType, isChecked: false, ref useSiteInfo);
657Conversion c = Compilation.Conversions.ClassifyBuiltInConversion(operand.Type, type, isChecked: false, ref discardedUseSiteInfo);
663Debug.Assert(left.Type?.SpecialType == CodeAnalysis.SpecialType.System_Boolean);
664Debug.Assert(right.Type?.SpecialType == CodeAnalysis.SpecialType.System_Boolean);
670Debug.Assert(left.Type?.SpecialType == CodeAnalysis.SpecialType.System_Boolean);
671Debug.Assert(right.Type?.SpecialType == CodeAnalysis.SpecialType.System_Boolean);
785switch (input.Type)
794throw ExceptionUtilities.UnexpectedValue(input.Type);
919Debug.Assert(valueTypeReceiver.Type is { });
920Debug.Assert(TypeSymbol.Equals(valueTypeReceiver.Type, referenceTypeReceiver.Type, TypeCompareKind.ConsiderEverything2));
921return new BoundComplexConditionalReceiver(Syntax, valueTypeReceiver, referenceTypeReceiver, valueTypeReceiver.Type) { WasCompilerGenerated = true };
926Debug.Assert(left.Type!.Equals(right.Type, TypeCompareKind.IgnoreCustomModifiersAndArraySizesAndLowerBounds | TypeCompareKind.IgnoreNullableModifiersForReferenceTypes) || left.Type.IsErrorType());
927Debug.Assert(left.Type.IsReferenceType);
929return new BoundNullCoalescingOperator(Syntax, left, right, leftPlaceholder: null, leftConversion: null, BoundNullCoalescingOperatorResultKind.LeftType, @checked: false, left.Type) { WasCompilerGenerated = true };
1037Debug.Assert(result.Type is { });
1038var resultType = type ?? result.Type;
1044Debug.Assert(result.Type is { });
1048: new BoundSequence(Syntax, locals, sideEffects, result, result.Type) { WasCompilerGenerated = true };
1053Debug.Assert(result.Type is { });
1054return new BoundSpillSequence(Syntax, locals, sideEffects, result, result.Type) { WasCompilerGenerated = true };
1083Debug.Assert(ex.Type is { SpecialType: CodeAnalysis.SpecialType.System_Int32 });
1178Debug.Assert(array.Type is { TypeKind: TypeKind.Array });
1184Debug.Assert(array.Type is { TypeKind: TypeKind.Array });
1185int rank = ((ArrayTypeSymbol)array.Type).Rank;
1197Debug.Assert(array.Type is { TypeKind: TypeKind.Array });
1198return new BoundArrayAccess(Syntax, array, indices, ((ArrayTypeSymbol)array.Type).ElementType);
1484if (TypeSymbol.Equals(type, arg.Type, TypeCompareKind.ConsiderEverything2))
1498arg.Type is TypeParameterSymbol { AllowsRefLikeType: true } && type.IsObjectType())
1514if (conversion.Method is { } && !TypeSymbol.Equals(conversion.Method.Parameters[0].Type, arg.Type, TypeCompareKind.ConsiderEverything2))
1524Debug.Assert(arg.Type is { });
1526arg.Type.IsNullableType() &&
1527arg.Type.GetNullableUnderlyingType().Equals(type, TypeCompareKind.AllIgnoreOptions))
1531return this.Call(arg, this.SpecialMethod(CodeAnalysis.SpecialMember.System_Nullable_T_get_Value).AsMember((NamedTypeSymbol)arg.Type));
1620return new BoundCatchBlock(Syntax, ImmutableArray<LocalSymbol>.Empty, source, source.Type, exceptionFilterPrologueOpt: null, exceptionFilterOpt: null, body: block, isSynthesizedAsyncCatchAll: false);
1640Debug.Assert(expression is { Type: { SpecialType: CodeAnalysis.SpecialType.System_Boolean } });
1641return new BoundUnaryOperator(expression.Syntax, UnaryOperatorKind.BoolLogicalNegation, expression, null, null, constrainedToTypeOpt: null, LookupResultKind.Viable, expression.Type);
1661Debug.Assert(argument.Type is { });
1694var type = argument.Type;
1764TypeSymbol exprType = rewrittenExpr.Type;
1818LocalRewriter.UnsafeGetNullableMethod(syntax, expression.Type, CodeAnalysis.SpecialMember.System_Nullable_T_get_HasValue, Compilation, Diagnostics));
1882return conditionalAccess.Update(conditionalAccess.Receiver, conditionalAccess.HasValueMethodOpt, whenNotNull, whenNull, conditionalAccess.Id, conditionalAccess.ForceCopyOfNullableValueType, whenNotNull.Type);