Binder\Binder.WithQueryLambdaParametersBinder.cs (1)
99var result = BindMemberOfType(node, node, name, 0, invoked: false, indexed: false, receiver, default(SeparatedSyntaxList<TypeSyntax>), default(ImmutableArray<TypeWithAnnotations>), lookupResult, BoundMethodGroupFlags.None, diagnostics);
Binder\Binder_Constraints.cs (10)
122ArrayBuilder<TypeWithAnnotations>? constraintTypes = null;
250constraintTypes = ArrayBuilder<TypeWithAnnotations>.GetInstance();
257var type = BindTypeOrConstraintKeyword(typeSyntax, diagnostics, out ConstraintContextualKeyword keyword);
348return (TypeParameterConstraintClause.Create(constraints, constraintTypes?.ToImmutableAndFree() ?? ImmutableArray<TypeWithAnnotations>.Empty), syntaxBuilder);
413var constraintTypeBuilder = ArrayBuilder<TypeWithAnnotations>.GetInstance();
418var constraintType = constraintTypes[i];
449TypeWithAnnotations constraintType,
486TypeWithAnnotations type,
488ArrayBuilder<TypeWithAnnotations> constraintTypes,
554static bool isValidConstraintType(TypeParameterSymbol typeParameter, TypeConstraintSyntax syntax, TypeWithAnnotations typeWithAnnotations, bool performOnlyCycleSafeValidation, BindingDiagnosticBag diagnostics)
Binder\Binder_Deconstruct.cs (12)
374return pending.SetInferredTypeWithAnnotations(TypeWithAnnotations.Create(type), this, diagnostics);
380return pending.SetInferredTypeWithAnnotations(TypeWithAnnotations.Create(type));
476var typesWithAnnotationsBuilder = ArrayBuilder<TypeWithAnnotations>.GetInstance(leftLength);
518typesWithAnnotationsBuilder.Add(TypeWithAnnotations.Create(mergedType));
550var typesWithAnnotationsBuilder = ArrayBuilder<TypeWithAnnotations>.GetInstance(count);
569typesWithAnnotationsBuilder.Add(TypeWithAnnotations.Create(value.Type));
655typeArgumentsWithAnnotations: default(ImmutableArray<TypeWithAnnotations>),
752var declType = BindVariableTypeWithAnnotations(component.Designation, diagnostics, component.Type.SkipScoped(out _).SkipRef(), ref isConst, out isVar, out alias);
803TypeWithAnnotations declTypeWithAnnotations,
854TypeWithAnnotations declTypeWithAnnotations)
866TypeWithAnnotations declTypeWithAnnotations,
950var fieldType = field.GetFieldType(this.FieldsBeingBound);
Binder\Binder_Expressions.cs (53)
373var type = new PointerTypeSymbol(TypeWithAnnotations.Create(boundStackAlloc.ElementType));
938var declType = BindVariableTypeWithAnnotations(node.Designation, diagnostics, node.Type.SkipScoped(out _).SkipRef(), ref isConst, out isVar, out alias);
946private BoundExpression BindDeclarationVariablesForErrorRecovery(TypeWithAnnotations declTypeWithAnnotations, VariableDesignationSyntax node, CSharpSyntaxNode syntax, BindingDiagnosticBag diagnostics)
948declTypeWithAnnotations = declTypeWithAnnotations.HasType ? declTypeWithAnnotations : TypeWithAnnotations.Create(CreateErrorType("var"));
987subExpressions.SelectAsArray(e => TypeWithAnnotations.Create(e.Type)),
1022var elementTypesWithAnnotations = ArrayBuilder<TypeWithAnnotations>.GetInstance(arguments.Count);
1054var elementTypeWithAnnotations = TypeWithAnnotations.Create(boundArgument.Type);
1239TypeWithAnnotations typeWithAnnotations = BindType(node.Type, diagnostics);
1380TypeWithAnnotations typeWithAnnotations = typeofBinder.BindType(typeSyntax, diagnostics, out alias);
1404private void CheckDisallowedAttributeDependentType(TypeWithAnnotations typeArgument, NameSyntax attributeName, BindingDiagnosticBag diagnostics)
1433TypeWithAnnotations typeWithAnnotations = this.BindType(typeSyntax, diagnostics, out alias);
1572TypeWithAnnotations typeWithAnnotations = this.BindType(node.Type, diagnostics, out AliasSymbol alias);
1629default(ImmutableArray<TypeWithAnnotations>);
2587TypeWithAnnotations targetTypeWithAnnotations = this.BindType(node.Type, diagnostics);
2748private BoundExpression BindCastCore(ExpressionSyntax node, BoundExpression operand, TypeWithAnnotations targetTypeWithAnnotations, bool wasCompilerGenerated, BindingDiagnosticBag diagnostics)
2836var targetElementTypesWithAnnotations = default(ImmutableArray<TypeWithAnnotations>);
2896ImmutableArray<TypeWithAnnotations> targetElementTypesWithAnnotations)
2927private BoundExpression BindExplicitNullableCastFromNonNullable(ExpressionSyntax node, BoundExpression operand, TypeWithAnnotations targetTypeWithAnnotations, BindingDiagnosticBag diagnostics)
2935TypeWithAnnotations underlyingTargetTypeWithAnnotations = targetTypeWithAnnotations.Type.GetNullableUnderlyingTypeWithAnnotations();
3178var declType = BindVariableTypeWithAnnotations(designation, diagnostics, typeSyntax, ref isConst, out isVar, out alias);
3227var declType = BindVariableTypeWithAnnotations(declarationExpression, diagnostics, typeSyntax, ref isConst, out isVar, out alias);
3491TypeWithAnnotations parameterTypeWithAnnotations,
3591TypeWithAnnotations paramsElementTypeOpt = result.ParamsElementTypeOpt;
3648void reportUnsafeIfNeeded(MemberResolutionResult<TMember> methodResult, BindingDiagnosticBag diagnostics, BoundExpression argument, TypeWithAnnotations parameterTypeWithAnnotations)
4149var arrayType = ArrayTypeSymbol.CreateCSharpArray(Compilation.Assembly, TypeWithAnnotations.Create(bestType), rank);
4178type: GetStackAllocType(node, TypeWithAnnotations.Create(bestType), diagnostics, out bool hasErrors),
4524var elementType = arrayType.ElementTypeWithAnnotations;
4609private TypeSymbol GetStackAllocType(SyntaxNode node, TypeWithAnnotations elementTypeWithAnnotations, BindingDiagnosticBag diagnostics, out bool hasErrors)
5109typeArgumentsWithAnnotations: ImmutableArray<TypeWithAnnotations>.Empty,
5204var typeWithAnnotations = BindType(node.Type, diagnostics);
6716var finalApplicableCandidates = GetCandidatesPassingFinalValidation(node, overloadResolutionResult, receiverOpt: null, default(ImmutableArray<TypeWithAnnotations>), isExtensionMethodGroup: false, diagnostics);
7604ImmutableArray<TypeWithAnnotations> typeArgumentsWithAnnotations = rightHasTypeArguments ?
7606default(ImmutableArray<TypeWithAnnotations>);
7621var typeArgument = typeArgumentsWithAnnotations[i];
7649/// <see cref="MakeQueryInvocation(CSharpSyntaxNode, BoundExpression, string, TypeSyntax, TypeWithAnnotations, BindingDiagnosticBag, string)"/>.
7724var typeArguments = typeArgumentsSyntax.Count > 0 ? BindTypeArguments(typeArgumentsSyntax, diagnostics) : default(ImmutableArray<TypeWithAnnotations>);
7820ImmutableArray<TypeWithAnnotations> typeArguments,
7894ImmutableArray<TypeWithAnnotations> typeArguments,
8014ImmutableArray<TypeWithAnnotations> typeArgumentsOpt, BindingDiagnosticBag diagnostics)
8076ImmutableArray<TypeWithAnnotations> typeArgumentsWithAnnotations,
8145ImmutableArray<TypeWithAnnotations> typeArgumentsWithAnnotations, LookupResult lookupResult, BoundMethodGroupFlags flags, SyntaxNode node,
8307default(ImmutableArray<TypeWithAnnotations>),
8409ImmutableArray<TypeWithAnnotations> typeArgumentsWithAnnotations,
8487typeWithAnnotations: TypeWithAnnotations.Create(type));
8527ImmutableArray<TypeWithAnnotations> typeArgumentsWithAnnotations,
8609ImmutableArray<TypeWithAnnotations> typeArgumentsWithAnnotations,
8716ImmutableArray<TypeWithAnnotations> typeArgumentsWithAnnotations,
10104var finalApplicableCandidates = GetCandidatesPassingFinalValidation(syntax, overloadResolutionResult, receiver, default(ImmutableArray<TypeWithAnnotations>), isExtensionMethodGroup: false, diagnostics);
10856ImmutableArray<TypeWithAnnotations> typeArguments = node.TypeArgumentsOpt;
11181TypeWithAnnotations? returnTypeOverride = null)
11186var returnType = returnTypeOverride ?? methodSymbol.ReturnTypeWithAnnotations;
11266static bool checkConstraints(CSharpCompilation compilation, ConversionsBase conversions, NamedTypeSymbol delegateType, ImmutableArray<TypeWithAnnotations> typeArguments)
Binder\Binder_Patterns.cs (12)
333declType: TypeWithAnnotations.Create(narrowedType, NullableAnnotation.NotAnnotated),
859TypeWithAnnotations declType = BindType(typeSyntax, diagnostics, out AliasSymbol aliasOpt);
868TypeWithAnnotations declType,
927private TypeWithAnnotations BindRecursivePatternType(
943return TypeWithAnnotations.Create(inputType.StrippedType(), NullableAnnotation.NotAnnotated);
974TypeWithAnnotations declTypeWithAnnotations = BindRecursivePatternType(typeSyntax, inputType, diagnostics, ref hasErrors, out BoundTypeExpression? boundDeclType);
989positionalClause, declType, ImmutableArray<TypeWithAnnotations>.Empty, permitDesignations, ref hasErrors, patternsBuilder, diagnostics);
1157ImmutableArray<TypeWithAnnotations> elementTypesWithAnnotations,
1358var declType = TypeWithState.ForType(inputType).ToTypeWithAnnotations(Compilation);
1385addSubpatternsForTuple(ImmutableArray<TypeWithAnnotations>.Empty);
1434void addSubpatternsForTuple(ImmutableArray<TypeWithAnnotations> elementTypes)
1557typeArgumentsWithAnnotations: default(ImmutableArray<TypeWithAnnotations>),
Binder\Binder_Query.cs (8)
56var typeRestriction = BindTypeArgument(fromClause.Type, diagnostics);
397var castType = BindTypeArgument(join.Type, diagnostics);
818new AnonymousTypeField(fieldName, fieldValue.Syntax.Location, TypeWithAnnotations.Create(TypeOrError(fieldValue)), RefKind.None, ScopedKind.None);
842private UnboundLambda MakeQueryUnboundLambdaWithCast(RangeVariableMap qvm, RangeVariableSymbol parameter, ExpressionSyntax expression, TypeSyntax castTypeSyntax, TypeWithAnnotations castType, bool withDependencies)
880return MakeQueryInvocation(node, receiver, methodName, default(SeparatedSyntaxList<TypeSyntax>), default(ImmutableArray<TypeWithAnnotations>), ImmutableArray.Create(arg), diagnostics
893return MakeQueryInvocation(node, receiver, methodName, default(SeparatedSyntaxList<TypeSyntax>), default(ImmutableArray<TypeWithAnnotations>), args, diagnostics
900protected BoundCall MakeQueryInvocation(CSharpSyntaxNode node, BoundExpression receiver, string methodName, TypeSyntax typeArgSyntax, TypeWithAnnotations typeArg, BindingDiagnosticBag diagnostics
913protected BoundCall MakeQueryInvocation(CSharpSyntaxNode node, BoundExpression receiver, string methodName, SeparatedSyntaxList<TypeSyntax> typeArgsSyntax, ImmutableArray<TypeWithAnnotations> typeArgs, ImmutableArray<BoundExpression> args, BindingDiagnosticBag diagnostics
Binder\Binder_Statements.cs (13)
727TypeWithAnnotations declType = BindVariableTypeWithAnnotations(node.Declaration, diagnostics, typeSyntax, ref isConst, isVar: out isVar, alias: out alias);
786private TypeWithAnnotations BindVariableTypeWithAnnotations(CSharpSyntaxNode declarationNode, BindingDiagnosticBag diagnostics, TypeSyntax typeSyntax, ref bool isConst, out bool isVar, out AliasSymbol alias)
799TypeWithAnnotations declType = BindTypeOrVarKeyword(typeSyntax.SkipScoped(out _).SkipRef(), diagnostics, out isVar, out alias);
954TypeWithAnnotations declTypeOpt,
980TypeWithAnnotations declTypeOpt,
1025declTypeOpt = TypeWithAnnotations.Create(initializerType);
1030declTypeOpt = TypeWithAnnotations.Create(CreateErrorType("var"));
1045declTypeOpt = TypeWithAnnotations.Create(CreateErrorType("var"));
1365TypeSymbol pointerType = new PointerTypeSymbol(TypeWithAnnotations.Create(elementType));
1470return op1.SetInferredTypeWithAnnotations(TypeWithAnnotations.Create(inferredType));
2373var targetElementTypes = default(ImmutableArray<TypeWithAnnotations>);
2547ImmutableArray<TypeWithAnnotations> targetElementTypes)
2858TypeWithAnnotations declType = BindTypeOrVarKeyword(typeSyntax, diagnostics, out isVar, out alias);
Binder\Binder_Symbols.cs (38)
37internal TypeWithAnnotations BindTypeOrVarKeyword(TypeSyntax syntax, BindingDiagnosticBag diagnostics, out bool isVar)
57private TypeWithAnnotations BindTypeOrConstraintKeyword(TypeSyntax syntax, BindingDiagnosticBag diagnostics, out ConstraintContextualKeyword keyword)
78internal TypeWithAnnotations BindTypeOrVarKeyword(TypeSyntax syntax, BindingDiagnosticBag diagnostics, out bool isVar, out AliasSymbol alias)
302internal TypeWithAnnotations BindType(ExpressionSyntax syntax, BindingDiagnosticBag diagnostics, ConsList<TypeSymbol> basesBeingResolved = null, bool suppressUseSiteDiagnostics = false)
311internal TypeWithAnnotations BindType(ExpressionSyntax syntax, BindingDiagnosticBag diagnostics, out AliasSymbol alias, ConsList<TypeSymbol> basesBeingResolved = null)
341return TypeWithAnnotations.Create(new ExtendedErrorTypeSymbol(GetContainingNamespaceOrNonExtensionType(symbol.Symbol), symbol.Symbol, LookupResultKind.NotATypeOrNamespace, diagnosticInfo));
409/// stack frames due to their use of large struct like <see cref="TypeWithAnnotations"/>.
467return TypeWithAnnotations.Create(
483return TypeWithAnnotations.Create(AreNullableAnnotationsEnabled(tupleTypeSyntax.CloseParenToken), BindTupleType(tupleTypeSyntax, diagnostics, basesBeingResolved));
529void reportNullableReferenceTypesIfNeeded(SyntaxToken questionToken, TypeWithAnnotations typeArgument = default)
551TypeWithAnnotations typeArgument = BindType(typeArgumentSyntax, diagnostics, basesBeingResolved);
552TypeWithAnnotations constructedType = typeArgument.SetIsAnnotated(Compilation);
579return TypeWithAnnotations.Create(AreNullableAnnotationsEnabled(predefinedType.Keyword), type);
592return TypeWithAnnotations.Create(new ExtendedErrorTypeSymbol(left, LookupResultKind.NotATypeOrNamespace, diagnostics.Add(ErrorCode.ERR_ColColWithTypeAlias, node.Alias.Location, node.Alias.Identifier.Text)));
601var elementType = BindType(node.ElementType, diagnostics, basesBeingResolved);
609return TypeWithAnnotations.Create(new PointerTypeSymbol(elementType));
615return TypeWithAnnotations.Create(CreateErrorType());
619internal static CSDiagnosticInfo? GetNullableUnconstrainedTypeParameterDiagnosticIfNecessary(LanguageVersion languageVersion, in TypeWithAnnotations type)
635private TypeWithAnnotations BindArrayType(
642TypeWithAnnotations type = BindType(node.ElementType, diagnostics, basesBeingResolved);
678type = TypeWithAnnotations.Create(AreNullableAnnotationsEnabled(rankSpecifier.CloseBracketToken), array);
689var types = ArrayBuilder<TypeWithAnnotations>.GetInstance(numElements);
701var argumentType = BindType(argumentSyntax.Type, diagnostics, basesBeingResolved);
842return TypeWithAnnotations.Create(new ExtendedErrorTypeSymbol(qualifierOpt ?? this.Compilation.Assembly.GlobalNamespace, string.Empty, arity: 0, errorInfo: null));
868return TypeWithAnnotations.Create(new ExtendedErrorTypeSymbol(
876return TypeWithAnnotations.Create(errorResult);
1158private TypeWithAnnotations BindGenericSimpleNamespaceOrTypeOrAliasSymbol(
1264return TypeWithAnnotations.Create(AreNullableAnnotationsEnabled(node.TypeArgumentList.GreaterThanToken), resultType);
1345private ImmutableArray<TypeWithAnnotations> BindTypeArguments(SeparatedSyntaxList<TypeSyntax> typeArguments, BindingDiagnosticBag diagnostics, ConsList<TypeSymbol> basesBeingResolved = null)
1348var args = ArrayBuilder<TypeWithAnnotations>.GetInstance(typeArguments.Count);
1357private TypeWithAnnotations BindTypeArgument(TypeSyntax typeArgument, BindingDiagnosticBag diagnostics, ConsList<TypeSymbol> basesBeingResolved = null)
1370var arg = typeArgument.Kind() == SyntaxKind.OmittedTypeArgument
1371? TypeWithAnnotations.Create(UnboundArgumentErrorTypeSymbol.Instance)
1380private NamedTypeSymbol ConstructNamedTypeUnlessTypeArgumentOmitted(SyntaxNode typeSyntax, NamedTypeSymbol type, SeparatedSyntaxList<TypeSyntax> typeArgumentsSyntax, ImmutableArray<TypeWithAnnotations> typeArguments, BindingDiagnosticBag diagnostics)
1426ImmutableArray<TypeWithAnnotations> typeArguments,
1473ImmutableArray<TypeWithAnnotations> typeArguments, bool invoked, ArrayBuilder<Symbol> members, BindingDiagnosticBag diagnostics)
1620ImmutableArray<TypeWithAnnotations> typeArguments,
1689TypeWithAnnotations type = right.TypeWithAnnotations;
Binder\ForEachLoopBinder.cs (15)
194TypeWithAnnotations inferredType;
227TypeWithAnnotations inferredType;
273TypeWithAnnotations iterationVariableType;
307TypeWithAnnotations declType = BindTypeOrVarKeyword(typeSyntax, diagnostics, out isVar, out alias);
311declType = inferredType.HasType ? inferredType : TypeWithAnnotations.Create(CreateErrorType("var"));
380iterationVariableType = inferredType.HasType ? inferredType : TypeWithAnnotations.Create(CreateErrorType("var"));
623internal TypeWithAnnotations InferCollectionElementType(BindingDiagnosticBag diagnostics, ExpressionSyntax collectionSyntax)
628GetEnumeratorInfoAndInferCollectionElementType(_syntax, collectionSyntax, ref collectionExpr, isAsync: IsAsync, isSpread: false, diagnostics, out TypeWithAnnotations inferredType, builder: out _);
681out TypeWithAnnotations inferredType,
695inferredType = TypeWithAnnotations.Create(DynamicTypeSymbol.Instance);
703inferredType = TypeWithAnnotations.Create(GetSpecialType(SpecialType.System_Char, diagnostics, collectionExpr.Syntax));
1192builder.ElementTypeWithAnnotations = builder.CurrentPropertyGetter?.ReturnTypeWithAnnotations ?? TypeWithAnnotations.Create(GetSpecialType(SpecialType.System_Object, diagnostics, errorLocationSyntax));
1314builder.ElementTypeWithAnnotations = TypeWithAnnotations.Create(
1322TypeWithAnnotations.Create(GetSpecialType(SpecialType.System_Char, diagnostics, syntax)) :
1451var typeArguments = ArrayBuilder<TypeWithAnnotations>.GetInstance();
Binder\Semantics\Conversions\ConversionsBase.cs (45)
1485if (anonymousFunction.HasExplicitReturnType(out var refKind, out var returnType))
1654internal static CollectionExpressionTypeKind GetCollectionExpressionTypeKind(CSharpCompilation compilation, TypeSymbol destination, out TypeWithAnnotations elementType)
1706internal static bool IsSpanOrListType(CSharpCompilation compilation, TypeSymbol targetType, WellKnownType spanType, [NotNullWhen(true)] out TypeWithAnnotations elementType)
1826internal bool HasTopLevelNullabilityIdentityConversion(TypeWithAnnotations source, TypeWithAnnotations destination)
1858internal bool HasTopLevelNullabilityImplicitConversion(TypeWithAnnotations source, TypeWithAnnotations destination)
1878private static bool IsPossiblyNullableTypeTypeParameter(in TypeWithAnnotations typeWithAnnotations)
1889public bool HasAnyNullabilityImplicitConversion(TypeWithAnnotations source, TypeWithAnnotations destination)
1959(ConversionsBase conversions, BoundExpression s, TypeWithAnnotations d, bool isChecked, ref CompoundUseSiteInfo<AssemblySymbol> u, bool forCast) =>
1976(ConversionsBase conversions, TypeWithAnnotations s, TypeWithAnnotations d, bool _, ref CompoundUseSiteInfo<AssemblySymbol> u, bool _) =>
2279private delegate Conversion ClassifyConversionFromExpressionDelegate(ConversionsBase conversions, BoundExpression sourceExpression, TypeWithAnnotations destination, bool isChecked, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo, bool forCast);
2280private delegate Conversion ClassifyConversionFromTypeDelegate(ConversionsBase conversions, TypeWithAnnotations source, TypeWithAnnotations destination, bool isChecked, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo, bool forCast);
2294(ConversionsBase conversions, BoundExpression s, TypeWithAnnotations d, bool isChecked, ref CompoundUseSiteInfo<AssemblySymbol> u, bool forCast)
2312(ConversionsBase conversions, BoundExpression s, TypeWithAnnotations d, bool isChecked, ref CompoundUseSiteInfo<AssemblySymbol> u, bool forCast) =>
2365(ConversionsBase conversions, TypeWithAnnotations s, TypeWithAnnotations d, bool _, ref CompoundUseSiteInfo<AssemblySymbol> u, bool _) =>
2384(ConversionsBase conversions, TypeWithAnnotations s, TypeWithAnnotations d, bool isChecked, ref CompoundUseSiteInfo<AssemblySymbol> u, bool forCast) =>
2405ImmutableArray<TypeWithAnnotations> sourceTypes;
2406ImmutableArray<TypeWithAnnotations> destTypes;
2590TypeWithAnnotations elementType = source.ElementTypeWithAnnotations;
2591TypeWithAnnotations argument0 = destinationAgg.TypeArgumentWithDefinitionUseSiteDiagnostics(0, ref useSiteInfo);
2601private bool HasImplicitReferenceConversion(TypeWithAnnotations source, TypeWithAnnotations destination, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
3160var typeParameters = ArrayBuilder<TypeWithAnnotations>.GetInstance();
3161var sourceTypeArguments = ArrayBuilder<TypeWithAnnotations>.GetInstance();
3162var destinationTypeArguments = ArrayBuilder<TypeWithAnnotations>.GetInstance();
3176var sourceTypeArgument = sourceTypeArguments[paramIndex];
3177var destinationTypeArgument = destinationTypeArguments[paramIndex];
3413bool hasConversion(RefKind refKind, TypeWithAnnotations sourceType, TypeWithAnnotations destinationType, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
3964var spanElementType = ((NamedTypeSymbol)destination).TypeArgumentsWithDefinitionUseSiteDiagnostics(ref useSiteInfo)[0];
3971var spanElementType = ((NamedTypeSymbol)destination).TypeArgumentsWithDefinitionUseSiteDiagnostics(ref useSiteInfo)[0];
3981var sourceElementType = ((NamedTypeSymbol)source).TypeArgumentsWithDefinitionUseSiteDiagnostics(ref useSiteInfo)[0];
3982var destinationElementType = ((NamedTypeSymbol)destination).TypeArgumentsWithDefinitionUseSiteDiagnostics(ref useSiteInfo)[0];
3991var spanElementType = ((NamedTypeSymbol)destination).TypeArgumentsWithDefinitionUseSiteDiagnostics(ref useSiteInfo)[0];
3998bool hasCovariantConversion(TypeWithAnnotations source, TypeWithAnnotations destination, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
4004bool hasIdentityConversion(TypeWithAnnotations source, TypeWithAnnotations destination)
4027var spanElementType = ((NamedTypeSymbol)destination).TypeArgumentsWithDefinitionUseSiteDiagnostics(ref useSiteInfo)[0];
Binder\Semantics\OverloadResolution\MethodTypeInference.cs (173)
73public readonly ImmutableArray<TypeWithAnnotations> InferredTypeArguments;
82ImmutableArray<TypeWithAnnotations> inferredTypeArguments,
97internal abstract TypeWithAnnotations GetTypeWithAnnotations(BoundExpression expr);
99internal abstract TypeWithAnnotations GetMethodGroupResultType(BoundMethodGroup group, MethodSymbol method);
103internal override TypeWithAnnotations GetTypeWithAnnotations(BoundExpression expr)
105return TypeWithAnnotations.Create(expr.GetTypeOrFunctionType());
108internal override TypeWithAnnotations GetMethodGroupResultType(BoundMethodGroup group, MethodSymbol method)
136private readonly ImmutableArray<TypeWithAnnotations> _formalParameterTypes;
145private readonly (TypeWithAnnotations Type, bool FromFunctionType)[] _fixedResults;
146private readonly HashSet<TypeWithAnnotations>[] _exactBounds;
147private readonly HashSet<TypeWithAnnotations>[] _upperBounds;
148private readonly HashSet<TypeWithAnnotations>[] _lowerBounds;
178ImmutableArray<TypeWithAnnotations> formalParameterTypes,
327ImmutableArray<TypeWithAnnotations> formalParameterTypes,
347_fixedResults = new (TypeWithAnnotations, bool)[methodTypeParameters.Length];
348_exactBounds = new HashSet<TypeWithAnnotations>[methodTypeParameters.Length];
349_upperBounds = new HashSet<TypeWithAnnotations>[methodTypeParameters.Length];
350_lowerBounds = new HashSet<TypeWithAnnotations>[methodTypeParameters.Length];
417var fixedType = _fixedResults[i].Type;
445private ImmutableArray<TypeWithAnnotations> GetResults(out bool inferredFromFunctionType)
465var fixedResultType = _fixedResults[i].Type;
483_fixedResults[i] = (TypeWithAnnotations.Create(new ExtendedErrorTypeSymbol(_constructedContainingTypeOfMethod, _methodTypeParameters[i].Name, 0, null, false)), false);
500private bool IsUnfixedTypeParameter(TypeWithAnnotations type)
535private void AddBound(TypeWithAnnotations addedBound, HashSet<TypeWithAnnotations>[] collectedBounds, TypeWithAnnotations methodTypeParameterWithAnnotations)
544collectedBounds[methodTypeParameterIndex] = new HashSet<TypeWithAnnotations>(TypeWithAnnotations.EqualsComparer.ConsiderEverythingComparer);
570static (typeParameter, i, self) => self.IsUnfixed(i) ? TypeWithAnnotations.Create(typeParameter) : self._fixedResults[i].Type,
612TypeWithAnnotations target = _formalParameterTypes[arg];
620private void MakeExplicitParameterTypeInferences(Binder binder, BoundExpression argument, TypeWithAnnotations target, ExactOrBoundsKind kind, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
648var argumentType = _extensions.GetTypeWithAnnotations(argument);
664TypeWithAnnotations target,
680if (!binder.TryGetCollectionIterationType((ExpressionSyntax)argument.Syntax, targetType.StrippedType(), out TypeWithAnnotations targetElementType))
700TypeWithAnnotations target,
719private bool MakeExplicitParameterTypeInferences(Binder binder, BoundTupleLiteral argument, TypeWithAnnotations target, ExactOrBoundsKind kind, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
751var destType = destTypes[i];
869var formalType = _formalParameterTypes[arg];
875private void MakeOutputTypeInferences(Binder binder, BoundExpression argument, TypeWithAnnotations formalType, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
898private void MakeOutputTypeInferences(Binder binder, BoundUnconvertedCollectionExpression argument, TypeWithAnnotations formalType, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
905if (!binder.TryGetCollectionIterationType((ExpressionSyntax)argument.Syntax, formalType.Type, out TypeWithAnnotations targetElementType))
919private void MakeOutputTypeInferences(Binder binder, BoundTupleLiteral argument, TypeWithAnnotations formalType, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
944var destType = destTypes[i];
1367private void OutputTypeInference(Binder binder, BoundExpression expression, TypeWithAnnotations target, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
1392var sourceType = _extensions.GetTypeWithAnnotations(expression);
1400private bool InferredReturnTypeInference(BoundExpression source, TypeWithAnnotations target, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
1418var returnType = delegateType.DelegateInvokeMethod.ReturnTypeWithAnnotations;
1424var inferredReturnType = InferReturnType(source, delegateType, ref useSiteInfo);
1473TypeWithAnnotations sourceReturnType = method.ReturnTypeWithAnnotations;
1492var returnType = MethodGroupReturnType(binder, originalMethodGroup, fixedParameters, method.RefKind, isFunctionPointerResolution, ref useSiteInfo, in callingConventionInfo);
1502private TypeWithAnnotations MethodGroupReturnType(
1523TypeWithAnnotations type = default;
1545private void ExplicitParameterTypeInference(BoundExpression source, TypeWithAnnotations target, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
1600private void ExplicitReturnTypeInference(BoundExpression source, TypeWithAnnotations target, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
1617if (!anonymousFunction.HasExplicitReturnType(out _, out TypeWithAnnotations anonymousFunctionReturnType))
1636private void ExactInference(TypeWithAnnotations source, TypeWithAnnotations target, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
1690private bool ExactTypeParameterInference(TypeWithAnnotations source, TypeWithAnnotations target)
1705private bool ExactArrayInference(TypeWithAnnotations source, TypeWithAnnotations target, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
1755var sourceElementType = GetSpanOrSZArrayElementType(source);
1756var targetElementType = GetSpanElementType(target);
1764private static TypeWithAnnotations GetSpanElementType(TypeSymbol type)
1770private static TypeWithAnnotations GetSpanOrSZArrayElementType(TypeSymbol type)
1784private void ExactOrBoundsInference(ExactOrBoundsKind kind, TypeWithAnnotations source, TypeWithAnnotations target, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
1800private bool ExactOrBoundsNullableInference(ExactOrBoundsKind kind, TypeWithAnnotations source, TypeWithAnnotations target, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
1820static bool isNullableOnly(TypeWithAnnotations type)
1824private bool ExactNullableInference(TypeWithAnnotations source, TypeWithAnnotations target, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
1829private bool LowerBoundTupleInference(TypeWithAnnotations source, TypeWithAnnotations target, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
1838ImmutableArray<TypeWithAnnotations> sourceTypes;
1839ImmutableArray<TypeWithAnnotations> targetTypes;
1856private bool ExactConstructedInference(TypeWithAnnotations source, TypeWithAnnotations target, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
1886private bool ExactPointerInference(TypeWithAnnotations source, TypeWithAnnotations target, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
1946var sourceTypeArguments = ArrayBuilder<TypeWithAnnotations>.GetInstance();
1947var targetTypeArguments = ArrayBuilder<TypeWithAnnotations>.GetInstance();
1967private void LowerBoundInference(TypeWithAnnotations source, TypeWithAnnotations target, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
2061private bool LowerBoundTypeParameterInference(TypeWithAnnotations source, TypeWithAnnotations target)
2076private static TypeWithAnnotations GetMatchingElementType(ArrayTypeSymbol source, TypeSymbol target, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
2130var elementSource = arraySource.ElementTypeWithAnnotations;
2131var elementTarget = GetMatchingElementType(arraySource, target, ref useSiteInfo);
2167var sourceElementType = GetSpanOrSZArrayElementType(source);
2168var targetElementType = GetSpanElementType(target);
2187private bool LowerBoundNullableInference(TypeWithAnnotations source, TypeWithAnnotations target, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
2389var sourceTypeArguments = ArrayBuilder<TypeWithAnnotations>.GetInstance();
2390var targetTypeArguments = ArrayBuilder<TypeWithAnnotations>.GetInstance();
2402var sourceTypeArgument = sourceTypeArguments[arg];
2403var targetTypeArgument = targetTypeArguments[arg];
2476private void UpperBoundInference(TypeWithAnnotations source, TypeWithAnnotations target, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
2537private bool UpperBoundTypeParameterInference(TypeWithAnnotations source, TypeWithAnnotations target)
2551private bool UpperBoundArrayInference(TypeWithAnnotations source, TypeWithAnnotations target, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
2569var elementTarget = arrayTarget.ElementTypeWithAnnotations;
2570var elementSource = GetMatchingElementType(arrayTarget, source.Type, ref useSiteInfo);
2588private bool UpperBoundNullableInference(TypeWithAnnotations source, TypeWithAnnotations target, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
2593private bool UpperBoundConstructedInference(TypeWithAnnotations sourceWithAnnotations, TypeWithAnnotations targetWithAnnotations, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
2739var sourceTypeArguments = ArrayBuilder<TypeWithAnnotations>.GetInstance();
2740var targetTypeArguments = ArrayBuilder<TypeWithAnnotations>.GetInstance();
2752var sourceTypeArgument = sourceTypeArguments[arg];
2753var targetTypeArgument = targetTypeArguments[arg];
2846var withoutNullability = Fix(_compilation, _conversions.WithNullability(false), typeParameter, exact, lower, upper, ref discardedUseSiteInfo).Type;
2858private static (TypeWithAnnotations Type, bool FromFunctionType) Fix(
2862HashSet<TypeWithAnnotations>? exact,
2863HashSet<TypeWithAnnotations>? lower,
2864HashSet<TypeWithAnnotations>? upper,
2879var candidates = new Dictionary<TypeWithAnnotations, TypeWithAnnotations>(EqualsIgnoringDynamicTupleNamesAndNullabilityComparer.Instance);
2884Predicate<TypeWithAnnotations> lowerPredicate;
2929var initialCandidates = ArrayBuilder<TypeWithAnnotations>.GetInstance();
2954TypeWithAnnotations best = default;
2955foreach (var candidate in initialCandidates)
2957foreach (var candidate2 in initialCandidates)
2995best = TypeWithAnnotations.Create(resultType, best.NullableAnnotation);
3001static bool containsFunctionTypes([NotNullWhen(true)] HashSet<TypeWithAnnotations>? types)
3006static bool containsNonFunctionTypes([NotNullWhen(true)] HashSet<TypeWithAnnotations>? types)
3011static bool isFunctionType(TypeWithAnnotations type, [NotNullWhen(true)] out FunctionTypeSymbol? functionType)
3037private static bool ImplicitConversionExists(TypeWithAnnotations sourceWithAnnotations, TypeWithAnnotations destinationWithAnnotations, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo, ConversionsBase conversions)
3061private TypeWithAnnotations InferReturnType(BoundExpression source, NamedTypeSymbol target, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
3142var returnType = anonymousFunction.InferReturnType(_conversions, fixedDelegate, ref useSiteInfo, out bool inferredFromFunctionType);
3187public static ImmutableArray<TypeWithAnnotations> InferTypeArgumentsFromReceiverType(
3239public static ImmutableArray<TypeWithAnnotations> InferTypeArgumentsFromFirstArgument(
3304var dest = _formalParameterTypes[0];
3336private ImmutableArray<TypeWithAnnotations> GetInferredTypeArguments(out bool inferredFromFunctionType)
3338var builder = ArrayBuilder<TypeWithAnnotations>.GetInstance(_fixedResults.Length);
3358private static void GetAllCandidates(Dictionary<TypeWithAnnotations, TypeWithAnnotations> candidates, ArrayBuilder<TypeWithAnnotations> builder)
3371Dictionary<TypeWithAnnotations, TypeWithAnnotations> candidates,
3372HashSet<TypeWithAnnotations> bounds,
3373Predicate<TypeWithAnnotations>? predicate,
3377foreach (var candidate in bounds)
3384var type = candidate;
3400Dictionary<TypeWithAnnotations, TypeWithAnnotations> candidates,
3401TypeWithAnnotations newCandidate,
3404if (candidates.TryGetValue(newCandidate, out TypeWithAnnotations oldCandidate))
3415Dictionary<TypeWithAnnotations, TypeWithAnnotations> candidates,
3416HashSet<TypeWithAnnotations> bounds,
3417Predicate<TypeWithAnnotations>? predicate,
3418ArrayBuilder<TypeWithAnnotations> initialCandidates,
3427foreach (var bound in bounds)
3434foreach (var candidate in initialCandidates)
3440TypeWithAnnotations source;
3441TypeWithAnnotations destination;
3455if (conversions.IncludeNullability && candidates.TryGetValue(bound, out var oldBound))
3462var newBound = TypeWithAnnotations.Create(oldBound.Type, newAnnotation);
3482Dictionary<TypeWithAnnotations, TypeWithAnnotations> candidates,
3483TypeWithAnnotations oldCandidate,
3484TypeWithAnnotations newCandidate,
3493if (candidates.TryGetValue(oldCandidate, out TypeWithAnnotations latest))
3504TypeWithAnnotations merged = latest.MergeEquivalentTypes(newCandidate, variance);
3513private sealed class EqualsIgnoringDynamicTupleNamesAndNullabilityComparer : EqualityComparer<TypeWithAnnotations>
3517public override int GetHashCode(TypeWithAnnotations obj)
3522public override bool Equals(TypeWithAnnotations x, TypeWithAnnotations y)
Binder\Semantics\OverloadResolution\OverloadResolution.cs (40)
139ArrayBuilder<TypeWithAnnotations> typeArguments,
175ArrayBuilder<TypeWithAnnotations> typeArguments = ArrayBuilder<TypeWithAnnotations>.GetInstance();
187ArrayBuilder<TypeWithAnnotations> typeArguments,
240var typeArguments = ArrayBuilder<TypeWithAnnotations>.GetInstance(0);
354ArrayBuilder<TypeWithAnnotations> typeArguments,
430ArrayBuilder<TypeWithAnnotations> typeArguments,
564var typeArgumentsBuilder = ArrayBuilder<TypeWithAnnotations>.GetInstance();
948if (IsValidParams(_binder, constructor, disallowExpandedNonArrayParams: false, out TypeWithAnnotations definitionElementType))
1011TypeWithAnnotations definitionParamsElementType,
1060ArrayBuilder<TypeWithAnnotations> typeArguments,
1195if ((options & (Options.IsMethodGroupConversion | Options.DisallowExpandedForm)) == 0 && IsValidParams(_binder, leastOverriddenMember, disallowExpandedNonArrayParams, out TypeWithAnnotations definitionElementType))
1296public static bool IsValidParams(Binder binder, Symbol member, bool disallowExpandedNonArrayParams, out TypeWithAnnotations definitionElementType)
1324public static bool TryInferParamsCollectionIterationType(Binder binder, TypeSymbol type, out TypeWithAnnotations elementType)
2569TypeWithAnnotations paramsElementTypeOpt, TMember member, out RefKind parameter1RefKind)
3207CollectionExpressionTypeKind kind1 = ConversionsBase.GetCollectionExpressionTypeKind(Compilation, t1, out TypeWithAnnotations elementType1);
3208CollectionExpressionTypeKind kind2 = ConversionsBase.GetCollectionExpressionTypeKind(Compilation, t2, out TypeWithAnnotations elementType2);
3235if (type.IsArrayInterface(out TypeWithAnnotations typeArg))
3279var x = lambda.GetInferredReturnType(ref useSiteInfo, out _);
3730var x = lambda.InferReturnType(Conversions, d1, ref useSiteInfo, out _);
3839out ImmutableArray<TypeWithAnnotations> parameterTypes,
3855internal readonly ImmutableArray<TypeWithAnnotations> ParameterTypes;
3859internal EffectiveParameters(ImmutableArray<TypeWithAnnotations> types, ImmutableArray<RefKind> refKinds, int firstParamsElementIndex)
3904var types = ArrayBuilder<TypeWithAnnotations>.GetInstance();
4041var types = ArrayBuilder<TypeWithAnnotations>.GetInstance();
4047TypeWithAnnotations paramsIterationType = default;
4054var type = parameter.TypeWithAnnotations;
4090ArrayBuilder<TypeWithAnnotations> typeArguments,
4168ArrayBuilder<TypeWithAnnotations> typeArguments,
4170TypeWithAnnotations definitionParamsElementType,
4231ArrayBuilder<TypeWithAnnotations> typeArgumentsBuilder,
4235TypeWithAnnotations definitionParamsElementTypeOpt,
4254ImmutableArray<TypeWithAnnotations> typeArguments;
4373static ImmutableArray<TypeWithAnnotations> getAllTypeArguments(TMember member, bool isNewExtensionMember)
4393private ImmutableArray<TypeWithAnnotations> InferMethodTypeArguments<TMember>(
4460return default(ImmutableArray<TypeWithAnnotations>);
4466return default(ImmutableArray<TypeWithAnnotations>);
4472TypeWithAnnotations definitionParamsElementTypeOpt,
4484TypeWithAnnotations paramsElementTypeOpt;
4490paramsElementTypeOpt = TypeWithAnnotations.Create(ErrorTypeSymbol.EmptyParamsCollectionElementTypeSentinel);
BoundTree\Constructors.cs (5)
472public BoundTypeExpression(SyntaxNode syntax, AliasSymbol? aliasOpt, BoundTypeExpression? boundContainingTypeOpt, ImmutableArray<BoundExpression> boundDimensionsOpt, TypeWithAnnotations typeWithAnnotations, bool hasErrors = false)
478public BoundTypeExpression(SyntaxNode syntax, AliasSymbol? aliasOpt, BoundTypeExpression? boundContainingTypeOpt, TypeWithAnnotations typeWithAnnotations, bool hasErrors = false)
483public BoundTypeExpression(SyntaxNode syntax, AliasSymbol? aliasOpt, TypeWithAnnotations typeWithAnnotations, bool hasErrors = false)
489: this(syntax, aliasOpt, null, TypeWithAnnotations.Create(type), hasErrors)
493public BoundTypeExpression(SyntaxNode syntax, AliasSymbol? aliasOpt, ImmutableArray<BoundExpression> dimensionsOpt, TypeWithAnnotations typeWithAnnotations, bool hasErrors = false)
BoundTree\UnboundLambda.cs (68)
44internal readonly TypeWithAnnotations TypeWithAnnotations;
54TypeWithAnnotations typeWithAnnotations,
106public TypeWithAnnotations GetInferredReturnType(ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo, out bool inferredFromFunctionType)
117public TypeWithAnnotations GetInferredReturnType(ConversionsBase? conversions, NullableWalker.VariableState? nullableState, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo, out bool inferredFromFunctionType)
144var returnTypes = ArrayBuilder<(BoundReturnStatement, TypeWithAnnotations)>.GetInstance();
169TypeWithAnnotations returnType,
170ImmutableArray<TypeWithAnnotations> parameterTypes,
185internal static InferredLambdaReturnType InferReturnType(ArrayBuilder<(BoundReturnStatement, TypeWithAnnotations)> returnTypes,
192internal static InferredLambdaReturnType InferReturnType(ArrayBuilder<(BoundReturnStatement, TypeWithAnnotations)> returnTypes,
202private static InferredLambdaReturnType InferReturnTypeImpl(ArrayBuilder<(BoundReturnStatement, TypeWithAnnotations)> returnTypes,
205var types = ArrayBuilder<(BoundExpression expr, TypeWithAnnotations resultType, bool isChecked)>.GetInstance();
227var bestType = CalculateReturnType(binder, conversions, delegateType, types, isAsync, node, ref useSiteInfo, out bool inferredFromFunctionType);
242private static TypeWithAnnotations CalculateReturnType(
246ArrayBuilder<(BoundExpression expr, TypeWithAnnotations resultType, bool isChecked)> returns,
252TypeWithAnnotations bestResultType;
278bestResultType = TypeWithAnnotations.Create(bestType);
290bestResultType = TypeWithAnnotations.Create(bestType);
320return TypeWithAnnotations.Create(resultType);
335return TypeWithAnnotations.Create(taskTypeT.Construct(ImmutableArray.Create(bestResultType)));
340private readonly ArrayBuilder<(BoundReturnStatement, TypeWithAnnotations)> _builder;
342private BlockReturns(ArrayBuilder<(BoundReturnStatement, TypeWithAnnotations)> builder)
347public static void GetReturnTypes(ArrayBuilder<(BoundReturnStatement, TypeWithAnnotations)> builder, BoundBlock block)
380_builder.Add((node, TypeWithAnnotations.Create(type)));
395TypeWithAnnotations returnType,
399ImmutableArray<TypeWithAnnotations> types,
462public bool HasExplicitReturnType(out RefKind refKind, out TypeWithAnnotations returnType)
484public TypeWithAnnotations InferReturnType(ConversionsBase conversions, NamedTypeSymbol delegateType, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo, out bool inferredFromFunctionType)
494public TypeWithAnnotations ParameterTypeWithAnnotations(int index) { return Data.ParameterTypeWithAnnotations(index); }
577public abstract bool HasExplicitReturnType(out RefKind refKind, out TypeWithAnnotations returnType);
583public abstract TypeWithAnnotations ParameterTypeWithAnnotations(int index);
636var type = lambda.InferredReturnType.TypeWithAnnotations;
646var type = BindForErrorRecovery().InferredReturnType.TypeWithAnnotations;
659private static TypeWithAnnotations DelegateReturnTypeWithAnnotations(MethodSymbol? invokeMethod, out RefKind refKind)
670internal (ImmutableArray<RefKind>, ArrayBuilder<ScopedKind>, ImmutableArray<TypeWithAnnotations>, bool) CollectParameterProperties()
674var parameterTypesBuilder = ArrayBuilder<TypeWithAnnotations>.GetInstance(ParameterCount);
681var type = ParameterTypeWithAnnotations(i);
736if (!HasExplicitReturnType(out var returnRefKind, out var returnType))
740var returnTypes = ArrayBuilder<(BoundReturnStatement, TypeWithAnnotations)>.GetInstance();
782returnType = TypeWithAnnotations.Create(Binder.Compilation.GetSpecialType(SpecialType.System_Void));
800var returnType = DelegateReturnTypeWithAnnotations(invokeMethod, out RefKind refKind);
904TypeWithAnnotations returnType,
905ImmutableArray<TypeWithAnnotations> parameterTypes,
921var returnType = DelegateReturnTypeWithAnnotations(invokeMethod, out RefKind refKind);
926private void ValidateUnsafeParameters(BindingDiagnosticBag diagnostics, ImmutableArray<TypeWithAnnotations> targetParameterTypes)
953ImmutableArray<TypeWithAnnotations> parameterTypes,
956bool hasExplicitReturnType = HasExplicitReturnType(out var refKind, out var returnType);
975var returnTypes = ArrayBuilder<(BoundReturnStatement, TypeWithAnnotations)>.GetInstance();
985? TypeWithAnnotations.Create(this.Binder.Compilation.GetSpecialType(SpecialType.System_Void))
986: TypeWithAnnotations.Create(LambdaSymbol.InferenceFailureReturnType);
1010ImmutableArray<TypeWithAnnotations> parameterTypes,
1012TypeWithAnnotations returnType,
1046public readonly ImmutableArray<TypeWithAnnotations> ParameterTypes;
1050public static readonly ReturnInferenceCacheKey Empty = new ReturnInferenceCacheKey(ImmutableArray<TypeWithAnnotations>.Empty, ImmutableArray<RefKind>.Empty, null);
1052private ReturnInferenceCacheKey(ImmutableArray<TypeWithAnnotations> parameterTypes, ImmutableArray<RefKind> parameterRefKinds, NamedTypeSymbol? taskLikeReturnTypeOpt)
1092foreach (var type in ParameterTypes)
1112out ImmutableArray<TypeWithAnnotations> parameterTypes,
1118parameterTypes = ImmutableArray<TypeWithAnnotations>.Empty;
1127var typesBuilder = ArrayBuilder<TypeWithAnnotations>.GetInstance(parameterCount);
1204?? rebind(ReallyInferReturnType(delegateType: null, ImmutableArray<TypeWithAnnotations>.Empty, ImmutableArray<RefKind>.Empty));
1220ImmutableArray<TypeWithAnnotations> parameterTypes,
1223var returnType = inferredReturnType.TypeWithAnnotations;
1235returnType = TypeWithAnnotations.Create(t);
1450private readonly TypeWithAnnotations _returnType;
1454private readonly ImmutableArray<TypeWithAnnotations> _parameterTypesWithAnnotations;
1465TypeWithAnnotations returnType,
1469ImmutableArray<TypeWithAnnotations> parameterTypesWithAnnotations,
1495public override bool HasExplicitReturnType(out RefKind refKind, out TypeWithAnnotations returnType)
1573public override TypeWithAnnotations ParameterTypeWithAnnotations(int index)
Compilation\CSharpCompilation.cs (10)
2270var firstType = method.Parameters[0].TypeWithAnnotations;
2404return ArrayTypeSymbol.CreateCSharpArray(this.Assembly, TypeWithAnnotations.Create(elementType, elementNullableAnnotation), rank);
2417return new PointerTypeSymbol(TypeWithAnnotations.Create(elementType, elementNullableAnnotation));
4140var returnTypeWithAnnotations = TypeWithAnnotations.Create(returnType.EnsureCSharpSymbolOrNull(nameof(returnType)), returnType.NullableAnnotation.ToInternalAnnotation());
4142type => TypeWithAnnotations.Create(type.EnsureCSharpSymbolOrNull(nameof(parameterTypes)), type.NullableAnnotation.ToInternalAnnotation()));
4190var typesBuilder = ArrayBuilder<TypeWithAnnotations>.GetInstance(elementTypes.Length);
4196typesBuilder.Add(TypeWithAnnotations.Create(elementType, annotation));
4234(t, a) => TypeWithAnnotations.Create(t.Type, a.ToInternalAnnotation())));
4264fields.Add(new AnonymousTypeField(name, location, TypeWithAnnotations.Create(type, nullableAnnotation), RefKind.None, ScopedKind.None));
FlowAnalysis\NullableWalker.cs (223)
100public readonly TypeWithAnnotations LValueType;
111public VisitResult(TypeWithState rValueType, TypeWithAnnotations lValueType)
120public VisitResult(TypeWithState rValueType, TypeWithAnnotations lValueType, Optional<LocalState> stateForLambda)
129LValueType = TypeWithAnnotations.Create(type, annotation);
137public VisitResult(TypeWithState rValueType, TypeWithAnnotations lValueType, VisitResult[] nestedVisitResults)
143internal VisitResult WithLValueType(TypeWithAnnotations lvalueType)
210private ArrayBuilder<(BoundReturnStatement, TypeWithAnnotations)>? _returnTypesOpt;
248private PooledDictionary<BoundExpression, Func<TypeWithAnnotations, TypeWithState>>? _targetTypedAnalysisCompletionOpt;
253/// The delegate is invoked by <see cref="VisitConversion(BoundConversion, BoundExpression, Conversion, TypeWithAnnotations, TypeWithState, bool, bool, bool, AssignmentKind, ParameterSymbol, bool, bool, bool, bool, Optional<LocalState>,bool, Location, ArrayBuilder<VisitResult>)"/>.
255private PooledDictionary<BoundExpression, Func<TypeWithAnnotations, TypeWithState>> TargetTypedAnalysisCompletion
256=> _targetTypedAnalysisCompletionOpt ??= PooledDictionary<BoundExpression, Func<TypeWithAnnotations, TypeWithState>>.GetInstance();
321private TypeWithAnnotations LvalueResultType
326private void SetLvalueResultType(BoundExpression? expression, TypeWithAnnotations type)
341private void SetResult(BoundExpression? expression, TypeWithState resultType, TypeWithAnnotations lvalueType, bool updateAnalyzedNullability = true, bool? isLvalue = null)
361private void SetAnalyzedNullability(BoundExpression? expression, TypeWithState resultType, TypeWithAnnotations lvalueType, bool? isLvalue = null)
472ArrayBuilder<(BoundReturnStatement, TypeWithAnnotations)>? returnTypesOpt,
740TypeWithAnnotations symbolType;
858var type = GetTypeOrReturnTypeWithAnnotations(memberToInitialize);
1045var symbolType = ApplyUnconditionalAnnotations(property.TypeWithAnnotations, symbolAnnotations);
1052var overriddenType = ApplyUnconditionalAnnotations(overriddenProperty.TypeWithAnnotations, overriddenAnnotations);
1784ArrayBuilder<(BoundReturnStatement, TypeWithAnnotations)>? returnTypesOpt)
1832ArrayBuilder<(BoundReturnStatement, TypeWithAnnotations)>? returnTypesOpt,
2017if (!_variables.TryGetType(local, out TypeWithAnnotations localType))
2026if (!_variables.TryGetType(parameter, out TypeWithAnnotations parameterType))
2325private TypeWithAnnotations VisitLvalueWithAnnotations(BoundExpression node)
2366private static bool ShouldReportNullableAssignment(TypeWithAnnotations type, NullableFlowState state)
2402TypeWithAnnotations targetType,
2475TypeWithAnnotations overriddenType,
2477TypeWithAnnotations overridingType,
2548static bool isBadAssignment(TypeWithState valueState, TypeWithAnnotations destinationType, FlowAnalysisAnnotations destinationAnnotations)
2624TypeWithAnnotations targetType,
2667static bool areEquivalentTypes(TypeWithAnnotations target, TypeWithState assignedValue) =>
2737TypeWithAnnotations fieldOrPropertyType = GetTypeOrReturnTypeWithAnnotations(member);
2864private TypeWithAnnotations GetTypeOrReturnTypeWithAnnotations(Symbol symbol)
2866var typeWithAnnotations = symbol.GetTypeOrReturnType();
2893typeWithAnnotations = TypeWithAnnotations.Create(typeWithAnnotations.Type, nullableAnnotation);
2975var parameterType = i >= signatureParameters.Length ? parameter.TypeWithAnnotations : signatureParameters[i].TypeWithAnnotations;
2981private void EnterParameter(ParameterSymbol parameter, TypeWithAnnotations parameterType)
3010var parameterLValueType = ApplyLValueAnnotations(parameter.TypeWithAnnotations, parameterAnnotations);
3026internal static TypeWithState GetParameterState(TypeWithAnnotations parameterType, FlowAnalysisAnnotations parameterAnnotations)
3056TryGetReturnType(out TypeWithAnnotations returnType, out FlowAnalysisAnnotations returnAnnotations))
3115private TypeWithState VisitRefExpression(BoundExpression expr, TypeWithAnnotations destinationType)
3121var lvalueResultType = LvalueResultType;
3137private bool TryGetReturnType(out TypeWithAnnotations type, out FlowAnalysisAnnotations annotations)
3148var returnType = delegateOrMethod.ReturnTypeWithAnnotations;
3192var type = GetDeclaredLocalResult(local);
3200type = TypeWithAnnotations.Create(node.Type, type.NullableAnnotation);
3555var resultType = ResultType.ToTypeWithAnnotations(compilation);
3656TypeWithAnnotations type = local.TypeWithAnnotations;
3859var elementConversionCompletions = ArrayBuilder<Func<TypeWithAnnotations /*targetElementType*/, TypeSymbol /*targetCollectionType*/, TypeWithState>>.GetInstance();
3871(TypeWithAnnotations resultTypeWithAnnotations) => convertCollection(node, resultTypeWithAnnotations, elementConversionCompletions);
3880var resultType = TypeWithAnnotations.Create(node.Type);
3887void visitElement(BoundNode element, BoundCollectionExpression node, TypeWithAnnotations targetElementType, ArrayBuilder<Func<TypeWithAnnotations, TypeSymbol, TypeWithState>> elementConversionCompletions)
3979TypeWithState convertCollection(BoundCollectionExpression node, TypeWithAnnotations targetCollectionType, ArrayBuilder<Func<TypeWithAnnotations, TypeSymbol, TypeWithState>> completions)
4021(CollectionExpressionTypeKind, TypeWithAnnotations) getCollectionDetails(BoundCollectionExpression node, TypeSymbol collectionType)
4023var collectionKind = ConversionsBase.GetCollectionExpressionTypeKind(this.compilation, collectionType, out var targetElementType);
4141(TypeWithAnnotations resultTypeWithAnnotations) =>
4221var parameterType = constructor.ParameterTypesWithAnnotations[0];
4222if (AreNullableAndUnderlyingTypes(type, parameterType.Type, out TypeWithAnnotations underlyingType))
4472Action<int, Symbol>? visitMemberAssignment(BoundAssignmentOperator node, int containingSlot, Symbol symbol, bool delayCompletionForType, Func<TypeWithAnnotations, TypeWithState>? conversionCompletion = null)
4483var type = ApplyLValueAnnotations(GetTypeOrReturnTypeWithAnnotations(symbol), GetObjectInitializerMemberLValueAnnotations(symbol));
4505Action<int, Symbol>? visitMemberAssignmentAsContinuation(BoundAssignmentOperator node, Func<TypeWithAnnotations, TypeWithState> conversionCompletion)
4639var lvalueType = resultType.ToTypeWithAnnotations(compilation);
4691return GetOrCreatePlaceholderSlot(node, TypeWithAnnotations.Create(node.Type, NullableAnnotation.NotAnnotated));
4694private int GetOrCreatePlaceholderSlot(object identifier, TypeWithAnnotations type)
4796var elementType = type switch
4844TypeWithAnnotations inferredType = (bestType is null)
4846: TypeWithAnnotations.Create(bestType);
4885static TypeWithAnnotations getSpanElementType(NamedTypeSymbol namedType)
4892static TypeSymbol setSpanElementType(NamedTypeSymbol namedType, TypeWithAnnotations elementType)
4921internal static TypeWithAnnotations BestTypeForLambdaReturns(
4922ArrayBuilder<(BoundExpression expr, TypeWithAnnotations resultType, bool isChecked)> returns,
4945var resultTypes = ArrayBuilder<TypeWithAnnotations>.GetInstance(n);
4958TypeWithAnnotations inferredType;
4962var bestTypeWithObliviousAnnotation = TypeWithAnnotations.Create(bestType);
4974inferredType = TypeWithAnnotations.Create(bestType, BestTypeInferrer.GetNullableAnnotation(resultTypes));
5021TypeWithAnnotations result;
5025result = TypeWithAnnotations.Create(type);
5048TypeWithAnnotations type = expressionType.TryGetInlineArrayElementField()!.TypeWithAnnotations;
5052type = TypeWithAnnotations.Create(((NamedTypeSymbol)node.Type).OriginalDefinition.Construct(ImmutableArray.Create(type)));
5277SetResult(binary, TypeWithState.ForType(binary.Type), TypeWithAnnotations.Create(binary.Type));
5352TypeWithAnnotations.Create(expr.Type),
5454var targetTypeWithNullability = ApplyLValueAnnotations(parameter.TypeWithAnnotations, parameterAnnotations);
5458targetTypeWithNullability = TypeWithAnnotations.Create(MakeNullableOf(targetTypeWithNullability));
5831TypeWithAnnotations targetType = VisitLvalueWithAnnotations(leftOperand);
5849targetType = TypeWithAnnotations.Create(node.Type, NullableAnnotation.NotAnnotated);
5940TypeWithAnnotations.Create(rightType),
5976TypeWithAnnotations explicitType = boundConversion.ConversionGroupOpt?.ExplicitType ?? default;
5978TypeWithAnnotations targetType = fromExplicitCast ? explicitType : TypeWithAnnotations.Create(boundConversion.Type);
6117var accessTypeWithAnnotations = LvalueResultType;
6173TypeWithAnnotations consequenceLValue;
6174TypeWithAnnotations alternativeLValue;
6194var refResultTypeWithAnnotations = TypeWithAnnotations.Create(refResultType, lValueAnnotation);
6203SetResult(node, TypeWithState.Create(refResultType, rValueState), TypeWithAnnotations.Create(refResultType, lValueAnnotation));
6254TypeWithAnnotations resultTypeWithAnnotations;
6275resultTypeWithAnnotations = TypeWithAnnotations.Create(resultType);
6288BoundExpression alternative, Conversion alternativeConversion, bool alternativeEndReachable, TypeWithAnnotations resultTypeWithAnnotations, bool wasTargetTyped)
6345(TypeWithAnnotations resultTypeWithAnnotations) =>
6367(TypeWithAnnotations LValueType, TypeWithState RValueType) visitConditionalRefOperand(LocalState state, BoundExpression operand)
6371TypeWithAnnotations lValueType = VisitLvalueWithAnnotations(operand);
6375void reportMismatchIfNecessary(BoundExpression node, TypeWithAnnotations source, TypeWithAnnotations destination)
6388TypeWithAnnotations targetType,
6436private static BoundExpression CreatePlaceholderIfNecessary(BoundExpression expr, TypeWithAnnotations type)
6516TypeWithAnnotations paramsIterationType = default;
6788var parameterType = method.Parameters[0].TypeWithAnnotations;
7053private static TypeWithAnnotations ApplyLValueAnnotations(TypeWithAnnotations declaredType, FlowAnalysisAnnotations flowAnalysisAnnotations)
7085private static TypeWithAnnotations ApplyUnconditionalAnnotations(TypeWithAnnotations declaredType, FlowAnalysisAnnotations annotations)
7296TypeWithAnnotations paramsIterationType = default;
7303(ParameterSymbol? parameter, TypeWithAnnotations parameterType, FlowAnalysisAnnotations parameterAnnotations, bool isExpandedParamsArgument) =
7373TypeWithAnnotations paramsIterationType = default;
7379(ParameterSymbol? parameter, TypeWithAnnotations parameterType, FlowAnalysisAnnotations parameterAnnotations, _) =
7524completion(TypeWithAnnotations.Create(argument.Type));
7718TypeWithAnnotations paramsIterationType = default;
7728TypeWithAnnotations paramsIterationType = default;
7807TypeWithAnnotations parameterType,
7862var lvalueResultType = result.LValueType;
7944TypeWithAnnotations parameterType,
7974var lValueType = result.LValueType;
7998var declaredType = result.LValueType;
8000var lValueType = ApplyLValueAnnotations(declaredType, leftAnnotations);
8003var varType = worstCaseParameterWithState.ToAnnotatedTypeWithAnnotations(compilation);
8057void trackNullableStateForAssignment(BoundExpression parameterValue, TypeWithAnnotations lValueType, int targetSlot, TypeWithState parameterWithState, bool isSuppressed, FlowAnalysisAnnotations parameterAnnotations)
8240private (ParameterSymbol? Parameter, TypeWithAnnotations Type, FlowAnalysisAnnotations Annotations, bool isExpandedParamsArgument) GetCorrespondingParameter(
8245ref TypeWithAnnotations paramsIterationType)
8259var type = parameter.TypeWithAnnotations;
8307parameterTypes: out ImmutableArray<TypeWithAnnotations> parameterTypes,
8344internal override TypeWithAnnotations GetTypeWithAnnotations(BoundExpression expr)
8346return TypeWithAnnotations.Create(expr.GetTypeOrFunctionType(), GetNullableAnnotation(expr));
8377internal override TypeWithAnnotations GetMethodGroupResultType(BoundMethodGroup group, MethodSymbol method)
8445var argumentType = visitResult.RValueType.ToTypeWithAnnotations(compilation);
8766TypeWithAnnotations explicitType = node.ConversionGroupOpt?.ExplicitType ?? default;
8768TypeWithAnnotations targetType = fromExplicitCast ? explicitType : TypeWithAnnotations.Create(node.Type);
8806private TypeWithState VisitOptionalImplicitConversion(BoundExpression expr, TypeWithAnnotations targetTypeOpt, bool useLegacyWarnings, bool trackMembers, AssignmentKind assignmentKind)
8818private (TypeWithState resultType, Func<TypeWithAnnotations, TypeWithState>? completion) VisitOptionalImplicitConversion(
8820TypeWithAnnotations targetTypeOpt,
8832(TypeWithState resultType, Func<TypeWithAnnotations, TypeWithState>? completion) visitConversion(
8834TypeWithAnnotations targetTypeOpt,
8869Func<TypeWithAnnotations, TypeWithState> visitConversionAsContinuation(BoundExpression expr, bool useLegacyWarnings, bool trackMembers, AssignmentKind assignmentKind, BoundExpression operand, Conversion conversion, TypeWithState operandType)
8871return (TypeWithAnnotations targetTypeOpt) =>
8880private static bool AreNullableAndUnderlyingTypes([NotNullWhen(true)] TypeSymbol? nullableTypeOpt, [NotNullWhen(true)] TypeSymbol? underlyingTypeOpt, out TypeWithAnnotations underlyingTypeWithAnnotations)
8885var typeArg = nullableTypeOpt.GetNullableUnderlyingTypeWithAnnotations();
8920ImmutableArray<TypeWithAnnotations> elementTypesWithAnnotations = elementTypes.SelectAsArray(a => a.ToTypeWithAnnotations(compilation));
9277TypeWithAnnotations targetTypeWithNullability,
9298if (TargetTypedAnalysisCompletion.TryGetValue(conversionOperand, out Func<TypeWithAnnotations, TypeWithState>? completion))
9489if (AreNullableAndUnderlyingTypes(targetType, operandType.Type, out TypeWithAnnotations underlyingType))
9629static TypeWithState calculateResultType(TypeWithAnnotations targetTypeWithNullability, bool fromExplicitCast, NullableFlowState resultState, bool isSuppressed, TypeSymbol targetType)
9645static NullableFlowState getReferenceConversionResultState(TypeWithAnnotations targetType, TypeWithState operandType)
9679static NullableFlowState getBoxingConversionResultState(TypeWithAnnotations targetType, TypeWithState operandType)
9739foreach (var constraintType in typeParameter1.ConstraintTypesNoUseSiteDiagnostics)
9837TypeWithAnnotations targetTypeWithNullability,
9869TypeWithAnnotations.Create(conversion.BestUserDefinedConversionAnalysis!.FromType),
9889var parameterType = ApplyLValueAnnotations(parameter.TypeWithAnnotations, parameterAnnotations);
9895var underlyingOperandTypeWithAnnotations = operandType.Type.GetNullableUnderlyingTypeWithAnnotations();
9921var methodReturnType = method.ReturnTypeWithAnnotations;
9940TypeWithAnnotations.Create(conversion.BestUserDefinedConversionAnalysis!.ToType),
10021private TypeWithState GetLiftedReturnType(TypeWithAnnotations returnType, NullableFlowState operandState)
10042private TypeWithState GetLiftedReturnTypeIfNecessary(bool isLifted, TypeWithAnnotations returnType, NullableFlowState operandState)
10049private TypeSymbol MakeNullableOf(TypeWithAnnotations underlying)
10056TypeWithAnnotations targetType,
10156(TypeWithAnnotations resultTypeWithAnnotations) =>
10237var argTypeWithAnnotations = TypeWithAnnotations.Create(argType, NullableAnnotation.NotAnnotated);
10337var parameterType = parameter.TypeWithAnnotations;
10436var lvalueResult = TypeWithAnnotations.Create(node.Type, NullableAnnotation.NotAnnotated);
10444var parameterType = GetDeclaredParameterResult(parameter);
10464TypeWithAnnotations leftLValueType;
10505var lvalueType = rightState.ToTypeWithAnnotations(compilation);
10523var type = property.TypeWithAnnotations;
10525var lValueType = ApplyLValueAnnotations(type, annotations);
10798var lvalueType = variable.Type;
10850AreNullableAndUnderlyingTypes(lvalueType.Type, operandType.Type, out TypeWithAnnotations underlyingType))
10866internal readonly TypeWithAnnotations Type;
10869internal DeconstructionVariable(BoundExpression expression, TypeWithAnnotations type)
11017var operandLvalue = LvalueResultType;
11032TypeWithAnnotations targetTypeOfOperandConversion;
11048targetTypeOfOperandConversion = TypeWithAnnotations.Create(MakeNullableOf(targetTypeOfOperandConversion));
11094var operandTypeWithAnnotations = operandType.ToTypeWithAnnotations(compilation);
11202var leftLvalueType = LvalueResultType;
11308private TypeWithAnnotations GetDeclaredLocalResult(LocalSymbol local)
11310return _variables.TryGetType(local, out TypeWithAnnotations type) ?
11315private TypeWithAnnotations GetDeclaredParameterResult(ParameterSymbol parameter)
11317return _variables.TryGetType(parameter, out TypeWithAnnotations type) ?
11366TypeWithAnnotations typeWithAnnotations = GetTypeOrReturnTypeWithAnnotations(updatedProperty);
11482var type = GetTypeOrReturnTypeWithAnnotations(member);
11603TypeWithAnnotations targetTypeWithAnnotations;
11642targetTypeWithAnnotations = TypeWithAnnotations.Create(collectionExpression.Type);
11649targetTypeWithAnnotations = TypeWithAnnotations.Create(ForEachLoopBinder.GetIEnumerableOfT(resultType, isAsync, compilation, ref discardedUseSiteInfo, out bool foundMultiple, needSupportForRefStructInterfaces: out _));
11703TypeWithAnnotations.Create(enumeratorInfoOpt.ElementType, NullableAnnotation.NotAnnotated).ToTypeWithState();
11784TypeWithAnnotations sourceType = sourceState.ToTypeWithAnnotations(compilation);
11813TypeWithAnnotations destinationType = iterationVariable.TypeWithAnnotations;
11911var type = TypeWithAnnotations.Create(node.Type);
12051var type = TypeWithAnnotations.Create(node.Type);
12059var type = TypeWithAnnotations.Create(node.Type);
12081var type = TypeWithAnnotations.Create(node.Type, node.NullableAnnotation);
12474var result = TypeWithAnnotations.Create(node.Type);
12494var result = TypeWithAnnotations.Create(node.Type, NullableAnnotation.Oblivious);
12600var result = TypeWithAnnotations.Create(node.Type, NullableAnnotation.Oblivious);
12669private static bool IsNullabilityMismatch(TypeWithAnnotations type1, TypeWithAnnotations type2)
12771var result = TypeWithAnnotations.Create(node.Type, node.IsInferred ? NullableAnnotation.Annotated : node.NullableAnnotation);
12815TypeWithAnnotations elementType = InMethodBinder.GetIteratorElementTypeFromReturnType(compilation, RefKind.None,
12868var typeWithAnnotations = TypeWithAnnotations.Create(node.Type, node.NullableAnnotation);
12933var returnTypeWithAnnotations = node.FunctionPointer.Signature.ReturnTypeWithAnnotations;
FlowAnalysis\NullableWalker.Variables.cs (7)
48internal readonly ImmutableDictionary<Symbol, TypeWithAnnotations> VariableTypes;
50internal VariablesSnapshot(int id, VariablesSnapshot? container, Symbol? symbol, ImmutableArray<KeyValuePair<VariableIdentifier, int>> variableSlot, ImmutableDictionary<Symbol, TypeWithAnnotations> variableTypes)
59internal bool TryGetType(Symbol symbol, out TypeWithAnnotations type)
128private readonly PooledDictionary<Symbol, TypeWithAnnotations> _variableTypes = SpecializedSymbolCollections.GetPooledSymbolDictionaryInstance<Symbol, TypeWithAnnotations>();
297internal bool TryGetType(Symbol symbol, out TypeWithAnnotations type)
303internal void SetType(Symbol symbol, TypeWithAnnotations type)
FlowAnalysis\NullableWalker_Patterns.cs (19)
387var expressionTypeWithAnnotations = expressionTypeWithState.ToTypeWithAnnotations(compilation);
451var parameterType = method.Parameters[i + extensionExtra].TypeWithAnnotations;
476outputSlot = makeDagTempSlot(TypeWithAnnotations.Create(e.Type, NullableAnnotation.NotAnnotated), output);
489var type = field.TypeWithAnnotations;
537var type = property.TypeWithAnnotations;
562TypeWithAnnotations type = getIndexerOutputType(inputType, e.IndexerAccess, isSlice: false);
574TypeWithAnnotations type = getIndexerOutputType(inputType, e.IndexerAccess, isSlice: true);
686var inferredType = value.ToTypeWithAnnotations(compilation, asAnnotatedType: boundLocal.DeclarationKind == BoundLocalDeclarationKind.WithInferredType);
687if (_variables.TryGetType(local, out var existingType))
690inferredType = TypeWithAnnotations.Create(inferredType.Type, existingType.NullableAnnotation.Join(inferredType.NullableAnnotation));
833int makeDagTempSlot(TypeWithAnnotations type, BoundDagTemp temp)
841var type = TypeWithAnnotations.Create(t, NullableAnnotation.Annotated);
848static TypeWithAnnotations getIndexerOutputType(TypeSymbol inputType, BoundExpression e, bool isSlice)
856? TypeWithAnnotations.Create(isNullableEnabled: true, inputType, isAnnotated: false)
957var inferredTypeWithAnnotations = TypeWithAnnotations.Create(inferredType);
993TypeWithAnnotations inferredTypeWithAnnotations,
1040(TypeWithAnnotations inferredTypeWithAnnotations) =>
Generated\BoundNodes.xml.Generated.cs (9)
1050public BoundTypeExpression(SyntaxNode syntax, AliasSymbol? aliasOpt, BoundTypeExpression? boundContainingTypeOpt, ImmutableArray<BoundExpression> boundDimensionsOpt, TypeWithAnnotations typeWithAnnotations, TypeSymbol type, bool hasErrors = false)
1066public TypeWithAnnotations TypeWithAnnotations { get; }
1071public BoundTypeExpression Update(AliasSymbol? aliasOpt, BoundTypeExpression? boundContainingTypeOpt, ImmutableArray<BoundExpression> boundDimensionsOpt, TypeWithAnnotations typeWithAnnotations, TypeSymbol type)
5829public BoundDynamicMemberAccess(SyntaxNode syntax, BoundExpression receiver, ImmutableArray<TypeWithAnnotations> typeArgumentsOpt, string name, bool invoked, bool indexed, TypeSymbol type, bool hasErrors = false)
5846public ImmutableArray<TypeWithAnnotations> TypeArgumentsOpt { get; }
5854public BoundDynamicMemberAccess Update(BoundExpression receiver, ImmutableArray<TypeWithAnnotations> typeArgumentsOpt, string name, bool invoked, bool indexed, TypeSymbol type)
6066public BoundMethodGroup(SyntaxNode syntax, ImmutableArray<TypeWithAnnotations> typeArgumentsOpt, string name, ImmutableArray<MethodSymbol> methods, Symbol? lookupSymbolOpt, DiagnosticInfo? lookupError, BoundMethodGroupFlags? flags, FunctionTypeSymbol? functionType, BoundExpression? receiverOpt, LookupResultKind resultKind, bool hasErrors = false)
6082public ImmutableArray<TypeWithAnnotations> TypeArgumentsOpt { get; }
6093public BoundMethodGroup Update(ImmutableArray<TypeWithAnnotations> typeArgumentsOpt, string name, ImmutableArray<MethodSymbol> methods, Symbol? lookupSymbolOpt, DiagnosticInfo? lookupError, BoundMethodGroupFlags? flags, FunctionTypeSymbol? functionType, BoundExpression? receiverOpt, LookupResultKind resultKind)
Lowering\AsyncRewriter\AsyncExceptionHandlerRewriter.cs (5)
187var pendingExceptionLocal = new SynthesizedLocal(_F.CurrentFunction, TypeWithAnnotations.Create(exceptionType), SynthesizedLocalKind.TryAwaitPendingException, tryStatementSyntax);
189var pendingBranchVar = new SynthesizedLocal(_F.CurrentFunction, TypeWithAnnotations.Create(_F.SpecialType(SpecialType.System_Int32)), SynthesizedLocalKind.TryAwaitPendingBranch, tryStatementSyntax);
1008this.returnValue = returnValue = new SynthesizedLocal(containingMethod, TypeWithAnnotations.Create(valueOpt.Type), SynthesizedLocalKind.AsyncMethodReturnValue, _syntaxOpt);
1044this.pendingCaughtException = new SynthesizedLocal(F.CurrentFunction, TypeWithAnnotations.Create(F.SpecialType(SpecialType.System_Object)), SynthesizedLocalKind.TryAwaitPendingCaughtException, tryStatementSyntax);
1045this.pendingCatch = new SynthesizedLocal(F.CurrentFunction, TypeWithAnnotations.Create(F.SpecialType(SpecialType.System_Int32)), SynthesizedLocalKind.TryAwaitPendingCatch, tryStatementSyntax);
Lowering\ClosureConversion\ClosureConversion.cs (11)
667var frameTypeParameters = ImmutableArray.Create(_currentTypeParameters.SelectAsArray(t => TypeWithAnnotations.Create(t)), 0, frame.Arity);
671LocalSymbol framePointer = new SynthesizedLocal(_topLevelMethod, TypeWithAnnotations.Create(frameType), SynthesizedLocalKind.LambdaDisplayClass, frame.ScopeSyntaxOpt);
965private ImmutableArray<TypeWithAnnotations> SubstituteTypeArguments(ImmutableArray<TypeWithAnnotations> typeArguments)
989var builder = ArrayBuilder<TypeWithAnnotations>.GetInstance(typeArguments.Length);
990foreach (var typeArg in typeArguments)
992TypeWithAnnotations oldTypeArg;
993TypeWithAnnotations newTypeArg = typeArg;
1018ImmutableArray<TypeWithAnnotations> typeArgumentsOpt,
1030var realTypeArguments = ImmutableArray.Create(_currentTypeParameters.SelectAsArray(t => TypeWithAnnotations.Create(t)), 0, totalTypeArgumentCount - originalMethod.Arity);
1654RemapLambdaOrLocalFunction(node.Syntax, node.Symbol, default(ImmutableArray<TypeWithAnnotations>), closureKind, ref referencedMethod, out receiver, out constructedFrame);
Lowering\ClosureConversion\LambdaCapturedVariable.cs (6)
23private readonly TypeWithAnnotations _type;
26protected LambdaCapturedVariable(SynthesizedClosureEnvironment frame, TypeWithAnnotations type, string fieldName, bool isThisParameter)
54new LambdaCapturedVariableForRegularParameter(frame, TypeWithAnnotations.Create(type), fieldName, parameter) :
55new LambdaCapturedVariable(frame, TypeWithAnnotations.Create(type), fieldName, isThis);
143internal override TypeWithAnnotations GetFieldType(ConsList<FieldSymbol> fieldsBeingBound)
178public LambdaCapturedVariableForRegularParameter(SynthesizedClosureEnvironment frame, TypeWithAnnotations type, string fieldName, ParameterSymbol parameter)
Lowering\LocalRewriter\LocalRewriter_CollectionExpression.cs (12)
45if (ConversionsBase.IsSpanOrListType(_compilation, node.Type, WellKnownType.System_Collections_Generic_List_T, out var listElementType))
62return VisitArrayOrSpanCollectionExpression(node, collectionTypeKind, node.Type, TypeWithAnnotations.Create(elementType));
65if (ConversionsBase.IsSpanOrListType(_compilation, node.Type, WellKnownType.System_Collections_Immutable_ImmutableArray_T, out var arrayElementType))
159private bool TryRewriteSingleElementSpreadToList(BoundCollectionExpression node, TypeWithAnnotations listElementType, [NotNullWhen(true)] out BoundExpression? result)
234private BoundExpression VisitImmutableArrayCollectionExpression(BoundCollectionExpression node, TypeWithAnnotations elementType, MethodSymbol asImmutableArray)
245private BoundExpression VisitArrayOrSpanCollectionExpression(BoundCollectionExpression node, CollectionExpressionTypeKind collectionTypeKind, TypeSymbol collectionType, TypeWithAnnotations elementType)
404var elementType = collectionType.TypeArgumentsWithAnnotationsNoUseSiteDiagnostics.Single();
482var elementType = spanType.TypeArgumentsWithAnnotationsNoUseSiteDiagnostics[0];
541TypeWithAnnotations elementType,
575Construct(ImmutableArray.Create(TypeWithAnnotations.Create(inlineArrayType), elementType));
604inlineArrayAsSpan = inlineArrayAsSpan.Construct(ImmutableArray.Create(TypeWithAnnotations.Create(inlineArrayType), elementType));
1020private BoundExpression CreateAndPopulateList(BoundCollectionExpression node, TypeWithAnnotations elementType, ImmutableArray<BoundNode> elements)
Lowering\StateMachineRewriter\StateMachineFieldSymbol.cs (6)
23private readonly TypeWithAnnotations _type;
32public StateMachineFieldSymbol(NamedTypeSymbol stateMachineType, TypeWithAnnotations type, string name, bool isPublic, bool isThis)
44this(stateMachineType, TypeWithAnnotations.Create(type), name, slotDebugInfo, slotIndex, isPublic)
48public StateMachineFieldSymbol(NamedTypeSymbol stateMachineType, TypeWithAnnotations type, string name, LocalSlotDebugInfo slotDebugInfo, int slotIndex, bool isPublic)
68internal override TypeWithAnnotations GetFieldType(ConsList<FieldSymbol> fieldsBeingBound)
93public StateMachineFieldSymbolForRegularParameter(NamedTypeSymbol stateMachineType, TypeWithAnnotations type, string name, ParameterSymbol parameter, bool isPublic)
Lowering\SyntheticBoundNodeFactory.cs (11)
170public StateMachineFieldSymbol StateMachineField(TypeWithAnnotations type, string name, bool isPublic = false, bool isThis = false)
181var result = new StateMachineFieldSymbol(CurrentType, TypeWithAnnotations.Create(type), name, isPublic, isThis);
189var result = new StateMachineFieldSymbolForRegularParameter(CurrentType, TypeWithAnnotations.Create(type), name, parameter, isPublic);
608return new SynthesizedLocal(CurrentFunction, TypeWithAnnotations.Create(type), kind, syntax, isPinned,
628TypeWithAnnotations.Create(type),
639return SynthesizedParameterSymbol.Create(container, TypeWithAnnotations.Create(type), ordinal, RefKind.None, name);
1241public BoundExpression NullRef(TypeWithAnnotations type)
1292public BoundExpression Typeof(TypeWithAnnotations type, TypeSymbol systemType)
1297public ImmutableArray<BoundExpression> TypeOfs(ImmutableArray<TypeWithAnnotations> typeArguments, TypeSymbol systemType)
1700TypeWithAnnotations.Create(type),
1739temp = new SynthesizedLocal(this.CurrentFunction, TypeWithAnnotations.Create(node.Type), SynthesizedLocalKind.LoweringTemp);
Symbols\ArrayTypeSymbol.cs (24)
23private readonly TypeWithAnnotations _elementTypeWithAnnotations;
27TypeWithAnnotations elementTypeWithAnnotations,
39TypeWithAnnotations elementTypeWithAnnotations,
51TypeWithAnnotations elementTypeWithAnnotations,
68TypeWithAnnotations elementType,
77TypeWithAnnotations elementTypeWithAnnotations,
84TypeWithAnnotations elementTypeWithAnnotations,
93TypeWithAnnotations elementType)
98internal ArrayTypeSymbol WithElementType(TypeWithAnnotations elementTypeWithAnnotations)
103protected abstract ArrayTypeSymbol WithElementTypeCore(TypeWithAnnotations elementTypeWithAnnotations);
106TypeWithAnnotations elementTypeWithAnnotations,
202public TypeWithAnnotations ElementTypeWithAnnotations
396TypeWithAnnotations oldElementType = ElementTypeWithAnnotations;
397TypeWithAnnotations newElementType;
409internal override TypeSymbol SetNullabilityForReferenceTypes(Func<TypeWithAnnotations, TypeWithAnnotations> transform)
417TypeWithAnnotations elementType = ElementTypeWithAnnotations.MergeEquivalentTypes(((ArrayTypeSymbol)other).ElementTypeWithAnnotations, variance);
515TypeWithAnnotations elementTypeWithAnnotations,
524protected override ArrayTypeSymbol WithElementTypeCore(TypeWithAnnotations newElementType)
573TypeWithAnnotations elementTypeWithAnnotations,
607TypeWithAnnotations elementTypeWithAnnotations,
614protected override ArrayTypeSymbol WithElementTypeCore(TypeWithAnnotations elementTypeWithAnnotations)
634TypeWithAnnotations elementTypeWithAnnotations,
647protected override ArrayTypeSymbol WithElementTypeCore(TypeWithAnnotations elementTypeWithAnnotations)
Symbols\ConstraintsHelper.cs (32)
75ImmutableArray<TypeWithAnnotations> constraintTypes,
132ImmutableArray<TypeWithAnnotations> constraintTypes,
152var constraintTypesBuilder = ArrayBuilder<TypeWithAnnotations>.GetInstance();
159foreach (var constraintType in constraintTypes)
344internal static ImmutableArray<ImmutableArray<TypeWithAnnotations>> MakeTypeParameterConstraintTypes(
354return ImmutableArray<ImmutableArray<TypeWithAnnotations>>.Empty;
368return ImmutableArray<ImmutableArray<TypeWithAnnotations>>.Empty;
902ImmutableArray<TypeWithAnnotations> typeArguments,
953TypeWithAnnotations typeArgument,
1060TypeWithAnnotations typeArgument,
1086var constraintTypes = ArrayBuilder<TypeWithAnnotations>.GetInstance();
1088ImmutableArray<TypeWithAnnotations> originalConstraintTypes = typeParameter.ConstraintTypesWithDefinitionUseSiteDiagnostics(ref useSiteInfo);
1100foreach (var constraintType in constraintTypes)
1120static bool errorIfNotSatisfiesConstructorConstraint(Symbol containingSymbol, TypeParameterSymbol typeParameter, TypeWithAnnotations typeArgument, ArrayBuilder<TypeParameterDiagnosticInfo> diagnosticsBuilder)
1146TypeWithAnnotations typeArgument,
1170TypeWithAnnotations typeArgument,
1174TypeWithAnnotations constraintType,
1228static NullableFlowState getTypeArgumentState(in TypeWithAnnotations typeWithAnnotations)
1252foreach (var constraintType in typeParameter.ConstraintTypesNoUseSiteDiagnostics)
1267static bool constraintTypeAllows(in TypeWithAnnotations typeWithAnnotations, NullableFlowState state)
1289foreach (var constraintType in typeParameter.ConstraintTypesNoUseSiteDiagnostics)
1348TypeWithAnnotations typeArgument,
1349TypeWithAnnotations constraintType,
1398foreach (var typeArgumentConstraint in typeParameter.ConstraintTypesWithDefinitionUseSiteDiagnostics(ref useSiteInfo))
1441private static bool IsReferenceType(TypeParameterSymbol typeParameter, ImmutableArray<TypeWithAnnotations> constraintTypes)
1446private static bool IsValueType(TypeParameterSymbol typeParameter, ImmutableArray<TypeWithAnnotations> constraintTypes)
1635internal static TypeWithAnnotations ConstraintWithMostSignificantNullability(TypeWithAnnotations type1, TypeWithAnnotations type2)
1655internal static bool IsObjectConstraint(TypeWithAnnotations type, ref TypeWithAnnotations bestObjectConstraint)
1681internal static bool IsObjectConstraintSignificant(bool? isNotNullable, TypeWithAnnotations objectConstraint)
Symbols\FunctionPointers\FunctionPointerMethodSymbol.cs (35)
29TypeWithAnnotations returnType;
33returnType = TypeWithAnnotations.Create(typeBinder.CreateErrorType());
245TypeWithAnnotations returnType,
248ImmutableArray<TypeWithAnnotations> parameterTypes,
270TypeWithAnnotations returnTypeWithAnnotations,
272ImmutableArray<TypeWithAnnotations> parameterTypes,
334TypeWithAnnotations substitutedReturnType,
335ImmutableArray<TypeWithAnnotations> substitutedParameterTypes,
352var mergedReturnType = ReturnTypeWithAnnotations.MergeEquivalentTypes(signature.ReturnTypeWithAnnotations, returnVariance);
354var mergedParameterTypes = ImmutableArray<TypeWithAnnotations>.Empty;
358var paramMergedTypesBuilder = ArrayBuilder<TypeWithAnnotations>.GetInstance(_parameters.Length);
371var mergedParameterType = thisParam.TypeWithAnnotations.MergeEquivalentTypes(otherParam.TypeWithAnnotations, paramVariance);
400public FunctionPointerMethodSymbol SetNullabilityForReferenceTypes(Func<TypeWithAnnotations, TypeWithAnnotations> transform)
402var transformedReturn = transform(ReturnTypeWithAnnotations);
404var transformedParameterTypes = ImmutableArray<TypeWithAnnotations>.Empty;
408var paramTypesBuilder = ArrayBuilder<TypeWithAnnotations>.GetInstance(_parameters.Length);
411var transformedType = transform(param.TypeWithAnnotations);
444TypeWithAnnotations returnType,
447ImmutableArray<TypeWithAnnotations> substitutedParameterTypes,
465var substitutedType = substitutedParameterTypes[i];
489TypeWithAnnotations returnTypeWithAnnotations,
491ImmutableArray<TypeWithAnnotations> parameterTypes,
520TypeWithAnnotations returnType,
548var returnType = TypeWithAnnotations.Create(retInfo.Type, customModifiers: CSharpCustomModifier.Convert(retInfo.CustomModifiers));
568var paramType = TypeWithAnnotations.Create(param.Type, customModifiers: CSharpCustomModifier.Convert(param.CustomModifiers));
605bool madeChanges = ReturnTypeWithAnnotations.ApplyNullableTransforms(defaultTransformFlag, transforms, ref position, out var newReturnType);
606var newParamTypes = ImmutableArray<TypeWithAnnotations>.Empty;
609var paramTypesBuilder = ArrayBuilder<TypeWithAnnotations>.GetInstance(Parameters.Length);
613madeParamChanges |= param.TypeWithAnnotations.ApplyNullableTransforms(defaultTransformFlag, transforms, ref position, out var newParamType);
768public override TypeWithAnnotations ReturnTypeWithAnnotations { get; }
836public override ImmutableArray<TypeWithAnnotations> TypeArgumentsWithAnnotations => ImmutableArray<TypeWithAnnotations>.Empty;
Symbols\Metadata\PE\PETypeParameterSymbol.cs (19)
44private ImmutableArray<TypeWithAnnotations> _lazyDeclaredConstraintTypes;
151private ImmutableArray<TypeWithAnnotations> GetDeclaredConstraintTypes(ConsList<PETypeParameterSymbol> inProgress)
158ImmutableArray<TypeWithAnnotations> declaredConstraintTypes;
168var symbolsBuilder = ArrayBuilder<TypeWithAnnotations>.GetInstance();
171TypeWithAnnotations bestObjectConstraint = default;
176TypeWithAnnotations type = GetConstraintTypeOrDefault(moduleSymbol, metadataReader, tokenDecoder, constraintHandle, ref hasUnmanagedModreqPattern);
209foreach (TypeWithAnnotations constraintType in symbolsBuilder)
230declaredConstraintTypes = ImmutableArray<TypeWithAnnotations>.Empty;
265private TypeWithAnnotations GetConstraintTypeOrDefault(PEModuleSymbol moduleSymbol, MetadataReader metadataReader, MetadataDecoder tokenDecoder, GenericParameterConstraintHandle constraintHandle, ref bool hasUnmanagedModreqPattern)
303var type = TypeWithAnnotations.Create(typeSymbol);
309private static bool? IsNotNullableFromConstraintType(TypeWithAnnotations constraintType, ConsList<PETypeParameterSymbol> inProgress, out bool isNonNullableValueType)
354ImmutableArray<TypeWithAnnotations> constraintTypes = this.GetDeclaredConstraintTypes(inProgress);
380private static bool? IsNotNullableFromConstraintTypes(ImmutableArray<TypeWithAnnotations> constraintTypes, ConsList<PETypeParameterSymbol> inProgress, out bool isNonNullableValueType)
386foreach (TypeWithAnnotations constraintType in constraintTypes)
537var symbolsBuilder = ArrayBuilder<TypeWithAnnotations>.GetInstance();
544TypeWithAnnotations type = GetConstraintTypeOrDefault(moduleSymbol, metadataReader, tokenDecoder, constraintHandle, ref hasUnmanagedModreqPattern);
616internal override ImmutableArray<TypeWithAnnotations> GetConstraintTypes(ConsList<TypeParameterSymbol> inProgress)
619return (bounds != null) ? bounds.ConstraintTypes : ImmutableArray<TypeWithAnnotations>.Empty;
Symbols\Retargeting\RetargetingSymbolTranslator.cs (20)
180public TypeWithAnnotations Retarget(TypeWithAnnotations underlyingType, RetargetOptions options, NamedTypeSymbol asDynamicIfNoPiaContainingType = null)
515var oldArguments = ArrayBuilder<TypeWithAnnotations>.GetInstance();
534var newArguments = ArrayBuilder<TypeWithAnnotations>.GetInstance(oldArguments.Count);
536foreach (var arg in oldArguments)
538var newArg = Retarget(arg, RetargetOptions.RetargetPrimitiveTypesByTypeCode); // generic instantiation is a signature
595private bool IsNoPiaIllegalGenericInstantiation(ArrayBuilder<TypeWithAnnotations> oldArguments, ArrayBuilder<TypeWithAnnotations> newArguments, int startOfNonInterfaceArguments)
671foreach (var argument in namedType.TypeArgumentsWithAnnotationsNoUseSiteDiagnostics)
697TypeWithAnnotations oldElement = type.ElementTypeWithAnnotations;
698TypeWithAnnotations newElement = Retarget(oldElement, RetargetOptions.RetargetPrimitiveTypesByTypeCode);
748TypeWithAnnotations oldPointed = type.PointedAtTypeWithAnnotations;
749TypeWithAnnotations newPointed = Retarget(oldPointed, RetargetOptions.RetargetPrimitiveTypesByTypeCode);
762var newReturn = Retarget(signature.ReturnTypeWithAnnotations, RetargetOptions.RetargetPrimitiveTypesByTypeCode);
766var newParameterTypes = ImmutableArray<TypeWithAnnotations>.Empty;
772var newParameterTypesBuilder = ArrayBuilder<TypeWithAnnotations>.GetInstance(paramCount);
778var newParameterType = Retarget(parameter.TypeWithAnnotations, RetargetOptions.RetargetPrimitiveTypesByTypeCode);
860public ImmutableArray<TypeWithAnnotations> Retarget(ImmutableArray<TypeWithAnnotations> sequence)
1112var targetType = Retarget(@event.TypeWithAnnotations, RetargetOptions.RetargetPrimitiveTypesByTypeCode);
Symbols\Source\LocalFunctionOrSourceMemberMethodSymbol.cs (8)
12private TypeWithAnnotations.Boxed? _lazyIteratorElementType;
19_lazyIteratorElementType = TypeWithAnnotations.Boxed.Sentinel;
23internal sealed override TypeWithAnnotations IteratorElementTypeWithAnnotations
27if (_lazyIteratorElementType == TypeWithAnnotations.Boxed.Sentinel)
29TypeWithAnnotations elementType = InMethodBinder.GetIteratorElementTypeFromReturnType(DeclaringCompilation, RefKind, ReturnType, errorLocation: null, diagnostics: null);
33elementType = TypeWithAnnotations.Create(new ExtendedErrorTypeSymbol(DeclaringCompilation, name: "", arity: 0, errorInfo: null, unreported: false));
36Interlocked.CompareExchange(ref _lazyIteratorElementType, new TypeWithAnnotations.Boxed(elementType), TypeWithAnnotations.Boxed.Sentinel);
Symbols\Source\ParameterHelpers.cs (7)
41parameterCreationFunc: static (Binder context, Symbol owner, TypeWithAnnotations parameterType,
70var parameterCreationFunc = static (Binder context, Symbol owner, TypeWithAnnotations parameterType,
133parameterCreationFunc: static (Binder binder, FunctionPointerMethodSymbol owner, TypeWithAnnotations parameterType,
177Func<Binder, TOwningSymbol, TypeWithAnnotations, TParameterSyntax, RefKind, int, SyntaxToken, SyntaxToken, bool, ScopedKind, BindingDiagnosticBag, TParameterSymbol> parameterCreationFunc,
257Func<Binder, TOwningSymbol, TypeWithAnnotations, TParameterSyntax, RefKind, int, SyntaxToken, SyntaxToken, bool, ScopedKind, BindingDiagnosticBag, TParameterSymbol> parameterCreationFunc,
308var parameterType = withTypeParametersBinder.BindType(parameterSyntax.Type, diagnostics, suppressUseSiteDiagnostics: suppressUseSiteDiagnostics);
830TypeWithAnnotations typeWithAnnotations,
Symbols\Source\SourceDelegateMethodSymbol.cs (24)
21private readonly TypeWithAnnotations _returnType;
25TypeWithAnnotations returnType,
57var returnType = binder.BindType(returnTypeSyntax, diagnostics);
60var voidType = TypeWithAnnotations.Create(binder.GetSpecialType(SpecialType.System_Void, diagnostics, syntax));
62var objectType = TypeWithAnnotations.Create(binder.GetSpecialType(SpecialType.System_Object, diagnostics, syntax));
63var intPtrType = TypeWithAnnotations.Create(binder.GetSpecialType(SpecialType.System_IntPtr, diagnostics, syntax));
85var iAsyncResultType = TypeWithAnnotations.Create(binder.GetSpecialType(SpecialType.System_IAsyncResult, diagnostics, syntax));
86var asyncCallbackType = TypeWithAnnotations.Create(binder.GetSpecialType(SpecialType.System_AsyncCallback, diagnostics, syntax));
153public override ImmutableArray<ImmutableArray<TypeWithAnnotations>> GetTypeParameterConstraintTypes()
154=> ImmutableArray<ImmutableArray<TypeWithAnnotations>>.Empty;
159public sealed override TypeWithAnnotations ReturnTypeWithAnnotations
214TypeWithAnnotations voidType,
215TypeWithAnnotations objectType,
216TypeWithAnnotations intPtrType,
259TypeWithAnnotations returnType,
352TypeWithAnnotations iAsyncResultType,
353TypeWithAnnotations objectType,
354TypeWithAnnotations asyncCallbackType,
392TypeWithAnnotations iAsyncResultType,
Symbols\Source\SourceMemberContainerSymbol.cs (13)
4887TypeWithAnnotations.Create(compilation.GetSpecialType(SpecialType.System_Void)),
4926TypeWithAnnotations.Create(this),
4935TypeWithAnnotations.Create(compilation.GetSpecialType(SpecialType.System_Void)),
4979TypeWithAnnotations.Create(compilation.GetWellKnownType(WellKnownType.System_Text_StringBuilder)),
4987returnType: TypeWithAnnotations.Create(compilation.GetSpecialType(SpecialType.System_Boolean)),
5042returnType: TypeWithAnnotations.Create(compilation.GetSpecialType(SpecialType.System_String)),
5216TypeWithAnnotations.Create(compilation.GetSpecialType(SpecialType.System_Int32)),
5245TypeWithAnnotations.Create(compilation.GetWellKnownType(WellKnownType.System_Type)),
5306TypeWithAnnotations.Create(this),
5315TypeWithAnnotations.Create(compilation.GetSpecialType(SpecialType.System_Boolean)),
5886builder.AddValue(TypeWithAnnotations.Create(baseType));
5890builder.AddValue(TypeWithAnnotations.Create(@interface));
5950AddSynthesizedAttribute(ref attributes, moduleBuilder.SynthesizeNullableAttributeIfNecessary(this, nullableContextValue, TypeWithAnnotations.Create(baseType)));
Symbols\Source\SourceNamedTypeSymbol.cs (24)
269internal ImmutableArray<TypeWithAnnotations> GetTypeParameterConstraintTypes(int ordinal)
272return (constraintTypes.Length > 0) ? constraintTypes[ordinal] : ImmutableArray<TypeWithAnnotations>.Empty;
275private ImmutableArray<ImmutableArray<TypeWithAnnotations>> GetTypeParameterConstraintTypes()
317private ImmutableArray<ImmutableArray<TypeWithAnnotations>> MakeTypeParameterConstraintTypes(BindingDiagnosticBag diagnostics)
512ImmutableArray<TypeWithAnnotations> originalConstraintTypes = constraint.ConstraintTypes;
513ArrayBuilder<TypeWithAnnotations> mergedConstraintTypes = null;
514SmallDictionary<TypeWithAnnotations, int> originalConstraintTypesMap = null;
561static bool mergeConstraints(ImmutableArray<TypeWithAnnotations> originalConstraintTypes,
562ref SmallDictionary<TypeWithAnnotations, int> originalConstraintTypesMap, ref ArrayBuilder<TypeWithAnnotations> mergedConstraintTypes,
582TypeWithAnnotations.EqualsComparer.IgnoreNullableModifiersForReferenceTypesComparer);
583SmallDictionary<TypeWithAnnotations, int> clauseConstraintTypesMap = toDictionary(clause.ConstraintTypes, originalConstraintTypesMap.Comparer);
587TypeWithAnnotations constraintType1 = mergedConstraintTypes?[index1] ?? originalConstraintTypes[index1];
597TypeWithAnnotations constraintType2 = clause.ConstraintTypes[index2];
611mergedConstraintTypes = ArrayBuilder<TypeWithAnnotations>.GetInstance(originalConstraintTypes.Length);
619foreach (var constraintType in clauseConstraintTypesMap.Keys)
631static SmallDictionary<TypeWithAnnotations, int> toDictionary(ImmutableArray<TypeWithAnnotations> constraintTypes, IEqualityComparer<TypeWithAnnotations> comparer)
633var result = new SmallDictionary<TypeWithAnnotations, int>(comparer);
666ImmutableArray<TypeWithAnnotations> originalConstraintTypes = constraint.ConstraintTypes;
699static void mergeConstraints(ref TypeParameterConstraintKind mergedKind, ImmutableArray<TypeWithAnnotations> originalConstraintTypes, TypeParameterConstraintClause clause)
740internal sealed override ImmutableArray<TypeWithAnnotations> TypeArgumentsWithAnnotationsNoUseSiteDiagnostics
1926TypeWithAnnotations elementType = elementField.TypeWithAnnotations;
Symbols\Synthesized\Records\SynthesizedRecordObjEquals.cs (3)
26protected override (TypeWithAnnotations ReturnType, ImmutableArray<ParameterSymbol> Parameters)
32return (ReturnType: TypeWithAnnotations.Create(Binder.GetSpecialType(compilation, SpecialType.System_Boolean, location, diagnostics)),
35TypeWithAnnotations.Create(Binder.GetSpecialType(compilation, SpecialType.System_Object, location, diagnostics), annotation),
Symbols\Synthesized\Records\SynthesizedRecordPrintMembers.cs (3)
89protected override (TypeWithAnnotations ReturnType, ImmutableArray<ParameterSymbol> Parameters) MakeParametersAndBindReturnType(BindingDiagnosticBag diagnostics)
94return (ReturnType: TypeWithAnnotations.Create(Binder.GetSpecialType(compilation, SpecialType.System_Boolean, location, diagnostics)),
97TypeWithAnnotations.Create(Binder.GetWellKnownType(compilation, WellKnownType.System_Text_StringBuilder, diagnostics, location), annotation),
Symbols\Synthesized\SynthesizedDelegateSymbol.cs (8)
21SynthesizedParameterSymbol.Create(this, TypeWithAnnotations.Create(objectType), 0, RefKind.None, "object"),
22SynthesizedParameterSymbol.Create(this, TypeWithAnnotations.Create(intPtrType), 1, RefKind.None, "method"));
35internal ParameterDescription(TypeWithAnnotations type, RefKind refKind, ScopedKind scope, ConstantValue? defaultValue, bool isParams, bool hasUnscopedRefAttribute)
45internal readonly TypeWithAnnotations Type;
58TypeWithAnnotations returnType,
165public override TypeWithAnnotations ReturnTypeWithAnnotations { get; }
171public override ImmutableArray<TypeWithAnnotations> TypeArgumentsWithAnnotations
173get { return ImmutableArray<TypeWithAnnotations>.Empty; }
Symbols\Synthesized\SynthesizedEntryPointSymbol.cs (14)
44return new ScriptEntryPoint(containingType, TypeWithAnnotations.Create(systemVoid));
125public override ImmutableArray<TypeWithAnnotations> TypeArgumentsWithAnnotations
127get { return ImmutableArray<TypeWithAnnotations>.Empty; }
394public override TypeWithAnnotations ReturnTypeWithAnnotations => TypeWithAnnotations.Create(_getAwaiterGetResultCall.Type);
446private readonly TypeWithAnnotations _returnType;
448internal ScriptEntryPoint(NamedTypeSymbol containingType, TypeWithAnnotations returnType) :
460public override TypeWithAnnotations ReturnTypeWithAnnotations => _returnType;
486new SynthesizedLocal(this, TypeWithAnnotations.Create(_containingType), SynthesizedLocalKind.LoweringTemp),
535private readonly TypeWithAnnotations _returnType;
537internal SubmissionEntryPoint(NamedTypeSymbol containingType, TypeWithAnnotations returnType, TypeSymbol submissionArrayType) :
543TypeWithAnnotations.Create(submissionArrayType), 0, RefKind.None, "submissionArray"));
558public override TypeWithAnnotations ReturnTypeWithAnnotations => _returnType;
578new SynthesizedLocal(this, TypeWithAnnotations.Create(_containingType), SynthesizedLocalKind.LoweringTemp),
Symbols\TypeMap.cs (21)
23public static readonly Func<TypeWithAnnotations, TypeSymbol> AsTypeSymbol = t => t.Type;
25internal static ImmutableArray<TypeWithAnnotations> TypeParametersAsTypeSymbolsWithAnnotations(ImmutableArray<TypeParameterSymbol> typeParameters)
27return typeParameters.SelectAsArray(static (tp) => TypeWithAnnotations.Create(tp));
30internal static ImmutableArray<TypeWithAnnotations> TypeParametersAsTypeSymbolsWithIgnoredAnnotations(ImmutableArray<TypeParameterSymbol> typeParameters)
32return typeParameters.SelectAsArray(static (tp) => TypeWithAnnotations.Create(tp, NullableAnnotation.Ignored));
35internal static ImmutableArray<TypeSymbol> AsTypeSymbols(ImmutableArray<TypeWithAnnotations> typesOpt)
41internal TypeMap(ImmutableArray<TypeParameterSymbol> from, ImmutableArray<TypeWithAnnotations> to, bool allowAlpha = false)
55private TypeMap(SmallDictionary<TypeParameterSymbol, TypeWithAnnotations> mapping)
56: base(new SmallDictionary<TypeParameterSymbol, TypeWithAnnotations>(mapping, ReferenceEqualityComparer.Instance))
61private static SmallDictionary<TypeParameterSymbol, TypeWithAnnotations> ForType(NamedTypeSymbol containingType)
65new SmallDictionary<TypeParameterSymbol, TypeWithAnnotations>(substituted.TypeSubstitution.Mapping, ReferenceEqualityComparer.Instance) :
66new SmallDictionary<TypeParameterSymbol, TypeWithAnnotations>(ReferenceEqualityComparer.Instance);
69internal TypeMap(NamedTypeSymbol containingType, ImmutableArray<TypeParameterSymbol> typeParameters, ImmutableArray<TypeWithAnnotations> typeArguments)
75TypeWithAnnotations ta = typeArguments[i];
83private static readonly SmallDictionary<TypeParameterSymbol, TypeWithAnnotations> s_emptyDictionary =
84new SmallDictionary<TypeParameterSymbol, TypeWithAnnotations>(ReferenceEqualityComparer.Instance);
129result.Mapping.Add(tp, TypeWithAnnotations.Create(newTp));
193private static SmallDictionary<TypeParameterSymbol, TypeWithAnnotations> ConstructMapping(ImmutableArray<TypeParameterSymbol> from, ImmutableArray<TypeWithAnnotations> to)
195var mapping = new SmallDictionary<TypeParameterSymbol, TypeWithAnnotations>(ReferenceEqualityComparer.Instance);
202TypeWithAnnotations ta = to[i];
Symbols\TypeSymbolExtensions.cs (32)
121foreach (var constraintType in constraintTypes)
171public static TypeWithAnnotations GetNullableUnderlyingTypeWithAnnotations(this TypeSymbol type)
379internal static bool IsArrayInterface(this TypeSymbol type, out TypeWithAnnotations typeArgument)
597public static bool TryGetElementTypesWithAnnotationsIfTupleType(this TypeSymbol type, out ImmutableArray<TypeWithAnnotations> elementTypes)
606elementTypes = default(ImmutableArray<TypeWithAnnotations>);
748/// <param name="useDefaultType">If true, use <see cref="TypeWithAnnotations.DefaultType"/>
749/// instead of <see cref="TypeWithAnnotations.Type"/> to avoid early resolution of nullable types</param>
751this TypeWithAnnotations typeWithAnnotationsOpt,
753Func<TypeWithAnnotations, T, bool, bool>? typeWithAnnotationsPredicate,
831TypeWithAnnotations next;
871(TypeWithAnnotations nextTypeWithAnnotations, TypeSymbol? nextType) = getNextIterationElements(fields[i].TypeWithAnnotations, canDigThroughNullable);
902(TypeWithAnnotations nextTypeWithAnnotations, TypeSymbol? nextType) = getNextIterationElements(typeArguments[i], canDigThroughNullable);
951static (TypeWithAnnotations, TypeSymbol?) getNextIterationElements(TypeWithAnnotations type, bool canDigThroughNullable)
952=> canDigThroughNullable ? (default(TypeWithAnnotations), type.NullableUnderlyingTypeOrSelf) : (type, null);
954static TypeSymbol? visitFunctionPointerType(FunctionPointerTypeSymbol type, Func<TypeWithAnnotations, T, bool, bool>? typeWithAnnotationsPredicate, Func<TypeSymbol, T, bool, bool>? typePredicate, T arg, bool useDefaultType, bool canDigThroughNullable, bool visitCustomModifiers, out TypeWithAnnotations next)
981(TypeWithAnnotations nextTypeWithAnnotations, TypeSymbol? nextType) = getNextIterationElements(currentPointer.Parameters[i].TypeWithAnnotations, canDigThroughNullable);
1254internal static bool ContainsNativeIntegerWrapperType(this TypeWithAnnotations type)
1597foreach (var arg in type.TypeArgumentsWithAnnotationsNoUseSiteDiagnostics)
1953private static bool NormalizeTaskTypesInType(CSharpCompilation compilation, ref TypeWithAnnotations typeWithAnnotations)
1958typeWithAnnotations = TypeWithAnnotations.Create(type, customModifiers: typeWithAnnotations.CustomModifiers);
1971var typeArgumentsBuilder = ArrayBuilder<TypeWithAnnotations>.GetInstance();
1976var typeWithModifier = typeArgumentsBuilder[i];
1982typeArgumentsBuilder[i] = TypeWithAnnotations.Create(typeArgNormalized, customModifiers: typeWithModifier.CustomModifiers);
2022var elementType = arrayType.ElementTypeWithAnnotations;
2033var pointedAtType = pointerType.PointedAtTypeWithAnnotations;
2045var returnType = funcPtrType.Signature.ReturnTypeWithAnnotations;
2048var paramTypes = ImmutableArray<TypeWithAnnotations>.Empty;
2052var paramsBuilder = ArrayBuilder<TypeWithAnnotations>.GetInstance(funcPtrType.Signature.ParameterCount);
2056var paramType = param.TypeWithAnnotations;
2085this TypeWithAnnotations type,
Symbols\TypeUnification.cs (17)
30var substituted1 = SubstituteAllTypeParameters(substitution, TypeWithAnnotations.Create(t1));
31var substituted2 = SubstituteAllTypeParameters(substitution, TypeWithAnnotations.Create(t2));
41private static TypeWithAnnotations SubstituteAllTypeParameters(AbstractTypeMap? substitution, TypeWithAnnotations type)
45TypeWithAnnotations previous;
59return CanUnifyHelper(TypeWithAnnotations.Create(t1), TypeWithAnnotations.Create(t2), ref substitution);
79private static bool CanUnifyHelper(TypeWithAnnotations t1, TypeWithAnnotations t2, ref MutableTypeMap? substitution)
101TypeWithAnnotations tmp = t1;
207AddSubstitution(ref substitution, tp1, TypeWithAnnotations.Create(t2.Type));
215TypeWithAnnotations.Create(t2.Type,
234TypeWithAnnotations.Create(t1.Type,
249private static void AddSubstitution(ref MutableTypeMap? substitution, TypeParameterSymbol tp1, TypeWithAnnotations t2)
280foreach (TypeWithAnnotations typePart in typeParts)
Symbols\TypeWithAnnotations.cs (97)
29internal readonly TypeWithAnnotations Value;
30internal Boxed(TypeWithAnnotations value)
75internal static TypeWithAnnotations Create(bool isNullableEnabled, TypeSymbol typeSymbol, bool isAnnotated = false)
85internal static TypeWithAnnotations Create(TypeSymbol typeSymbol, NullableAnnotation nullableAnnotation = NullableAnnotation.Oblivious, ImmutableArray<CustomModifier> customModifiers = default)
108internal TypeWithAnnotations AsAnnotated()
118internal TypeWithAnnotations AsNotAnnotated()
168private static TypeWithAnnotations CreateNonLazyType(TypeSymbol typeSymbol, NullableAnnotation nullableAnnotation, ImmutableArray<CustomModifier> customModifiers)
173private static TypeWithAnnotations CreateLazyNullableTypeParameter(CSharpCompilation compilation, TypeWithAnnotations underlying)
178private static TypeWithAnnotations CreateLazySubstitutedType(TypeSymbol substitutedTypeSymbol, ImmutableArray<CustomModifier> customModifiers, TypeParameterSymbol typeParameter)
194public TypeWithAnnotations SetIsAnnotated(CSharpCompilation compilation)
222TypeWithAnnotations makeNullableT()
235private TypeWithAnnotations AsNullableReferenceType() => _extensions.AsNullableReferenceType(this);
236public TypeWithAnnotations AsNotNullableReferenceType() => _extensions.AsNotNullableReferenceType(this);
241internal TypeWithAnnotations MergeEquivalentTypes(TypeWithAnnotations other, VarianceKind variance)
250public TypeWithAnnotations WithModifiers(ImmutableArray<CustomModifier> customModifiers) =>
338public bool Equals(TypeWithAnnotations other, TypeCompareKind comparison)
390internal sealed class EqualsComparer : EqualityComparer<TypeWithAnnotations>
402public override int GetHashCode(TypeWithAnnotations obj)
411public override bool Equals(TypeWithAnnotations x, TypeWithAnnotations y)
421internal bool TypeSymbolEquals(TypeWithAnnotations other, TypeCompareKind comparison) =>
436public TypeWithAnnotations SubstituteType(AbstractTypeMap typeMap) =>
439internal TypeWithAnnotations SubstituteTypeCore(AbstractTypeMap typeMap)
446var newTypeWithModifiers = typeMap.SubstituteType(typeSymbol);
542private bool TypeSymbolEqualsCore(TypeWithAnnotations other, TypeCompareKind comparison)
567public TypeWithAnnotations WithTypeAndModifiers(TypeSymbol typeSymbol, ImmutableArray<CustomModifier> customModifiers) =>
570public TypeWithAnnotations WithType(TypeSymbol typeSymbol) =>
590TypeWithAnnotations typeWithAnnotationsOpt,
625private static void AddNullableTransforms(TypeWithAnnotations typeWithAnnotations, ArrayBuilder<byte> transforms)
661public bool ApplyNullableTransforms(byte defaultTransformFlag, ImmutableArray<byte> transforms, ref int position, out TypeWithAnnotations result)
724public TypeWithAnnotations WithTopLevelNonNullability()
735public TypeWithAnnotations SetUnknownNullabilityForReferenceTypes()
763return other is TypeWithAnnotations t && this.Equals(t, TypeCompareKind.ConsiderEverything);
781public static bool operator ==(TypeWithAnnotations? x, TypeWithAnnotations? y)
789public static bool operator !=(TypeWithAnnotations? x, TypeWithAnnotations? y)
795internal bool IsSameAs(TypeWithAnnotations other)
856internal abstract TypeWithAnnotations AsNullableReferenceType(TypeWithAnnotations type);
857internal abstract TypeWithAnnotations AsNotNullableReferenceType(TypeWithAnnotations type);
859internal abstract TypeWithAnnotations WithModifiers(TypeWithAnnotations type, ImmutableArray<CustomModifier> customModifiers);
873internal abstract TypeWithAnnotations WithTypeAndModifiers(TypeWithAnnotations type, TypeSymbol typeSymbol, ImmutableArray<CustomModifier> customModifiers);
875internal abstract bool TypeSymbolEquals(TypeWithAnnotations type, TypeWithAnnotations other, TypeCompareKind comparison);
876internal abstract TypeWithAnnotations SubstituteType(TypeWithAnnotations type, AbstractTypeMap typeMap);
877internal abstract void ReportDiagnosticsIfObsolete(TypeWithAnnotations type, Binder binder, SyntaxNode syntax, BindingDiagnosticBag diagnostics);
907internal override TypeWithAnnotations WithModifiers(TypeWithAnnotations type, ImmutableArray<CustomModifier> customModifiers)
914internal override TypeWithAnnotations WithTypeAndModifiers(TypeWithAnnotations type, TypeSymbol typeSymbol, ImmutableArray<CustomModifier> customModifiers)
919internal override TypeWithAnnotations AsNullableReferenceType(TypeWithAnnotations type)
924internal override TypeWithAnnotations AsNotNullableReferenceType(TypeWithAnnotations type)
930internal override bool TypeSymbolEquals(TypeWithAnnotations type, TypeWithAnnotations other, TypeCompareKind comparison)
935internal override TypeWithAnnotations SubstituteType(TypeWithAnnotations type, AbstractTypeMap typeMap)
940internal override void ReportDiagnosticsIfObsolete(TypeWithAnnotations type, Binder binder, SyntaxNode syntax, BindingDiagnosticBag diagnostics)
1012internal override TypeWithAnnotations WithModifiers(TypeWithAnnotations type, ImmutableArray<CustomModifier> customModifiers)
1017internal override TypeWithAnnotations WithTypeAndModifiers(TypeWithAnnotations type, TypeSymbol typeSymbol, ImmutableArray<CustomModifier> customModifiers)
1022internal override TypeWithAnnotations AsNullableReferenceType(TypeWithAnnotations type)
1027internal override TypeWithAnnotations AsNotNullableReferenceType(TypeWithAnnotations type)
1033internal override void ReportDiagnosticsIfObsolete(TypeWithAnnotations type, Binder binder, SyntaxNode syntax, BindingDiagnosticBag diagnostics)
1038internal override bool TypeSymbolEquals(TypeWithAnnotations type, TypeWithAnnotations other, TypeCompareKind comparison)
1043internal override TypeWithAnnotations SubstituteType(TypeWithAnnotations type, AbstractTypeMap typeMap)
1062private readonly TypeWithAnnotations _underlying;
1065public LazyNullableTypeParameter(CSharpCompilation compilation, TypeWithAnnotations underlying)
1112internal override TypeWithAnnotations WithModifiers(TypeWithAnnotations type, ImmutableArray<CustomModifier> customModifiers)
1122return TypeWithAnnotations.Create(resolvedType, type.NullableAnnotation, customModifiers: customModifiers);
1128internal override TypeWithAnnotations WithTypeAndModifiers(TypeWithAnnotations type, TypeSymbol typeSymbol, ImmutableArray<CustomModifier> customModifiers)
1132return TypeWithAnnotations.Create(typeSymbol, type.NullableAnnotation, customModifiers: customModifiers);
1138internal override TypeWithAnnotations AsNullableReferenceType(TypeWithAnnotations type)
1143internal override TypeWithAnnotations AsNotNullableReferenceType(TypeWithAnnotations type)
1152internal override TypeWithAnnotations SubstituteType(TypeWithAnnotations type, AbstractTypeMap typeMap)
1159var newUnderlying = _underlying.SubstituteTypeCore(typeMap);
1176internal override void ReportDiagnosticsIfObsolete(TypeWithAnnotations type, Binder binder, SyntaxNode syntax, BindingDiagnosticBag diagnostics)
1188internal override bool TypeSymbolEquals(TypeWithAnnotations type, TypeWithAnnotations other, TypeCompareKind comparison)