Binder\Binder.WithQueryLambdaParametersBinder.cs (1)
99var result = BindMemberOfType(node, node, name, 0, indexed: false, receiver, default(SeparatedSyntaxList<TypeSyntax>), default(ImmutableArray<TypeWithAnnotations>), lookupResult, BoundMethodGroupFlags.None, diagnostics);
Binder\Binder_Constraints.cs (10)
121ArrayBuilder<TypeWithAnnotations>? constraintTypes = null;
249constraintTypes = ArrayBuilder<TypeWithAnnotations>.GetInstance();
256var type = BindTypeOrConstraintKeyword(typeSyntax, diagnostics, out ConstraintContextualKeyword keyword);
347return (TypeParameterConstraintClause.Create(constraints, constraintTypes?.ToImmutableAndFree() ?? ImmutableArray<TypeWithAnnotations>.Empty), syntaxBuilder);
412var constraintTypeBuilder = ArrayBuilder<TypeWithAnnotations>.GetInstance();
417var constraintType = constraintTypes[i];
448TypeWithAnnotations constraintType,
485TypeWithAnnotations type,
487ArrayBuilder<TypeWithAnnotations> constraintTypes,
553static 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>),
751var declType = BindVariableTypeWithAnnotations(component.Designation, diagnostics, component.Type.SkipScoped(out _).SkipRef(), ref isConst, out isVar, out alias);
802TypeWithAnnotations declTypeWithAnnotations,
853TypeWithAnnotations declTypeWithAnnotations)
865TypeWithAnnotations declTypeWithAnnotations,
947var fieldType = field.GetFieldType(this.FieldsBeingBound);
Binder\Binder_Expressions.cs (49)
368var type = new PointerTypeSymbol(TypeWithAnnotations.Create(boundStackAlloc.ElementType));
929var declType = BindVariableTypeWithAnnotations(node.Designation, diagnostics, node.Type.SkipScoped(out _).SkipRef(), ref isConst, out isVar, out alias);
937private BoundExpression BindDeclarationVariablesForErrorRecovery(TypeWithAnnotations declTypeWithAnnotations, VariableDesignationSyntax node, CSharpSyntaxNode syntax, BindingDiagnosticBag diagnostics)
939declTypeWithAnnotations = declTypeWithAnnotations.HasType ? declTypeWithAnnotations : TypeWithAnnotations.Create(CreateErrorType("var"));
978subExpressions.SelectAsArray(e => TypeWithAnnotations.Create(e.Type)),
1013var elementTypesWithAnnotations = ArrayBuilder<TypeWithAnnotations>.GetInstance(arguments.Count);
1045var elementTypeWithAnnotations = TypeWithAnnotations.Create(boundArgument.Type);
1230TypeWithAnnotations typeWithAnnotations = BindType(node.Type, diagnostics);
1371TypeWithAnnotations typeWithAnnotations = typeofBinder.BindType(typeSyntax, diagnostics, out alias);
1395private void CheckDisallowedAttributeDependentType(TypeWithAnnotations typeArgument, NameSyntax attributeName, BindingDiagnosticBag diagnostics)
1424TypeWithAnnotations typeWithAnnotations = this.BindType(typeSyntax, diagnostics, out alias);
1480TypeWithAnnotations typeWithAnnotations = this.BindType(node.Type, diagnostics, out AliasSymbol alias);
1537default(ImmutableArray<TypeWithAnnotations>);
2499TypeWithAnnotations targetTypeWithAnnotations = this.BindType(node.Type, diagnostics);
2660private BoundExpression BindCastCore(ExpressionSyntax node, BoundExpression operand, TypeWithAnnotations targetTypeWithAnnotations, bool wasCompilerGenerated, BindingDiagnosticBag diagnostics)
2748var targetElementTypesWithAnnotations = default(ImmutableArray<TypeWithAnnotations>);
2808ImmutableArray<TypeWithAnnotations> targetElementTypesWithAnnotations)
2839private BoundExpression BindExplicitNullableCastFromNonNullable(ExpressionSyntax node, BoundExpression operand, TypeWithAnnotations targetTypeWithAnnotations, BindingDiagnosticBag diagnostics)
2847TypeWithAnnotations underlyingTargetTypeWithAnnotations = targetTypeWithAnnotations.Type.GetNullableUnderlyingTypeWithAnnotations();
3090var declType = BindVariableTypeWithAnnotations(designation, diagnostics, typeSyntax, ref isConst, out isVar, out alias);
3137var declType = BindVariableTypeWithAnnotations(declarationExpression, diagnostics, typeSyntax, ref isConst, out isVar, out alias);
3468TypeWithAnnotations parameterTypeWithAnnotations,
3568TypeWithAnnotations paramsElementTypeOpt = result.ParamsElementTypeOpt;
3625void reportUnsafeIfNeeded(MemberResolutionResult<TMember> methodResult, BindingDiagnosticBag diagnostics, BoundExpression argument, TypeWithAnnotations parameterTypeWithAnnotations)
4046var arrayType = ArrayTypeSymbol.CreateCSharpArray(Compilation.Assembly, TypeWithAnnotations.Create(bestType), rank);
4075type: GetStackAllocType(node, TypeWithAnnotations.Create(bestType), diagnostics, out bool hasErrors),
4421var elementType = arrayType.ElementTypeWithAnnotations;
4506private TypeSymbol GetStackAllocType(SyntaxNode node, TypeWithAnnotations elementTypeWithAnnotations, BindingDiagnosticBag diagnostics, out bool hasErrors)
5006typeArgumentsWithAnnotations: ImmutableArray<TypeWithAnnotations>.Empty,
5101var typeWithAnnotations = BindType(node.Type, diagnostics);
6555var finalApplicableCandidates = GetCandidatesPassingFinalValidation(node, overloadResolutionResult, receiverOpt: null, default(ImmutableArray<TypeWithAnnotations>), invokedAsExtensionMethod: false, diagnostics);
7445ImmutableArray<TypeWithAnnotations> typeArgumentsWithAnnotations = rightHasTypeArguments ?
7447default(ImmutableArray<TypeWithAnnotations>);
7462var typeArgument = typeArgumentsWithAnnotations[i];
7490/// <see cref="MakeQueryInvocation(CSharpSyntaxNode, BoundExpression, string, TypeSyntax, TypeWithAnnotations, BindingDiagnosticBag, string)"/>.
7565var typeArguments = typeArgumentsSyntax.Count > 0 ? BindTypeArguments(typeArgumentsSyntax, diagnostics) : default(ImmutableArray<TypeWithAnnotations>);
7661ImmutableArray<TypeWithAnnotations> typeArguments,
7735ImmutableArray<TypeWithAnnotations> typeArguments,
7831ImmutableArray<TypeWithAnnotations> typeArgumentsWithAnnotations,
8047default(ImmutableArray<TypeWithAnnotations>),
8129ImmutableArray<TypeWithAnnotations> typeArgumentsWithAnnotations,
8206typeWithAnnotations: TypeWithAnnotations.Create(type));
8245ImmutableArray<TypeWithAnnotations> typeArgumentsWithAnnotations,
8366ImmutableArray<TypeWithAnnotations> typeArgumentsWithAnnotations,
9664var finalApplicableCandidates = GetCandidatesPassingFinalValidation(syntax, overloadResolutionResult, receiver, default(ImmutableArray<TypeWithAnnotations>), invokedAsExtensionMethod: false, diagnostics);
10603TypeWithAnnotations? returnTypeOverride = null)
10608var returnType = returnTypeOverride ?? methodSymbol.ReturnTypeWithAnnotations;
10690static bool checkConstraints(CSharpCompilation compilation, ConversionsBase conversions, NamedTypeSymbol delegateType, ImmutableArray<TypeWithAnnotations> typeArguments)
Binder\Binder_Patterns.cs (12)
332declType: TypeWithAnnotations.Create(narrowedType, NullableAnnotation.NotAnnotated),
858TypeWithAnnotations declType = BindType(typeSyntax, diagnostics, out AliasSymbol aliasOpt);
867TypeWithAnnotations declType,
926private TypeWithAnnotations BindRecursivePatternType(
942return TypeWithAnnotations.Create(inputType.StrippedType(), NullableAnnotation.NotAnnotated);
973TypeWithAnnotations declTypeWithAnnotations = BindRecursivePatternType(typeSyntax, inputType, diagnostics, ref hasErrors, out BoundTypeExpression? boundDeclType);
988positionalClause, declType, ImmutableArray<TypeWithAnnotations>.Empty, permitDesignations, ref hasErrors, patternsBuilder, diagnostics);
1156ImmutableArray<TypeWithAnnotations> elementTypesWithAnnotations,
1357var declType = TypeWithState.ForType(inputType).ToTypeWithAnnotations(Compilation);
1384addSubpatternsForTuple(ImmutableArray<TypeWithAnnotations>.Empty);
1433void addSubpatternsForTuple(ImmutableArray<TypeWithAnnotations> elementTypes)
1556typeArgumentsWithAnnotations: 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)
724TypeWithAnnotations declType = BindVariableTypeWithAnnotations(node.Declaration, diagnostics, typeSyntax, ref isConst, isVar: out isVar, alias: out alias);
783private TypeWithAnnotations BindVariableTypeWithAnnotations(CSharpSyntaxNode declarationNode, BindingDiagnosticBag diagnostics, TypeSyntax typeSyntax, ref bool isConst, out bool isVar, out AliasSymbol alias)
796TypeWithAnnotations declType = BindTypeOrVarKeyword(typeSyntax.SkipScoped(out _).SkipRef(), diagnostics, out isVar, out alias);
951TypeWithAnnotations declTypeOpt,
977TypeWithAnnotations declTypeOpt,
1022declTypeOpt = TypeWithAnnotations.Create(initializerType);
1027declTypeOpt = TypeWithAnnotations.Create(CreateErrorType("var"));
1042declTypeOpt = TypeWithAnnotations.Create(CreateErrorType("var"));
1364TypeSymbol pointerType = new PointerTypeSymbol(TypeWithAnnotations.Create(elementType));
1469return op1.SetInferredTypeWithAnnotations(TypeWithAnnotations.Create(inferredType));
2299var targetElementTypes = default(ImmutableArray<TypeWithAnnotations>);
2473ImmutableArray<TypeWithAnnotations> targetElementTypes)
2725TypeWithAnnotations declType = BindTypeOrVarKeyword(typeSyntax, diagnostics, out isVar, out alias);
Binder\Binder_Symbols.cs (36)
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(GetContainingNamespaceOrType(symbol.Symbol), symbol.Symbol, LookupResultKind.NotATypeOrNamespace, diagnosticInfo));
401/// stack frames due to their use of large struct like <see cref="TypeWithAnnotations"/>.
459return TypeWithAnnotations.Create(
475return TypeWithAnnotations.Create(AreNullableAnnotationsEnabled(tupleTypeSyntax.CloseParenToken), BindTupleType(tupleTypeSyntax, diagnostics, basesBeingResolved));
521void reportNullableReferenceTypesIfNeeded(SyntaxToken questionToken, TypeWithAnnotations typeArgument = default)
543TypeWithAnnotations typeArgument = BindType(typeArgumentSyntax, diagnostics, basesBeingResolved);
544TypeWithAnnotations constructedType = typeArgument.SetIsAnnotated(Compilation);
571return TypeWithAnnotations.Create(AreNullableAnnotationsEnabled(predefinedType.Keyword), type);
584return TypeWithAnnotations.Create(new ExtendedErrorTypeSymbol(left, LookupResultKind.NotATypeOrNamespace, diagnostics.Add(ErrorCode.ERR_ColColWithTypeAlias, node.Alias.Location, node.Alias.Identifier.Text)));
593var elementType = BindType(node.ElementType, diagnostics, basesBeingResolved);
601return TypeWithAnnotations.Create(new PointerTypeSymbol(elementType));
607return TypeWithAnnotations.Create(CreateErrorType());
611internal static CSDiagnosticInfo? GetNullableUnconstrainedTypeParameterDiagnosticIfNecessary(LanguageVersion languageVersion, in TypeWithAnnotations type)
627private TypeWithAnnotations BindArrayType(
634TypeWithAnnotations type = BindType(node.ElementType, diagnostics, basesBeingResolved);
670type = TypeWithAnnotations.Create(AreNullableAnnotationsEnabled(rankSpecifier.CloseBracketToken), array);
681var types = ArrayBuilder<TypeWithAnnotations>.GetInstance(numElements);
693var argumentType = BindType(argumentSyntax.Type, diagnostics, basesBeingResolved);
834return TypeWithAnnotations.Create(new ExtendedErrorTypeSymbol(qualifierOpt ?? this.Compilation.Assembly.GlobalNamespace, string.Empty, arity: 0, errorInfo: null));
860return TypeWithAnnotations.Create(new ExtendedErrorTypeSymbol(
868return TypeWithAnnotations.Create(errorResult);
1150private TypeWithAnnotations BindGenericSimpleNamespaceOrTypeOrAliasSymbol(
1256return TypeWithAnnotations.Create(AreNullableAnnotationsEnabled(node.TypeArgumentList.GreaterThanToken), resultType);
1337private ImmutableArray<TypeWithAnnotations> BindTypeArguments(SeparatedSyntaxList<TypeSyntax> typeArguments, BindingDiagnosticBag diagnostics, ConsList<TypeSymbol> basesBeingResolved = null)
1340var args = ArrayBuilder<TypeWithAnnotations>.GetInstance(typeArguments.Count);
1349private TypeWithAnnotations BindTypeArgument(TypeSyntax typeArgument, BindingDiagnosticBag diagnostics, ConsList<TypeSymbol> basesBeingResolved = null)
1363? TypeWithAnnotations.Create(UnboundArgumentErrorTypeSymbol.Instance)
1372private NamedTypeSymbol ConstructNamedTypeUnlessTypeArgumentOmitted(SyntaxNode typeSyntax, NamedTypeSymbol type, SeparatedSyntaxList<TypeSyntax> typeArgumentsSyntax, ImmutableArray<TypeWithAnnotations> typeArguments, BindingDiagnosticBag diagnostics)
1400ImmutableArray<TypeWithAnnotations> typeArguments,
1554ImmutableArray<TypeWithAnnotations> typeArguments,
1623TypeWithAnnotations type = right.TypeWithAnnotations;
Binder\ForEachLoopBinder.cs (15)
194TypeWithAnnotations inferredType;
227TypeWithAnnotations inferredType;
265TypeWithAnnotations iterationVariableType;
299TypeWithAnnotations declType = BindTypeOrVarKeyword(typeSyntax, diagnostics, out isVar, out alias);
303declType = inferredType.HasType ? inferredType : TypeWithAnnotations.Create(CreateErrorType("var"));
370iterationVariableType = inferredType.HasType ? inferredType : TypeWithAnnotations.Create(CreateErrorType("var"));
608internal TypeWithAnnotations InferCollectionElementType(BindingDiagnosticBag diagnostics, ExpressionSyntax collectionSyntax)
613GetEnumeratorInfoAndInferCollectionElementType(_syntax, collectionSyntax, ref collectionExpr, isAsync: IsAsync, isSpread: false, diagnostics, out TypeWithAnnotations inferredType, builder: out _);
666out TypeWithAnnotations inferredType,
680inferredType = TypeWithAnnotations.Create(DynamicTypeSymbol.Instance);
688inferredType = TypeWithAnnotations.Create(GetSpecialType(SpecialType.System_Char, diagnostics, collectionExpr.Syntax));
1163builder.ElementTypeWithAnnotations = builder.CurrentPropertyGetter?.ReturnTypeWithAnnotations ?? TypeWithAnnotations.Create(GetSpecialType(SpecialType.System_Object, diagnostics, errorLocationSyntax));
1284builder.ElementTypeWithAnnotations = TypeWithAnnotations.Create(
1292TypeWithAnnotations.Create(GetSpecialType(SpecialType.System_Char, diagnostics, syntax)) :
1421var typeArguments = ArrayBuilder<TypeWithAnnotations>.GetInstance();
Binder\Semantics\Conversions\ConversionsBase.cs (33)
1469if (anonymousFunction.HasExplicitReturnType(out var refKind, out var returnType))
1640internal static CollectionExpressionTypeKind GetCollectionExpressionTypeKind(CSharpCompilation compilation, TypeSymbol destination, out TypeWithAnnotations elementType)
1692internal static bool IsSpanOrListType(CSharpCompilation compilation, TypeSymbol targetType, WellKnownType spanType, [NotNullWhen(true)] out TypeWithAnnotations elementType)
1812internal bool HasTopLevelNullabilityIdentityConversion(TypeWithAnnotations source, TypeWithAnnotations destination)
1844internal bool HasTopLevelNullabilityImplicitConversion(TypeWithAnnotations source, TypeWithAnnotations destination)
1864private static bool IsPossiblyNullableTypeTypeParameter(in TypeWithAnnotations typeWithAnnotations)
1875public bool HasAnyNullabilityImplicitConversion(TypeWithAnnotations source, TypeWithAnnotations destination)
1939(ConversionsBase conversions, BoundExpression s, TypeWithAnnotations d, bool isChecked, ref CompoundUseSiteInfo<AssemblySymbol> u, bool forCast) =>
1956(ConversionsBase conversions, TypeWithAnnotations s, TypeWithAnnotations d, bool _, ref CompoundUseSiteInfo<AssemblySymbol> u, bool _) =>
2258private delegate Conversion ClassifyConversionFromExpressionDelegate(ConversionsBase conversions, BoundExpression sourceExpression, TypeWithAnnotations destination, bool isChecked, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo, bool forCast);
2259private delegate Conversion ClassifyConversionFromTypeDelegate(ConversionsBase conversions, TypeWithAnnotations source, TypeWithAnnotations destination, bool isChecked, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo, bool forCast);
2273(ConversionsBase conversions, BoundExpression s, TypeWithAnnotations d, bool isChecked, ref CompoundUseSiteInfo<AssemblySymbol> u, bool forCast)
2291(ConversionsBase conversions, BoundExpression s, TypeWithAnnotations d, bool isChecked, ref CompoundUseSiteInfo<AssemblySymbol> u, bool forCast) =>
2344(ConversionsBase conversions, TypeWithAnnotations s, TypeWithAnnotations d, bool _, ref CompoundUseSiteInfo<AssemblySymbol> u, bool _) =>
2363(ConversionsBase conversions, TypeWithAnnotations s, TypeWithAnnotations d, bool isChecked, ref CompoundUseSiteInfo<AssemblySymbol> u, bool forCast) =>
2384ImmutableArray<TypeWithAnnotations> sourceTypes;
2385ImmutableArray<TypeWithAnnotations> destTypes;
2569TypeWithAnnotations elementType = source.ElementTypeWithAnnotations;
2570TypeWithAnnotations argument0 = destinationAgg.TypeArgumentWithDefinitionUseSiteDiagnostics(0, ref useSiteInfo);
2580private bool HasImplicitReferenceConversion(TypeWithAnnotations source, TypeWithAnnotations destination, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
3139var typeParameters = ArrayBuilder<TypeWithAnnotations>.GetInstance();
3140var sourceTypeArguments = ArrayBuilder<TypeWithAnnotations>.GetInstance();
3141var destinationTypeArguments = ArrayBuilder<TypeWithAnnotations>.GetInstance();
3392bool hasConversion(RefKind refKind, TypeWithAnnotations sourceType, TypeWithAnnotations destinationType, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
Binder\Semantics\OverloadResolution\MethodTypeInference.cs (158)
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;
141private readonly (TypeWithAnnotations Type, bool FromFunctionType)[] _fixedResults;
142private readonly HashSet<TypeWithAnnotations>[] _exactBounds;
143private readonly HashSet<TypeWithAnnotations>[] _upperBounds;
144private readonly HashSet<TypeWithAnnotations>[] _lowerBounds;
174ImmutableArray<TypeWithAnnotations> formalParameterTypes,
319ImmutableArray<TypeWithAnnotations> formalParameterTypes,
332_fixedResults = new (TypeWithAnnotations, bool)[methodTypeParameters.Length];
333_exactBounds = new HashSet<TypeWithAnnotations>[methodTypeParameters.Length];
334_upperBounds = new HashSet<TypeWithAnnotations>[methodTypeParameters.Length];
335_lowerBounds = new HashSet<TypeWithAnnotations>[methodTypeParameters.Length];
401var fixedType = _fixedResults[i].Type;
429private ImmutableArray<TypeWithAnnotations> GetResults(out bool inferredFromFunctionType)
449var fixedResultType = _fixedResults[i].Type;
467_fixedResults[i] = (TypeWithAnnotations.Create(new ExtendedErrorTypeSymbol(_constructedContainingTypeOfMethod, _methodTypeParameters[i].Name, 0, null, false)), false);
484private bool IsUnfixedTypeParameter(TypeWithAnnotations type)
509private void AddBound(TypeWithAnnotations addedBound, HashSet<TypeWithAnnotations>[] collectedBounds, TypeWithAnnotations methodTypeParameterWithAnnotations)
518collectedBounds[methodTypeParameterIndex] = new HashSet<TypeWithAnnotations>(TypeWithAnnotations.EqualsComparer.ConsiderEverythingComparer);
544static (typeParameter, i, self) => self.IsUnfixed(i) ? TypeWithAnnotations.Create(typeParameter) : self._fixedResults[i].Type,
586TypeWithAnnotations target = _formalParameterTypes[arg];
594private void MakeExplicitParameterTypeInferences(Binder binder, BoundExpression argument, TypeWithAnnotations target, ExactOrBoundsKind kind, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
622var argumentType = _extensions.GetTypeWithAnnotations(argument);
638TypeWithAnnotations target,
654if (!binder.TryGetCollectionIterationType((ExpressionSyntax)argument.Syntax, targetType.StrippedType(), out TypeWithAnnotations targetElementType))
674TypeWithAnnotations target,
693private bool MakeExplicitParameterTypeInferences(Binder binder, BoundTupleLiteral argument, TypeWithAnnotations target, ExactOrBoundsKind kind, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
725var destType = destTypes[i];
843var formalType = _formalParameterTypes[arg];
849private void MakeOutputTypeInferences(Binder binder, BoundExpression argument, TypeWithAnnotations formalType, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
872private void MakeOutputTypeInferences(Binder binder, BoundUnconvertedCollectionExpression argument, TypeWithAnnotations formalType, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
879if (!binder.TryGetCollectionIterationType((ExpressionSyntax)argument.Syntax, formalType.Type, out TypeWithAnnotations targetElementType))
893private void MakeOutputTypeInferences(Binder binder, BoundTupleLiteral argument, TypeWithAnnotations formalType, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
918var destType = destTypes[i];
1341private void OutputTypeInference(Binder binder, BoundExpression expression, TypeWithAnnotations target, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
1366var sourceType = _extensions.GetTypeWithAnnotations(expression);
1374private bool InferredReturnTypeInference(BoundExpression source, TypeWithAnnotations target, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
1392var returnType = delegateType.DelegateInvokeMethod.ReturnTypeWithAnnotations;
1398var inferredReturnType = InferReturnType(source, delegateType, ref useSiteInfo);
1447TypeWithAnnotations sourceReturnType = method.ReturnTypeWithAnnotations;
1466var returnType = MethodGroupReturnType(binder, originalMethodGroup, fixedParameters, method.RefKind, isFunctionPointerResolution, ref useSiteInfo, in callingConventionInfo);
1476private TypeWithAnnotations MethodGroupReturnType(
1495TypeWithAnnotations type = default;
1517private void ExplicitParameterTypeInference(BoundExpression source, TypeWithAnnotations target, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
1572private void ExplicitReturnTypeInference(BoundExpression source, TypeWithAnnotations target, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
1589if (!anonymousFunction.HasExplicitReturnType(out _, out TypeWithAnnotations anonymousFunctionReturnType))
1608private void ExactInference(TypeWithAnnotations source, TypeWithAnnotations target, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
1655private bool ExactTypeParameterInference(TypeWithAnnotations source, TypeWithAnnotations target)
1670private bool ExactArrayInference(TypeWithAnnotations source, TypeWithAnnotations target, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
1700private void ExactOrBoundsInference(ExactOrBoundsKind kind, TypeWithAnnotations source, TypeWithAnnotations target, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
1716private bool ExactOrBoundsNullableInference(ExactOrBoundsKind kind, TypeWithAnnotations source, TypeWithAnnotations target, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
1736static bool isNullableOnly(TypeWithAnnotations type)
1740private bool ExactNullableInference(TypeWithAnnotations source, TypeWithAnnotations target, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
1745private bool LowerBoundTupleInference(TypeWithAnnotations source, TypeWithAnnotations target, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
1754ImmutableArray<TypeWithAnnotations> sourceTypes;
1755ImmutableArray<TypeWithAnnotations> targetTypes;
1772private bool ExactConstructedInference(TypeWithAnnotations source, TypeWithAnnotations target, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
1802private bool ExactPointerInference(TypeWithAnnotations source, TypeWithAnnotations target, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
1862var sourceTypeArguments = ArrayBuilder<TypeWithAnnotations>.GetInstance();
1863var targetTypeArguments = ArrayBuilder<TypeWithAnnotations>.GetInstance();
1883private void LowerBoundInference(TypeWithAnnotations source, TypeWithAnnotations target, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
1970private bool LowerBoundTypeParameterInference(TypeWithAnnotations source, TypeWithAnnotations target)
1985private static TypeWithAnnotations GetMatchingElementType(ArrayTypeSymbol source, TypeSymbol target, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
2039var elementSource = arraySource.ElementTypeWithAnnotations;
2040var elementTarget = GetMatchingElementType(arraySource, target, ref useSiteInfo);
2058private bool LowerBoundNullableInference(TypeWithAnnotations source, TypeWithAnnotations target, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
2260var sourceTypeArguments = ArrayBuilder<TypeWithAnnotations>.GetInstance();
2261var targetTypeArguments = ArrayBuilder<TypeWithAnnotations>.GetInstance();
2347private void UpperBoundInference(TypeWithAnnotations source, TypeWithAnnotations target, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
2408private bool UpperBoundTypeParameterInference(TypeWithAnnotations source, TypeWithAnnotations target)
2422private bool UpperBoundArrayInference(TypeWithAnnotations source, TypeWithAnnotations target, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
2440var elementTarget = arrayTarget.ElementTypeWithAnnotations;
2441var elementSource = GetMatchingElementType(arrayTarget, source.Type, ref useSiteInfo);
2459private bool UpperBoundNullableInference(TypeWithAnnotations source, TypeWithAnnotations target, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
2464private bool UpperBoundConstructedInference(TypeWithAnnotations sourceWithAnnotations, TypeWithAnnotations targetWithAnnotations, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
2610var sourceTypeArguments = ArrayBuilder<TypeWithAnnotations>.GetInstance();
2611var targetTypeArguments = ArrayBuilder<TypeWithAnnotations>.GetInstance();
2729private static (TypeWithAnnotations Type, bool FromFunctionType) Fix(
2733HashSet<TypeWithAnnotations>? exact,
2734HashSet<TypeWithAnnotations>? lower,
2735HashSet<TypeWithAnnotations>? upper,
2750var candidates = new Dictionary<TypeWithAnnotations, TypeWithAnnotations>(EqualsIgnoringDynamicTupleNamesAndNullabilityComparer.Instance);
2755Predicate<TypeWithAnnotations> lowerPredicate;
2800var initialCandidates = ArrayBuilder<TypeWithAnnotations>.GetInstance();
2825TypeWithAnnotations best = default;
2866best = TypeWithAnnotations.Create(resultType, best.NullableAnnotation);
2872static bool containsFunctionTypes([NotNullWhen(true)] HashSet<TypeWithAnnotations>? types)
2877static bool containsNonFunctionTypes([NotNullWhen(true)] HashSet<TypeWithAnnotations>? types)
2882static bool isFunctionType(TypeWithAnnotations type, [NotNullWhen(true)] out FunctionTypeSymbol? functionType)
2908private static bool ImplicitConversionExists(TypeWithAnnotations sourceWithAnnotations, TypeWithAnnotations destinationWithAnnotations, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo, ConversionsBase conversions)
2932private TypeWithAnnotations InferReturnType(BoundExpression source, NamedTypeSymbol target, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
3013var returnType = anonymousFunction.InferReturnType(_conversions, fixedDelegate, ref useSiteInfo, out bool inferredFromFunctionType);
3072public static ImmutableArray<TypeWithAnnotations> InferTypeArgumentsFromFirstArgument(
3136var dest = _formalParameterTypes[0];
3168private ImmutableArray<TypeWithAnnotations> GetInferredTypeArguments(out bool inferredFromFunctionType)
3170var builder = ArrayBuilder<TypeWithAnnotations>.GetInstance(_fixedResults.Length);
3190private static void GetAllCandidates(Dictionary<TypeWithAnnotations, TypeWithAnnotations> candidates, ArrayBuilder<TypeWithAnnotations> builder)
3203Dictionary<TypeWithAnnotations, TypeWithAnnotations> candidates,
3204HashSet<TypeWithAnnotations> bounds,
3205Predicate<TypeWithAnnotations>? predicate,
3209foreach (var candidate in bounds)
3216var type = candidate;
3232Dictionary<TypeWithAnnotations, TypeWithAnnotations> candidates,
3233TypeWithAnnotations newCandidate,
3236if (candidates.TryGetValue(newCandidate, out TypeWithAnnotations oldCandidate))
3247Dictionary<TypeWithAnnotations, TypeWithAnnotations> candidates,
3248HashSet<TypeWithAnnotations> bounds,
3249Predicate<TypeWithAnnotations>? predicate,
3250ArrayBuilder<TypeWithAnnotations> initialCandidates,
3259foreach (var bound in bounds)
3272TypeWithAnnotations source;
3273TypeWithAnnotations destination;
3287if (conversions.IncludeNullability && candidates.TryGetValue(bound, out var oldBound))
3294var newBound = TypeWithAnnotations.Create(oldBound.Type, newAnnotation);
3314Dictionary<TypeWithAnnotations, TypeWithAnnotations> candidates,
3315TypeWithAnnotations oldCandidate,
3316TypeWithAnnotations newCandidate,
3325if (candidates.TryGetValue(oldCandidate, out TypeWithAnnotations latest))
3336TypeWithAnnotations merged = latest.MergeEquivalentTypes(newCandidate, variance);
3345private sealed class EqualsIgnoringDynamicTupleNamesAndNullabilityComparer : EqualityComparer<TypeWithAnnotations>
3349public override int GetHashCode(TypeWithAnnotations obj)
3354public override bool Equals(TypeWithAnnotations x, TypeWithAnnotations y)
Binder\Semantics\OverloadResolution\OverloadResolution.cs (37)
137ArrayBuilder<TypeWithAnnotations> typeArguments,
173ArrayBuilder<TypeWithAnnotations> typeArguments = ArrayBuilder<TypeWithAnnotations>.GetInstance();
185ArrayBuilder<TypeWithAnnotations> typeArguments,
259ArrayBuilder<TypeWithAnnotations> typeArguments,
449var typeArgumentsBuilder = ArrayBuilder<TypeWithAnnotations>.GetInstance();
823if (IsValidParams(_binder, constructor, disallowExpandedNonArrayParams: false, out TypeWithAnnotations definitionElementType))
885TypeWithAnnotations definitionParamsElementType,
933ArrayBuilder<TypeWithAnnotations> typeArguments,
1066if ((options & Options.IsMethodGroupConversion) == 0 && IsValidParams(_binder, leastOverriddenMember, disallowExpandedNonArrayParams, out TypeWithAnnotations definitionElementType))
1166public static bool IsValidParams(Binder binder, Symbol member, bool disallowExpandedNonArrayParams, out TypeWithAnnotations definitionElementType)
1194public static bool TryInferParamsCollectionIterationType(Binder binder, TypeSymbol type, out TypeWithAnnotations elementType)
2434static TypeSymbol getParameterTypeAndRefKind(int i, MemberAnalysisResult result, ImmutableArray<ParameterSymbol> parameters, TypeWithAnnotations paramsElementTypeOpt, out RefKind parameter1RefKind)
2919CollectionExpressionTypeKind kind1 = ConversionsBase.GetCollectionExpressionTypeKind(Compilation, t1, out TypeWithAnnotations elementType1);
2920CollectionExpressionTypeKind kind2 = ConversionsBase.GetCollectionExpressionTypeKind(Compilation, t2, out TypeWithAnnotations elementType2);
2933if (type.IsArrayInterface(out TypeWithAnnotations typeArg))
2977var x = lambda.GetInferredReturnType(ref useSiteInfo, out _);
3391var x = lambda.InferReturnType(Conversions, d1, ref useSiteInfo, out _);
3500out ImmutableArray<TypeWithAnnotations> parameterTypes,
3516internal readonly ImmutableArray<TypeWithAnnotations> ParameterTypes;
3520internal EffectiveParameters(ImmutableArray<TypeWithAnnotations> types, ImmutableArray<RefKind> refKinds, int firstParamsElementIndex)
3556var types = ArrayBuilder<TypeWithAnnotations>.GetInstance();
3693var types = ArrayBuilder<TypeWithAnnotations>.GetInstance();
3699TypeWithAnnotations paramsIterationType = default;
3706var type = parameter.TypeWithAnnotations;
3742ArrayBuilder<TypeWithAnnotations> typeArguments,
3817ArrayBuilder<TypeWithAnnotations> typeArguments,
3819TypeWithAnnotations definitionParamsElementType,
3876ArrayBuilder<TypeWithAnnotations> typeArgumentsBuilder,
3879TypeWithAnnotations definitionParamsElementTypeOpt,
3898ImmutableArray<TypeWithAnnotations> typeArguments;
4010private ImmutableArray<TypeWithAnnotations> InferMethodTypeArguments(
4056return default(ImmutableArray<TypeWithAnnotations>);
4062return default(ImmutableArray<TypeWithAnnotations>);
4068TypeWithAnnotations definitionParamsElementTypeOpt,
4079TypeWithAnnotations paramsElementTypeOpt;
4085paramsElementTypeOpt = TypeWithAnnotations.Create(ErrorTypeSymbol.EmptyParamsCollectionElementTypeSentinel);
BoundTree\Constructors.cs (5)
543public BoundTypeExpression(SyntaxNode syntax, AliasSymbol? aliasOpt, BoundTypeExpression? boundContainingTypeOpt, ImmutableArray<BoundExpression> boundDimensionsOpt, TypeWithAnnotations typeWithAnnotations, bool hasErrors = false)
549public BoundTypeExpression(SyntaxNode syntax, AliasSymbol? aliasOpt, BoundTypeExpression? boundContainingTypeOpt, TypeWithAnnotations typeWithAnnotations, bool hasErrors = false)
554public BoundTypeExpression(SyntaxNode syntax, AliasSymbol? aliasOpt, TypeWithAnnotations typeWithAnnotations, bool hasErrors = false)
560: this(syntax, aliasOpt, null, TypeWithAnnotations.Create(type), hasErrors)
564public 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)
468public TypeWithAnnotations InferReturnType(ConversionsBase conversions, NamedTypeSymbol delegateType, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo, out bool inferredFromFunctionType)
478public TypeWithAnnotations ParameterTypeWithAnnotations(int index) { return Data.ParameterTypeWithAnnotations(index); }
556public abstract bool HasExplicitReturnType(out RefKind refKind, out TypeWithAnnotations returnType);
562public abstract TypeWithAnnotations ParameterTypeWithAnnotations(int index);
615var type = lambda.InferredReturnType.TypeWithAnnotations;
625var type = BindForErrorRecovery().InferredReturnType.TypeWithAnnotations;
638private static TypeWithAnnotations DelegateReturnTypeWithAnnotations(MethodSymbol? invokeMethod, out RefKind refKind)
649internal (ImmutableArray<RefKind>, ArrayBuilder<ScopedKind>, ImmutableArray<TypeWithAnnotations>, bool) CollectParameterProperties()
653var parameterTypesBuilder = ArrayBuilder<TypeWithAnnotations>.GetInstance(ParameterCount);
660var type = ParameterTypeWithAnnotations(i);
715if (!HasExplicitReturnType(out var returnRefKind, out var returnType))
719var returnTypes = ArrayBuilder<(BoundReturnStatement, TypeWithAnnotations)>.GetInstance();
761returnType = TypeWithAnnotations.Create(Binder.Compilation.GetSpecialType(SpecialType.System_Void));
778var returnType = DelegateReturnTypeWithAnnotations(invokeMethod, out RefKind refKind);
882TypeWithAnnotations returnType,
883ImmutableArray<TypeWithAnnotations> parameterTypes,
899var returnType = DelegateReturnTypeWithAnnotations(invokeMethod, out RefKind refKind);
904private void ValidateUnsafeParameters(BindingDiagnosticBag diagnostics, ImmutableArray<TypeWithAnnotations> targetParameterTypes)
931ImmutableArray<TypeWithAnnotations> parameterTypes,
934bool hasExplicitReturnType = HasExplicitReturnType(out var refKind, out var returnType);
953var returnTypes = ArrayBuilder<(BoundReturnStatement, TypeWithAnnotations)>.GetInstance();
963? TypeWithAnnotations.Create(this.Binder.Compilation.GetSpecialType(SpecialType.System_Void))
964: TypeWithAnnotations.Create(LambdaSymbol.InferenceFailureReturnType);
988ImmutableArray<TypeWithAnnotations> parameterTypes,
990TypeWithAnnotations returnType,
1024public readonly ImmutableArray<TypeWithAnnotations> ParameterTypes;
1028public static readonly ReturnInferenceCacheKey Empty = new ReturnInferenceCacheKey(ImmutableArray<TypeWithAnnotations>.Empty, ImmutableArray<RefKind>.Empty, null);
1030private ReturnInferenceCacheKey(ImmutableArray<TypeWithAnnotations> parameterTypes, ImmutableArray<RefKind> parameterRefKinds, NamedTypeSymbol? taskLikeReturnTypeOpt)
1070foreach (var type in ParameterTypes)
1090out ImmutableArray<TypeWithAnnotations> parameterTypes,
1096parameterTypes = ImmutableArray<TypeWithAnnotations>.Empty;
1105var typesBuilder = ArrayBuilder<TypeWithAnnotations>.GetInstance(parameterCount);
1182?? rebind(ReallyInferReturnType(delegateType: null, ImmutableArray<TypeWithAnnotations>.Empty, ImmutableArray<RefKind>.Empty));
1198ImmutableArray<TypeWithAnnotations> parameterTypes,
1201var returnType = inferredReturnType.TypeWithAnnotations;
1213returnType = TypeWithAnnotations.Create(t);
1428private readonly TypeWithAnnotations _returnType;
1432private readonly ImmutableArray<TypeWithAnnotations> _parameterTypesWithAnnotations;
1443TypeWithAnnotations returnType,
1447ImmutableArray<TypeWithAnnotations> parameterTypesWithAnnotations,
1473public override bool HasExplicitReturnType(out RefKind refKind, out TypeWithAnnotations returnType)
1551public override TypeWithAnnotations ParameterTypeWithAnnotations(int index)
Compilation\CSharpCompilation.cs (10)
2248var firstType = method.Parameters[0].TypeWithAnnotations;
2382return ArrayTypeSymbol.CreateCSharpArray(this.Assembly, TypeWithAnnotations.Create(elementType, elementNullableAnnotation), rank);
2395return new PointerTypeSymbol(TypeWithAnnotations.Create(elementType, elementNullableAnnotation));
4071var returnTypeWithAnnotations = TypeWithAnnotations.Create(returnType.EnsureCSharpSymbolOrNull(nameof(returnType)), returnType.NullableAnnotation.ToInternalAnnotation());
4073type => TypeWithAnnotations.Create(type.EnsureCSharpSymbolOrNull(nameof(parameterTypes)), type.NullableAnnotation.ToInternalAnnotation()));
4121var typesBuilder = ArrayBuilder<TypeWithAnnotations>.GetInstance(elementTypes.Length);
4127typesBuilder.Add(TypeWithAnnotations.Create(elementType, annotation));
4165(t, a) => TypeWithAnnotations.Create(t.Type, a.ToInternalAnnotation())));
4195fields.Add(new AnonymousTypeField(name, location, TypeWithAnnotations.Create(type, nullableAnnotation), RefKind.None, ScopedKind.None));
FlowAnalysis\NullableWalker.cs (214)
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)
204private ArrayBuilder<(BoundReturnStatement, TypeWithAnnotations)>? _returnTypesOpt;
242private PooledDictionary<BoundExpression, Func<TypeWithAnnotations, TypeWithState>>? _targetTypedAnalysisCompletionOpt;
247/// The delegate is invoked by <see cref="VisitConversion(BoundConversion, BoundExpression, Conversion, TypeWithAnnotations, TypeWithState, bool, bool, bool, AssignmentKind, ParameterSymbol, bool, bool, bool, Optional<LocalState>,bool, Location, ArrayBuilder<VisitResult>)"/>.
249private PooledDictionary<BoundExpression, Func<TypeWithAnnotations, TypeWithState>> TargetTypedAnalysisCompletion
250=> _targetTypedAnalysisCompletionOpt ??= PooledDictionary<BoundExpression, Func<TypeWithAnnotations, TypeWithState>>.GetInstance();
315private TypeWithAnnotations LvalueResultType
320private void SetLvalueResultType(BoundExpression? expression, TypeWithAnnotations type)
335private void SetResult(BoundExpression? expression, TypeWithState resultType, TypeWithAnnotations lvalueType, bool updateAnalyzedNullability = true, bool? isLvalue = null)
355private void SetAnalyzedNullability(BoundExpression? expression, TypeWithState resultType, TypeWithAnnotations lvalueType, bool? isLvalue = null)
459ArrayBuilder<(BoundReturnStatement, TypeWithAnnotations)>? returnTypesOpt,
720TypeWithAnnotations symbolType;
941var type = memberToInitialize.GetTypeOrReturnType();
1673ArrayBuilder<(BoundReturnStatement, TypeWithAnnotations)>? returnTypesOpt)
1719ArrayBuilder<(BoundReturnStatement, TypeWithAnnotations)>? returnTypesOpt,
1900if (!_variables.TryGetType(local, out TypeWithAnnotations localType))
1909if (!_variables.TryGetType(parameter, out TypeWithAnnotations parameterType))
2184private TypeWithAnnotations VisitLvalueWithAnnotations(BoundExpression node)
2225private static bool ShouldReportNullableAssignment(TypeWithAnnotations type, NullableFlowState state)
2261TypeWithAnnotations targetType,
2334TypeWithAnnotations overriddenType,
2336TypeWithAnnotations overridingType,
2407static bool isBadAssignment(TypeWithState valueState, TypeWithAnnotations destinationType, FlowAnalysisAnnotations destinationAnnotations)
2483TypeWithAnnotations targetType,
2526static bool areEquivalentTypes(TypeWithAnnotations target, TypeWithState assignedValue) =>
2593TypeWithAnnotations fieldOrPropertyType = member.GetTypeOrReturnType();
2775var parameterType = i >= signatureParameters.Length ? parameter.TypeWithAnnotations : signatureParameters[i].TypeWithAnnotations;
2781private void EnterParameter(ParameterSymbol parameter, TypeWithAnnotations parameterType)
2810var parameterLValueType = ApplyLValueAnnotations(parameter.TypeWithAnnotations, parameterAnnotations);
2826internal static TypeWithState GetParameterState(TypeWithAnnotations parameterType, FlowAnalysisAnnotations parameterAnnotations)
2856TryGetReturnType(out TypeWithAnnotations returnType, out FlowAnalysisAnnotations returnAnnotations))
2914private TypeWithState VisitRefExpression(BoundExpression expr, TypeWithAnnotations destinationType)
2920var lvalueResultType = LvalueResultType;
2936private bool TryGetReturnType(out TypeWithAnnotations type, out FlowAnalysisAnnotations annotations)
2947var returnType = delegateOrMethod.ReturnTypeWithAnnotations;
2991var type = GetDeclaredLocalResult(local);
2999type = TypeWithAnnotations.Create(node.Type, type.NullableAnnotation);
3320var resultType = ResultType.ToTypeWithAnnotations(compilation);
3421TypeWithAnnotations type = local.TypeWithAnnotations;
3619var elementConversionCompletions = ArrayBuilder<Func<TypeWithAnnotations, TypeWithState>>.GetInstance();
3662(TypeWithAnnotations resultTypeWithAnnotations) => convertCollection(node, resultTypeWithAnnotations, elementConversionCompletions);
3671var resultType = TypeWithAnnotations.Create(node.Type);
3678TypeWithState convertCollection(BoundCollectionExpression node, TypeWithAnnotations targetCollectionType, ArrayBuilder<Func<TypeWithAnnotations, TypeWithState>> completions)
3720(CollectionExpressionTypeKind, TypeWithAnnotations) getCollectionDetails(BoundCollectionExpression node, TypeSymbol collectionType)
3722var collectionKind = ConversionsBase.GetCollectionExpressionTypeKind(this.compilation, collectionType, out var targetElementType);
3806(TypeWithAnnotations resultTypeWithAnnotations) =>
3885var parameterType = constructor.ParameterTypesWithAnnotations[0];
3886if (AreNullableAndUnderlyingTypes(type, parameterType.Type, out TypeWithAnnotations underlyingType))
4134Action<int, Symbol>? visitMemberAssignment(BoundAssignmentOperator node, int containingSlot, Symbol symbol, bool delayCompletionForType, Func<TypeWithAnnotations, TypeWithState>? conversionCompletion = null)
4145var type = ApplyLValueAnnotations(symbol.GetTypeOrReturnType(), GetObjectInitializerMemberLValueAnnotations(symbol));
4167Action<int, Symbol>? visitMemberAssignmentAsContinuation(BoundAssignmentOperator node, Func<TypeWithAnnotations, TypeWithState> conversionCompletion)
4300var lvalueType = resultType.ToTypeWithAnnotations(compilation);
4352return GetOrCreatePlaceholderSlot(node, TypeWithAnnotations.Create(node.Type, NullableAnnotation.NotAnnotated));
4355private int GetOrCreatePlaceholderSlot(object identifier, TypeWithAnnotations type)
4505TypeWithAnnotations inferredType = (bestType is null)
4507: TypeWithAnnotations.Create(bestType);
4546static TypeWithAnnotations getSpanElementType(NamedTypeSymbol namedType)
4553static TypeSymbol setSpanElementType(NamedTypeSymbol namedType, TypeWithAnnotations elementType)
4582internal static TypeWithAnnotations BestTypeForLambdaReturns(
4583ArrayBuilder<(BoundExpression expr, TypeWithAnnotations resultType, bool isChecked)> returns,
4605var resultTypes = ArrayBuilder<TypeWithAnnotations>.GetInstance(n);
4618TypeWithAnnotations inferredType;
4622var bestTypeWithObliviousAnnotation = TypeWithAnnotations.Create(bestType);
4634inferredType = TypeWithAnnotations.Create(bestType, BestTypeInferrer.GetNullableAnnotation(resultTypes));
4681TypeWithAnnotations result;
4685result = TypeWithAnnotations.Create(type);
4708TypeWithAnnotations type = expressionType.TryGetInlineArrayElementField()!.TypeWithAnnotations;
4712type = TypeWithAnnotations.Create(((NamedTypeSymbol)node.Type).OriginalDefinition.Construct(ImmutableArray.Create(type)));
4937SetResult(binary, TypeWithState.ForType(binary.Type), TypeWithAnnotations.Create(binary.Type));
4999var targetTypeWithNullability = ApplyLValueAnnotations(parameter.TypeWithAnnotations, parameterAnnotations);
5003targetTypeWithNullability = TypeWithAnnotations.Create(MakeNullableOf(targetTypeWithNullability));
5048TypeWithAnnotations.Create(expr.Type),
5434TypeWithAnnotations targetType = VisitLvalueWithAnnotations(leftOperand);
5452targetType = TypeWithAnnotations.Create(node.Type, NullableAnnotation.NotAnnotated);
5543TypeWithAnnotations.Create(rightType),
5579TypeWithAnnotations explicitType = boundConversion.ConversionGroupOpt?.ExplicitType ?? default;
5581TypeWithAnnotations targetType = fromExplicitCast ? explicitType : TypeWithAnnotations.Create(boundConversion.Type);
5719var accessTypeWithAnnotations = LvalueResultType;
5775TypeWithAnnotations consequenceLValue;
5776TypeWithAnnotations alternativeLValue;
5796var refResultTypeWithAnnotations = TypeWithAnnotations.Create(refResultType, lValueAnnotation);
5805SetResult(node, TypeWithState.Create(refResultType, rValueState), TypeWithAnnotations.Create(refResultType, lValueAnnotation));
5856TypeWithAnnotations resultTypeWithAnnotations;
5877resultTypeWithAnnotations = TypeWithAnnotations.Create(resultType);
5890BoundExpression alternative, Conversion alternativeConversion, bool alternativeEndReachable, TypeWithAnnotations resultTypeWithAnnotations, bool wasTargetTyped)
5947(TypeWithAnnotations resultTypeWithAnnotations) =>
5969(TypeWithAnnotations LValueType, TypeWithState RValueType) visitConditionalRefOperand(LocalState state, BoundExpression operand)
5973TypeWithAnnotations lValueType = VisitLvalueWithAnnotations(operand);
5977void reportMismatchIfNecessary(BoundExpression node, TypeWithAnnotations source, TypeWithAnnotations destination)
5990TypeWithAnnotations targetType,
6038private static BoundExpression CreatePlaceholderIfNecessary(BoundExpression expr, TypeWithAnnotations type)
6105TypeWithAnnotations paramsIterationType = default;
6249var parameterType = method.Parameters[0].TypeWithAnnotations;
6509private static TypeWithAnnotations ApplyLValueAnnotations(TypeWithAnnotations declaredType, FlowAnalysisAnnotations flowAnalysisAnnotations)
6541private static TypeWithAnnotations ApplyUnconditionalAnnotations(TypeWithAnnotations declaredType, FlowAnalysisAnnotations annotations)
6737TypeWithAnnotations paramsIterationType = default;
6744(ParameterSymbol? parameter, TypeWithAnnotations parameterType, FlowAnalysisAnnotations parameterAnnotations, bool isExpandedParamsArgument) =
6810TypeWithAnnotations paramsIterationType = default;
6816(ParameterSymbol? parameter, TypeWithAnnotations parameterType, FlowAnalysisAnnotations parameterAnnotations, _) =
6961completion(TypeWithAnnotations.Create(argument.Type));
7105TypeWithAnnotations paramsIterationType = default;
7115TypeWithAnnotations paramsIterationType = default;
7194TypeWithAnnotations parameterType,
7249var lvalueResultType = result.LValueType;
7331TypeWithAnnotations parameterType,
7361var lValueType = result.LValueType;
7385var declaredType = result.LValueType;
7387var lValueType = ApplyLValueAnnotations(declaredType, leftAnnotations);
7390var varType = worstCaseParameterWithState.ToAnnotatedTypeWithAnnotations(compilation);
7444void trackNullableStateForAssignment(BoundExpression parameterValue, TypeWithAnnotations lValueType, int targetSlot, TypeWithState parameterWithState, bool isSuppressed, FlowAnalysisAnnotations parameterAnnotations)
7627private (ParameterSymbol? Parameter, TypeWithAnnotations Type, FlowAnalysisAnnotations Annotations, bool isExpandedParamsArgument) GetCorrespondingParameter(
7632ref TypeWithAnnotations paramsIterationType)
7646var type = parameter.TypeWithAnnotations;
7693parameterTypes: out ImmutableArray<TypeWithAnnotations> parameterTypes,
7726internal override TypeWithAnnotations GetTypeWithAnnotations(BoundExpression expr)
7728return TypeWithAnnotations.Create(expr.GetTypeOrFunctionType(), GetNullableAnnotation(expr));
7759internal override TypeWithAnnotations GetMethodGroupResultType(BoundMethodGroup group, MethodSymbol method)
7827var argumentType = visitResult.RValueType.ToTypeWithAnnotations(compilation);
8112TypeWithAnnotations explicitType = node.ConversionGroupOpt?.ExplicitType ?? default;
8114TypeWithAnnotations targetType = fromExplicitCast ? explicitType : TypeWithAnnotations.Create(node.Type);
8152private TypeWithState VisitOptionalImplicitConversion(BoundExpression expr, TypeWithAnnotations targetTypeOpt, bool useLegacyWarnings, bool trackMembers, AssignmentKind assignmentKind)
8164private (TypeWithState resultType, Func<TypeWithAnnotations, TypeWithState>? completion) VisitOptionalImplicitConversion(
8166TypeWithAnnotations targetTypeOpt,
8178(TypeWithState resultType, Func<TypeWithAnnotations, TypeWithState>? completion) visitConversion(
8180TypeWithAnnotations targetTypeOpt,
8215Func<TypeWithAnnotations, TypeWithState> visitConversionAsContinuation(BoundExpression expr, bool useLegacyWarnings, bool trackMembers, AssignmentKind assignmentKind, BoundExpression operand, Conversion conversion, TypeWithState operandType)
8217return (TypeWithAnnotations targetTypeOpt) =>
8226private static bool AreNullableAndUnderlyingTypes([NotNullWhen(true)] TypeSymbol? nullableTypeOpt, [NotNullWhen(true)] TypeSymbol? underlyingTypeOpt, out TypeWithAnnotations underlyingTypeWithAnnotations)
8231var typeArg = nullableTypeOpt.GetNullableUnderlyingTypeWithAnnotations();
8266ImmutableArray<TypeWithAnnotations> elementTypesWithAnnotations = elementTypes.SelectAsArray(a => a.ToTypeWithAnnotations(compilation));
8623TypeWithAnnotations targetTypeWithNullability,
8643if (TargetTypedAnalysisCompletion.TryGetValue(conversionOperand, out Func<TypeWithAnnotations, TypeWithState>? completion))
8835if (AreNullableAndUnderlyingTypes(targetType, operandType.Type, out TypeWithAnnotations underlyingType))
8964static TypeWithState calculateResultType(TypeWithAnnotations targetTypeWithNullability, bool fromExplicitCast, NullableFlowState resultState, bool isSuppressed, TypeSymbol targetType)
8980static NullableFlowState getReferenceConversionResultState(TypeWithAnnotations targetType, TypeWithState operandType)
9014static NullableFlowState getBoxingConversionResultState(TypeWithAnnotations targetType, TypeWithState operandType)
9074foreach (var constraintType in typeParameter1.ConstraintTypesNoUseSiteDiagnostics)
9164TypeWithAnnotations targetTypeWithNullability,
9196TypeWithAnnotations.Create(conversion.BestUserDefinedConversionAnalysis!.FromType),
9216var parameterType = ApplyLValueAnnotations(parameter.TypeWithAnnotations, parameterAnnotations);
9222var underlyingOperandTypeWithAnnotations = operandType.Type.GetNullableUnderlyingTypeWithAnnotations();
9248var methodReturnType = method.ReturnTypeWithAnnotations;
9267TypeWithAnnotations.Create(conversion.BestUserDefinedConversionAnalysis!.ToType),
9348private TypeWithState GetLiftedReturnType(TypeWithAnnotations returnType, NullableFlowState operandState)
9369private TypeWithState GetLiftedReturnTypeIfNecessary(bool isLifted, TypeWithAnnotations returnType, NullableFlowState operandState)
9376private TypeSymbol MakeNullableOf(TypeWithAnnotations underlying)
9383TypeWithAnnotations targetType,
9483(TypeWithAnnotations resultTypeWithAnnotations) =>
9564var argTypeWithAnnotations = TypeWithAnnotations.Create(argType, NullableAnnotation.NotAnnotated);
9661var parameterType = parameter.TypeWithAnnotations;
9751var lvalueResult = TypeWithAnnotations.Create(node.Type, NullableAnnotation.NotAnnotated);
9759var parameterType = GetDeclaredParameterResult(parameter);
9788TypeWithAnnotations declaredType = LvalueResultType;
9789TypeWithAnnotations leftLValueType = ApplyLValueAnnotations(declaredType, leftAnnotations);
9818var lvalueType = rightState.ToTypeWithAnnotations(compilation);
9836var type = property.TypeWithAnnotations;
9838var lValueType = ApplyLValueAnnotations(type, annotations);
10160AreNullableAndUnderlyingTypes(lvalueType.Type, operandType.Type, out TypeWithAnnotations underlyingType))
10176internal readonly TypeWithAnnotations Type;
10179internal DeconstructionVariable(BoundExpression expression, TypeWithAnnotations type)
10263var operandLvalue = LvalueResultType;
10270TypeWithAnnotations targetTypeOfOperandConversion;
10326var operandTypeWithAnnotations = operandType.ToTypeWithAnnotations(compilation);
10368var leftLvalueType = LvalueResultType;
10446var paramType = parameter.TypeWithAnnotations;
10481private TypeWithAnnotations GetDeclaredLocalResult(LocalSymbol local)
10483return _variables.TryGetType(local, out TypeWithAnnotations type) ?
10488private TypeWithAnnotations GetDeclaredParameterResult(ParameterSymbol parameter)
10490return _variables.TryGetType(parameter, out TypeWithAnnotations type) ?
10606var type = member.GetTypeOrReturnType();
10710TypeWithAnnotations targetTypeWithAnnotations;
10746targetTypeWithAnnotations = TypeWithAnnotations.Create(node.Expression.Type);
10753targetTypeWithAnnotations = TypeWithAnnotations.Create(ForEachLoopBinder.GetIEnumerableOfT(resultType, isAsync, compilation, ref discardedUseSiteInfo, out bool foundMultiple, needSupportForRefStructInterfaces: out _));
10804TypeWithAnnotations.Create(node.EnumeratorInfoOpt.ElementType, NullableAnnotation.NotAnnotated).ToTypeWithState();
10885TypeWithAnnotations sourceType = sourceState.ToTypeWithAnnotations(compilation);
10914TypeWithAnnotations destinationType = iterationVariable.TypeWithAnnotations;
11011var type = TypeWithAnnotations.Create(node.Type);
11112var type = TypeWithAnnotations.Create(node.Type);
11120var type = TypeWithAnnotations.Create(node.Type);
11142var type = TypeWithAnnotations.Create(node.Type, node.NullableAnnotation);
11470var result = TypeWithAnnotations.Create(node.Type);
11490var result = TypeWithAnnotations.Create(node.Type, NullableAnnotation.Oblivious);
11596var result = TypeWithAnnotations.Create(node.Type, NullableAnnotation.Oblivious);
11665private static bool IsNullabilityMismatch(TypeWithAnnotations type1, TypeWithAnnotations type2)
11767var result = TypeWithAnnotations.Create(node.Type, node.IsInferred ? NullableAnnotation.Annotated : node.NullableAnnotation);
11811TypeWithAnnotations elementType = InMethodBinder.GetIteratorElementTypeFromReturnType(compilation, RefKind.None,
11864var typeWithAnnotations = TypeWithAnnotations.Create(node.Type, node.NullableAnnotation);
11929var 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)
349var expressionTypeWithAnnotations = expressionTypeWithState.ToTypeWithAnnotations(compilation);
413var parameterType = method.Parameters[i + extensionExtra].TypeWithAnnotations;
438outputSlot = makeDagTempSlot(TypeWithAnnotations.Create(e.Type, NullableAnnotation.NotAnnotated), output);
451var type = field.TypeWithAnnotations;
497var type = property.TypeWithAnnotations;
522TypeWithAnnotations type = getIndexerOutputType(inputType, e.IndexerAccess, isSlice: false);
534TypeWithAnnotations type = getIndexerOutputType(inputType, e.IndexerAccess, isSlice: true);
646var inferredType = value.ToTypeWithAnnotations(compilation, asAnnotatedType: boundLocal.DeclarationKind == BoundLocalDeclarationKind.WithInferredType);
647if (_variables.TryGetType(local, out var existingType))
650inferredType = TypeWithAnnotations.Create(inferredType.Type, existingType.NullableAnnotation.Join(inferredType.NullableAnnotation));
793int makeDagTempSlot(TypeWithAnnotations type, BoundDagTemp temp)
801var type = TypeWithAnnotations.Create(t, NullableAnnotation.Annotated);
808static TypeWithAnnotations getIndexerOutputType(TypeSymbol inputType, BoundExpression e, bool isSlice)
816? TypeWithAnnotations.Create(isNullableEnabled: true, inputType, isAnnotated: false)
917var inferredTypeWithAnnotations = TypeWithAnnotations.Create(inferredType);
953TypeWithAnnotations inferredTypeWithAnnotations,
1000(TypeWithAnnotations inferredTypeWithAnnotations) =>
Generated\BoundNodes.xml.Generated.cs (9)
1068public BoundTypeExpression(SyntaxNode syntax, AliasSymbol? aliasOpt, BoundTypeExpression? boundContainingTypeOpt, ImmutableArray<BoundExpression> boundDimensionsOpt, TypeWithAnnotations typeWithAnnotations, TypeSymbol type, bool hasErrors = false)
1084public TypeWithAnnotations TypeWithAnnotations { get; }
1089public BoundTypeExpression Update(AliasSymbol? aliasOpt, BoundTypeExpression? boundContainingTypeOpt, ImmutableArray<BoundExpression> boundDimensionsOpt, TypeWithAnnotations typeWithAnnotations, TypeSymbol type)
5837public BoundDynamicMemberAccess(SyntaxNode syntax, BoundExpression receiver, ImmutableArray<TypeWithAnnotations> typeArgumentsOpt, string name, bool invoked, bool indexed, TypeSymbol type, bool hasErrors = false)
5854public ImmutableArray<TypeWithAnnotations> TypeArgumentsOpt { get; }
5862public BoundDynamicMemberAccess Update(BoundExpression receiver, ImmutableArray<TypeWithAnnotations> typeArgumentsOpt, string name, bool invoked, bool indexed, TypeSymbol type)
6074public 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)
6090public ImmutableArray<TypeWithAnnotations> TypeArgumentsOpt { get; }
6101public 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)
662var frameTypeParameters = ImmutableArray.Create(_currentTypeParameters.SelectAsArray(t => TypeWithAnnotations.Create(t)), 0, frame.Arity);
666LocalSymbol framePointer = new SynthesizedLocal(_topLevelMethod, TypeWithAnnotations.Create(frameType), SynthesizedLocalKind.LambdaDisplayClass, frame.ScopeSyntaxOpt);
960private ImmutableArray<TypeWithAnnotations> SubstituteTypeArguments(ImmutableArray<TypeWithAnnotations> typeArguments)
984var builder = ArrayBuilder<TypeWithAnnotations>.GetInstance(typeArguments.Length);
985foreach (var typeArg in typeArguments)
987TypeWithAnnotations oldTypeArg;
988TypeWithAnnotations newTypeArg = typeArg;
1013ImmutableArray<TypeWithAnnotations> typeArgumentsOpt,
1025var realTypeArguments = ImmutableArray.Create(_currentTypeParameters.SelectAsArray(t => TypeWithAnnotations.Create(t)), 0, totalTypeArgumentCount - originalMethod.Arity);
1651RemapLambdaOrLocalFunction(node.Syntax, node.Symbol, default(ImmutableArray<TypeWithAnnotations>), closureKind, ref referencedMethod, out receiver, out constructedFrame);
Lowering\LocalRewriter\LocalRewriter_CollectionExpression.cs (12)
46if (ConversionsBase.IsSpanOrListType(_compilation, node.Type, WellKnownType.System_Collections_Generic_List_T, out var listElementType))
63return VisitArrayOrSpanCollectionExpression(node, collectionTypeKind, node.Type, TypeWithAnnotations.Create(elementType));
66if (ConversionsBase.IsSpanOrListType(_compilation, node.Type, WellKnownType.System_Collections_Immutable_ImmutableArray_T, out var arrayElementType))
160private bool TryRewriteSingleElementSpreadToList(BoundCollectionExpression node, TypeWithAnnotations listElementType, [NotNullWhen(true)] out BoundExpression? result)
232private BoundExpression VisitImmutableArrayCollectionExpression(BoundCollectionExpression node, TypeWithAnnotations elementType, MethodSymbol asImmutableArray)
243private BoundExpression VisitArrayOrSpanCollectionExpression(BoundCollectionExpression node, CollectionExpressionTypeKind collectionTypeKind, TypeSymbol collectionType, TypeWithAnnotations elementType)
398var elementType = collectionType.TypeArgumentsWithAnnotationsNoUseSiteDiagnostics.Single();
468var elementType = spanType.TypeArgumentsWithAnnotationsNoUseSiteDiagnostics[0];
527TypeWithAnnotations elementType,
561Construct(ImmutableArray.Create(TypeWithAnnotations.Create(inlineArrayType), elementType));
590inlineArrayAsSpan = inlineArrayAsSpan.Construct(ImmutableArray.Create(TypeWithAnnotations.Create(inlineArrayType), elementType));
973private BoundExpression CreateAndPopulateList(BoundCollectionExpression node, TypeWithAnnotations elementType, ImmutableArray<BoundNode> elements)
Lowering\StateMachineRewriter\StateMachineFieldSymbol.cs (5)
21private readonly TypeWithAnnotations _type;
30public StateMachineFieldSymbol(NamedTypeSymbol stateMachineType, TypeWithAnnotations type, string name, bool isPublic, bool isThis)
42this(stateMachineType, TypeWithAnnotations.Create(type), name, slotDebugInfo, slotIndex, isPublic)
46public StateMachineFieldSymbol(NamedTypeSymbol stateMachineType, TypeWithAnnotations type, string name, LocalSlotDebugInfo slotDebugInfo, int slotIndex, bool isPublic)
66internal override TypeWithAnnotations GetFieldType(ConsList<FieldSymbol> fieldsBeingBound)
Lowering\SyntheticBoundNodeFactory.cs (12)
121typeArgs: typeArgs.IsDefault ? default(ImmutableArray<TypeWithAnnotations>) : typeArgs.SelectAsArray(t => TypeWithAnnotations.Create(t)),
221public StateMachineFieldSymbol StateMachineField(TypeWithAnnotations type, string name, bool isPublic = false, bool isThis = false)
232var result = new StateMachineFieldSymbol(CurrentType, TypeWithAnnotations.Create(type), name, isPublic, isThis);
646return new SynthesizedLocal(CurrentFunction, TypeWithAnnotations.Create(type), kind, syntax, isPinned,
666TypeWithAnnotations.Create(type),
677return SynthesizedParameterSymbol.Create(container, TypeWithAnnotations.Create(type), ordinal, RefKind.None, name);
1279public BoundExpression NullRef(TypeWithAnnotations type)
1330public BoundExpression Typeof(TypeWithAnnotations type, TypeSymbol systemType)
1335public ImmutableArray<BoundExpression> TypeOfs(ImmutableArray<TypeWithAnnotations> typeArguments, TypeSymbol systemType)
1738TypeWithAnnotations.Create(type),
1777temp = new SynthesizedLocal(this.CurrentFunction, TypeWithAnnotations.Create(node.Type), SynthesizedLocalKind.LoweringTemp);
Symbols\ArrayTypeSymbol.cs (24)
22private readonly TypeWithAnnotations _elementTypeWithAnnotations;
26TypeWithAnnotations elementTypeWithAnnotations,
38TypeWithAnnotations elementTypeWithAnnotations,
50TypeWithAnnotations elementTypeWithAnnotations,
67TypeWithAnnotations elementType,
76TypeWithAnnotations elementTypeWithAnnotations,
83TypeWithAnnotations elementTypeWithAnnotations,
92TypeWithAnnotations elementType)
97internal ArrayTypeSymbol WithElementType(TypeWithAnnotations elementTypeWithAnnotations)
102protected abstract ArrayTypeSymbol WithElementTypeCore(TypeWithAnnotations elementTypeWithAnnotations);
105TypeWithAnnotations elementTypeWithAnnotations,
201public TypeWithAnnotations ElementTypeWithAnnotations
393TypeWithAnnotations oldElementType = ElementTypeWithAnnotations;
394TypeWithAnnotations newElementType;
406internal override TypeSymbol SetNullabilityForReferenceTypes(Func<TypeWithAnnotations, TypeWithAnnotations> transform)
414TypeWithAnnotations elementType = ElementTypeWithAnnotations.MergeEquivalentTypes(((ArrayTypeSymbol)other).ElementTypeWithAnnotations, variance);
512TypeWithAnnotations elementTypeWithAnnotations,
521protected override ArrayTypeSymbol WithElementTypeCore(TypeWithAnnotations newElementType)
570TypeWithAnnotations elementTypeWithAnnotations,
604TypeWithAnnotations elementTypeWithAnnotations,
611protected override ArrayTypeSymbol WithElementTypeCore(TypeWithAnnotations elementTypeWithAnnotations)
631TypeWithAnnotations elementTypeWithAnnotations,
644protected override ArrayTypeSymbol WithElementTypeCore(TypeWithAnnotations elementTypeWithAnnotations)
Symbols\ConstraintsHelper.cs (31)
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;
893ImmutableArray<TypeWithAnnotations> typeArguments,
930TypeWithAnnotations typeArgument,
1033TypeWithAnnotations typeArgument,
1059var constraintTypes = ArrayBuilder<TypeWithAnnotations>.GetInstance();
1061ImmutableArray<TypeWithAnnotations> originalConstraintTypes = typeParameter.ConstraintTypesWithDefinitionUseSiteDiagnostics(ref useSiteInfo);
1093static bool errorIfNotSatisfiesConstructorConstraint(Symbol containingSymbol, TypeParameterSymbol typeParameter, TypeWithAnnotations typeArgument, ArrayBuilder<TypeParameterDiagnosticInfo> diagnosticsBuilder)
1119TypeWithAnnotations typeArgument,
1143TypeWithAnnotations typeArgument,
1147TypeWithAnnotations constraintType,
1199static NullableFlowState getTypeArgumentState(in TypeWithAnnotations typeWithAnnotations)
1223foreach (var constraintType in typeParameter.ConstraintTypesNoUseSiteDiagnostics)
1238static bool constraintTypeAllows(in TypeWithAnnotations typeWithAnnotations, NullableFlowState state)
1260foreach (var constraintType in typeParameter.ConstraintTypesNoUseSiteDiagnostics)
1319TypeWithAnnotations typeArgument,
1320TypeWithAnnotations constraintType,
1369foreach (var typeArgumentConstraint in typeParameter.ConstraintTypesWithDefinitionUseSiteDiagnostics(ref useSiteInfo))
1412private static bool IsReferenceType(TypeParameterSymbol typeParameter, ImmutableArray<TypeWithAnnotations> constraintTypes)
1417private static bool IsValueType(TypeParameterSymbol typeParameter, ImmutableArray<TypeWithAnnotations> constraintTypes)
1605internal static TypeWithAnnotations ConstraintWithMostSignificantNullability(TypeWithAnnotations type1, TypeWithAnnotations type2)
1625internal static bool IsObjectConstraint(TypeWithAnnotations type, ref TypeWithAnnotations bestObjectConstraint)
1651internal 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)
43private ImmutableArray<TypeWithAnnotations> _lazyDeclaredConstraintTypes;
150private ImmutableArray<TypeWithAnnotations> GetDeclaredConstraintTypes(ConsList<PETypeParameterSymbol> inProgress)
157ImmutableArray<TypeWithAnnotations> declaredConstraintTypes;
167var symbolsBuilder = ArrayBuilder<TypeWithAnnotations>.GetInstance();
170TypeWithAnnotations bestObjectConstraint = default;
175TypeWithAnnotations type = GetConstraintTypeOrDefault(moduleSymbol, metadataReader, tokenDecoder, constraintHandle, ref hasUnmanagedModreqPattern);
208foreach (TypeWithAnnotations constraintType in symbolsBuilder)
229declaredConstraintTypes = ImmutableArray<TypeWithAnnotations>.Empty;
264private TypeWithAnnotations GetConstraintTypeOrDefault(PEModuleSymbol moduleSymbol, MetadataReader metadataReader, MetadataDecoder tokenDecoder, GenericParameterConstraintHandle constraintHandle, ref bool hasUnmanagedModreqPattern)
302var type = TypeWithAnnotations.Create(typeSymbol);
308private static bool? IsNotNullableFromConstraintType(TypeWithAnnotations constraintType, ConsList<PETypeParameterSymbol> inProgress, out bool isNonNullableValueType)
353ImmutableArray<TypeWithAnnotations> constraintTypes = this.GetDeclaredConstraintTypes(inProgress);
379private static bool? IsNotNullableFromConstraintTypes(ImmutableArray<TypeWithAnnotations> constraintTypes, ConsList<PETypeParameterSymbol> inProgress, out bool isNonNullableValueType)
385foreach (TypeWithAnnotations constraintType in constraintTypes)
536var symbolsBuilder = ArrayBuilder<TypeWithAnnotations>.GetInstance();
543TypeWithAnnotations type = GetConstraintTypeOrDefault(moduleSymbol, metadataReader, tokenDecoder, constraintHandle, ref hasUnmanagedModreqPattern);
615internal override ImmutableArray<TypeWithAnnotations> GetConstraintTypes(ConsList<TypeParameterSymbol> inProgress)
618return (bounds != null) ? bounds.ConstraintTypes : ImmutableArray<TypeWithAnnotations>.Empty;
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 (5)
41parameterCreationFunc: (Binder context, Symbol owner, TypeWithAnnotations parameterType,
81parameterCreationFunc: (Binder binder, FunctionPointerMethodSymbol owner, TypeWithAnnotations parameterType,
124Func<Binder, TOwningSymbol, TypeWithAnnotations, TParameterSyntax, RefKind, int, SyntaxToken, SyntaxToken, bool, ScopedKind, BindingDiagnosticBag, TParameterSymbol> parameterCreationFunc,
181var parameterType = withTypeParametersBinder.BindType(parameterSyntax.Type, diagnostics, suppressUseSiteDiagnostics: suppressUseSiteDiagnostics);
652TypeWithAnnotations typeWithAnnotations,
Symbols\Source\SourceDelegateMethodSymbol.cs (24)
20private readonly TypeWithAnnotations _returnType;
24TypeWithAnnotations returnType,
56var returnType = binder.BindType(returnTypeSyntax, diagnostics);
59var voidType = TypeWithAnnotations.Create(binder.GetSpecialType(SpecialType.System_Void, diagnostics, syntax));
61var objectType = TypeWithAnnotations.Create(binder.GetSpecialType(SpecialType.System_Object, diagnostics, syntax));
62var intPtrType = TypeWithAnnotations.Create(binder.GetSpecialType(SpecialType.System_IntPtr, diagnostics, syntax));
84var iAsyncResultType = TypeWithAnnotations.Create(binder.GetSpecialType(SpecialType.System_IAsyncResult, diagnostics, syntax));
85var asyncCallbackType = TypeWithAnnotations.Create(binder.GetSpecialType(SpecialType.System_AsyncCallback, diagnostics, syntax));
152public override ImmutableArray<ImmutableArray<TypeWithAnnotations>> GetTypeParameterConstraintTypes()
153=> ImmutableArray<ImmutableArray<TypeWithAnnotations>>.Empty;
158public sealed override TypeWithAnnotations ReturnTypeWithAnnotations
213TypeWithAnnotations voidType,
214TypeWithAnnotations objectType,
215TypeWithAnnotations intPtrType,
258TypeWithAnnotations returnType,
351TypeWithAnnotations iAsyncResultType,
352TypeWithAnnotations objectType,
353TypeWithAnnotations asyncCallbackType,
391TypeWithAnnotations iAsyncResultType,
Symbols\Source\SourceMemberContainerSymbol.cs (13)
4255TypeWithAnnotations.Create(compilation.GetSpecialType(SpecialType.System_Void)),
4294TypeWithAnnotations.Create(this),
4303TypeWithAnnotations.Create(compilation.GetSpecialType(SpecialType.System_Void)),
4343TypeWithAnnotations.Create(compilation.GetWellKnownType(WellKnownType.System_Text_StringBuilder)),
4351returnType: TypeWithAnnotations.Create(compilation.GetSpecialType(SpecialType.System_Boolean)),
4406returnType: TypeWithAnnotations.Create(compilation.GetSpecialType(SpecialType.System_String)),
4578TypeWithAnnotations.Create(compilation.GetSpecialType(SpecialType.System_Int32)),
4607TypeWithAnnotations.Create(compilation.GetWellKnownType(WellKnownType.System_Type)),
4668TypeWithAnnotations.Create(this),
4677TypeWithAnnotations.Create(compilation.GetSpecialType(SpecialType.System_Boolean)),
5240builder.AddValue(TypeWithAnnotations.Create(baseType));
5244builder.AddValue(TypeWithAnnotations.Create(@interface));
5304AddSynthesizedAttribute(ref attributes, moduleBuilder.SynthesizeNullableAttributeIfNecessary(this, nullableContextValue, TypeWithAnnotations.Create(baseType)));
Symbols\Source\SourceNamedTypeSymbol.cs (23)
265internal ImmutableArray<TypeWithAnnotations> GetTypeParameterConstraintTypes(int ordinal)
268return (constraintTypes.Length > 0) ? constraintTypes[ordinal] : ImmutableArray<TypeWithAnnotations>.Empty;
271private ImmutableArray<ImmutableArray<TypeWithAnnotations>> GetTypeParameterConstraintTypes()
313private ImmutableArray<ImmutableArray<TypeWithAnnotations>> MakeTypeParameterConstraintTypes(BindingDiagnosticBag diagnostics)
507ImmutableArray<TypeWithAnnotations> originalConstraintTypes = constraint.ConstraintTypes;
508ArrayBuilder<TypeWithAnnotations> mergedConstraintTypes = null;
509SmallDictionary<TypeWithAnnotations, int> originalConstraintTypesMap = null;
556static bool mergeConstraints(ImmutableArray<TypeWithAnnotations> originalConstraintTypes,
557ref SmallDictionary<TypeWithAnnotations, int> originalConstraintTypesMap, ref ArrayBuilder<TypeWithAnnotations> mergedConstraintTypes,
577TypeWithAnnotations.EqualsComparer.IgnoreNullableModifiersForReferenceTypesComparer);
578SmallDictionary<TypeWithAnnotations, int> clauseConstraintTypesMap = toDictionary(clause.ConstraintTypes, originalConstraintTypesMap.Comparer);
582TypeWithAnnotations constraintType1 = mergedConstraintTypes?[index1] ?? originalConstraintTypes[index1];
592TypeWithAnnotations constraintType2 = clause.ConstraintTypes[index2];
606mergedConstraintTypes = ArrayBuilder<TypeWithAnnotations>.GetInstance(originalConstraintTypes.Length);
626static SmallDictionary<TypeWithAnnotations, int> toDictionary(ImmutableArray<TypeWithAnnotations> constraintTypes, IEqualityComparer<TypeWithAnnotations> comparer)
628var result = new SmallDictionary<TypeWithAnnotations, int>(comparer);
661ImmutableArray<TypeWithAnnotations> originalConstraintTypes = constraint.ConstraintTypes;
694static void mergeConstraints(ref TypeParameterConstraintKind mergedKind, ImmutableArray<TypeWithAnnotations> originalConstraintTypes, TypeParameterConstraintClause clause)
735internal sealed override ImmutableArray<TypeWithAnnotations> TypeArgumentsWithAnnotationsNoUseSiteDiagnostics
1862TypeWithAnnotations 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; }
392public override TypeWithAnnotations ReturnTypeWithAnnotations => TypeWithAnnotations.Create(_getAwaiterGetResultCall.Type);
444private readonly TypeWithAnnotations _returnType;
446internal ScriptEntryPoint(NamedTypeSymbol containingType, TypeWithAnnotations returnType) :
458public override TypeWithAnnotations ReturnTypeWithAnnotations => _returnType;
484new SynthesizedLocal(this, TypeWithAnnotations.Create(_containingType), SynthesizedLocalKind.LoweringTemp),
533private readonly TypeWithAnnotations _returnType;
535internal SubmissionEntryPoint(NamedTypeSymbol containingType, TypeWithAnnotations returnType, TypeSymbol submissionArrayType) :
541TypeWithAnnotations.Create(submissionArrayType), 0, RefKind.None, "submissionArray"));
556public override TypeWithAnnotations ReturnTypeWithAnnotations => _returnType;
576new SynthesizedLocal(this, TypeWithAnnotations.Create(_containingType), SynthesizedLocalKind.LoweringTemp),
Symbols\TypeMap.cs (21)
24public static readonly Func<TypeWithAnnotations, TypeSymbol> AsTypeSymbol = t => t.Type;
26internal static ImmutableArray<TypeWithAnnotations> TypeParametersAsTypeSymbolsWithAnnotations(ImmutableArray<TypeParameterSymbol> typeParameters)
28return typeParameters.SelectAsArray(static (tp) => TypeWithAnnotations.Create(tp));
31internal static ImmutableArray<TypeWithAnnotations> TypeParametersAsTypeSymbolsWithIgnoredAnnotations(ImmutableArray<TypeParameterSymbol> typeParameters)
33return typeParameters.SelectAsArray(static (tp) => TypeWithAnnotations.Create(tp, NullableAnnotation.Ignored));
36internal static ImmutableArray<TypeSymbol> AsTypeSymbols(ImmutableArray<TypeWithAnnotations> typesOpt)
42internal TypeMap(ImmutableArray<TypeParameterSymbol> from, ImmutableArray<TypeWithAnnotations> to, bool allowAlpha = false)
56private TypeMap(SmallDictionary<TypeParameterSymbol, TypeWithAnnotations> mapping)
57: base(new SmallDictionary<TypeParameterSymbol, TypeWithAnnotations>(mapping, ReferenceEqualityComparer.Instance))
62private static SmallDictionary<TypeParameterSymbol, TypeWithAnnotations> ForType(NamedTypeSymbol containingType)
66new SmallDictionary<TypeParameterSymbol, TypeWithAnnotations>(substituted.TypeSubstitution.Mapping, ReferenceEqualityComparer.Instance) :
67new SmallDictionary<TypeParameterSymbol, TypeWithAnnotations>(ReferenceEqualityComparer.Instance);
70internal TypeMap(NamedTypeSymbol containingType, ImmutableArray<TypeParameterSymbol> typeParameters, ImmutableArray<TypeWithAnnotations> typeArguments)
76TypeWithAnnotations ta = typeArguments[i];
84private static readonly SmallDictionary<TypeParameterSymbol, TypeWithAnnotations> s_emptyDictionary =
85new SmallDictionary<TypeParameterSymbol, TypeWithAnnotations>(ReferenceEqualityComparer.Instance);
130result.Mapping.Add(tp, TypeWithAnnotations.Create(newTp));
200private static SmallDictionary<TypeParameterSymbol, TypeWithAnnotations> ConstructMapping(ImmutableArray<TypeParameterSymbol> from, ImmutableArray<TypeWithAnnotations> to)
202var mapping = new SmallDictionary<TypeParameterSymbol, TypeWithAnnotations>(ReferenceEqualityComparer.Instance);
209TypeWithAnnotations ta = to[i];
Symbols\TypeSymbolExtensions.cs (31)
111foreach (var constraintType in constraintTypes)
161public static TypeWithAnnotations GetNullableUnderlyingTypeWithAnnotations(this TypeSymbol type)
369internal static bool IsArrayInterface(this TypeSymbol type, out TypeWithAnnotations typeArgument)
587public static bool TryGetElementTypesWithAnnotationsIfTupleType(this TypeSymbol type, out ImmutableArray<TypeWithAnnotations> elementTypes)
596elementTypes = default(ImmutableArray<TypeWithAnnotations>);
723/// <param name="useDefaultType">If true, use <see cref="TypeWithAnnotations.DefaultType"/>
724/// instead of <see cref="TypeWithAnnotations.Type"/> to avoid early resolution of nullable types</param>
726this TypeWithAnnotations typeWithAnnotationsOpt,
728Func<TypeWithAnnotations, T, bool, bool>? typeWithAnnotationsPredicate,
806TypeWithAnnotations next;
845(TypeWithAnnotations nextTypeWithAnnotations, TypeSymbol? nextType) = getNextIterationElements(fields[i].TypeWithAnnotations, canDigThroughNullable);
876(TypeWithAnnotations nextTypeWithAnnotations, TypeSymbol? nextType) = getNextIterationElements(typeArguments[i], canDigThroughNullable);
925static (TypeWithAnnotations, TypeSymbol?) getNextIterationElements(TypeWithAnnotations type, bool canDigThroughNullable)
926=> canDigThroughNullable ? (default(TypeWithAnnotations), type.NullableUnderlyingTypeOrSelf) : (type, null);
928static 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)
955(TypeWithAnnotations nextTypeWithAnnotations, TypeSymbol? nextType) = getNextIterationElements(currentPointer.Parameters[i].TypeWithAnnotations, canDigThroughNullable);
1228internal static bool ContainsNativeIntegerWrapperType(this TypeWithAnnotations type)
1545foreach (var arg in type.TypeArgumentsWithAnnotationsNoUseSiteDiagnostics)
1902private static bool NormalizeTaskTypesInType(CSharpCompilation compilation, ref TypeWithAnnotations typeWithAnnotations)
1907typeWithAnnotations = TypeWithAnnotations.Create(type, customModifiers: typeWithAnnotations.CustomModifiers);
1920var typeArgumentsBuilder = ArrayBuilder<TypeWithAnnotations>.GetInstance();
1931typeArgumentsBuilder[i] = TypeWithAnnotations.Create(typeArgNormalized, customModifiers: typeWithModifier.CustomModifiers);
1971var elementType = arrayType.ElementTypeWithAnnotations;
1982var pointedAtType = pointerType.PointedAtTypeWithAnnotations;
1994var returnType = funcPtrType.Signature.ReturnTypeWithAnnotations;
1997var paramTypes = ImmutableArray<TypeWithAnnotations>.Empty;
2001var paramsBuilder = ArrayBuilder<TypeWithAnnotations>.GetInstance(funcPtrType.Signature.ParameterCount);
2005var paramType = param.TypeWithAnnotations;
2034this 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)