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);
306return (TypeParameterConstraintClause.Create(constraints, constraintTypes?.ToImmutableAndFree() ?? ImmutableArray<TypeWithAnnotations>.Empty), syntaxBuilder);
371var constraintTypeBuilder = ArrayBuilder<TypeWithAnnotations>.GetInstance();
376var constraintType = constraintTypes[i];
407TypeWithAnnotations constraintType,
444TypeWithAnnotations type,
446ArrayBuilder<TypeWithAnnotations> constraintTypes,
512static 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 (54)
365var type = new PointerTypeSymbol(TypeWithAnnotations.Create(boundStackAlloc.ElementType));
895var declType = BindVariableTypeWithAnnotations(node.Designation, diagnostics, node.Type.SkipScoped(out _).SkipRef(), ref isConst, out isVar, out alias);
903private BoundExpression BindDeclarationVariablesForErrorRecovery(TypeWithAnnotations declTypeWithAnnotations, VariableDesignationSyntax node, CSharpSyntaxNode syntax, BindingDiagnosticBag diagnostics)
905declTypeWithAnnotations = declTypeWithAnnotations.HasType ? declTypeWithAnnotations : TypeWithAnnotations.Create(CreateErrorType("var"));
944subExpressions.SelectAsArray(e => TypeWithAnnotations.Create(e.Type)),
979var elementTypesWithAnnotations = ArrayBuilder<TypeWithAnnotations>.GetInstance(arguments.Count);
1011var elementTypeWithAnnotations = TypeWithAnnotations.Create(boundArgument.Type);
1196TypeWithAnnotations typeWithAnnotations = BindType(node.Type, diagnostics);
1337TypeWithAnnotations typeWithAnnotations = typeofBinder.BindType(typeSyntax, diagnostics, out alias);
1361private void CheckDisallowedAttributeDependentType(TypeWithAnnotations typeArgument, Location errorLocation, BindingDiagnosticBag diagnostics)
1390TypeWithAnnotations typeWithAnnotations = this.BindType(typeSyntax, diagnostics, out alias);
1446TypeWithAnnotations typeWithAnnotations = this.BindType(node.Type, diagnostics, out AliasSymbol alias);
1503default(ImmutableArray<TypeWithAnnotations>);
2327TypeWithAnnotations targetTypeWithAnnotations = this.BindType(node.Type, diagnostics);
2488private BoundExpression BindCastCore(ExpressionSyntax node, BoundExpression operand, TypeWithAnnotations targetTypeWithAnnotations, bool wasCompilerGenerated, BindingDiagnosticBag diagnostics)
2576var targetElementTypesWithAnnotations = default(ImmutableArray<TypeWithAnnotations>);
2631ImmutableArray<TypeWithAnnotations> targetElementTypesWithAnnotations)
2662private BoundExpression BindExplicitNullableCastFromNonNullable(ExpressionSyntax node, BoundExpression operand, TypeWithAnnotations targetTypeWithAnnotations, BindingDiagnosticBag diagnostics)
2670TypeWithAnnotations underlyingTargetTypeWithAnnotations = targetTypeWithAnnotations.Type.GetNullableUnderlyingTypeWithAnnotations();
2912var declType = BindVariableTypeWithAnnotations(designation, diagnostics, typeSyntax, ref isConst, out isVar, out alias);
2959var declType = BindVariableTypeWithAnnotations(declarationExpression, diagnostics, typeSyntax, ref isConst, out isVar, out alias);
3176TypeWithAnnotations parameterTypeWithAnnotations = GetCorrespondingParameterTypeWithAnnotations(ref result, parameters, arg);
3183TypeWithAnnotations parameterTypeWithAnnotations = GetCorrespondingParameterTypeWithAnnotations(ref result, parameters, arg);
3190TypeWithAnnotations parameterTypeWithAnnotations = GetCorrespondingParameterTypeWithAnnotations(ref result, parameters, arg);
3195TypeWithAnnotations parameterTypeWithAnnotations = GetCorrespondingParameterTypeWithAnnotations(ref result, parameters, arg);
3200TypeWithAnnotations parameterTypeWithAnnotations = GetCorrespondingParameterTypeWithAnnotations(ref result, parameters, arg);
3209TypeWithAnnotations parameterTypeWithAnnotations = GetCorrespondingParameterTypeWithAnnotations(ref result, parameters, arg);
3220void reportUnsafeIfNeeded(MemberResolutionResult<TMember> methodResult, BindingDiagnosticBag diagnostics, BoundExpression argument, TypeWithAnnotations parameterTypeWithAnnotations)
3239private static TypeWithAnnotations GetCorrespondingParameterTypeWithAnnotations(ref MemberAnalysisResult result, ImmutableArray<ParameterSymbol> parameters, int arg)
3242var type = parameters[paramNum].TypeWithAnnotations;
3430var arrayType = ArrayTypeSymbol.CreateCSharpArray(Compilation.Assembly, TypeWithAnnotations.Create(bestType), rank);
3459type: GetStackAllocType(node, TypeWithAnnotations.Create(bestType), diagnostics, out bool hasErrors),
3805var elementType = arrayType.ElementTypeWithAnnotations;
3890private TypeSymbol GetStackAllocType(SyntaxNode node, TypeWithAnnotations elementTypeWithAnnotations, BindingDiagnosticBag diagnostics, out bool hasErrors)
4358typeArgumentsWithAnnotations: ImmutableArray<TypeWithAnnotations>.Empty,
4431var typeWithAnnotations = BindType(node.Type, diagnostics);
6475ImmutableArray<TypeWithAnnotations> typeArgumentsWithAnnotations = rightHasTypeArguments ?
6477default(ImmutableArray<TypeWithAnnotations>);
6492var typeArgument = typeArgumentsWithAnnotations[i];
6520/// <see cref="MakeQueryInvocation(CSharpSyntaxNode, BoundExpression, string, TypeSyntax, TypeWithAnnotations, BindingDiagnosticBag, string)"/>.
6595var typeArguments = typeArgumentsSyntax.Count > 0 ? BindTypeArguments(typeArgumentsSyntax, diagnostics) : default(ImmutableArray<TypeWithAnnotations>);
6691ImmutableArray<TypeWithAnnotations> typeArguments,
6765ImmutableArray<TypeWithAnnotations> typeArguments,
6861ImmutableArray<TypeWithAnnotations> typeArgumentsWithAnnotations,
7076default(ImmutableArray<TypeWithAnnotations>),
7158ImmutableArray<TypeWithAnnotations> typeArgumentsWithAnnotations,
7235typeWithAnnotations: TypeWithAnnotations.Create(type));
7274ImmutableArray<TypeWithAnnotations> typeArgumentsWithAnnotations,
7380ImmutableArray<TypeWithAnnotations> typeArgumentsWithAnnotations,
8418var finalApplicableCandidates = GetCandidatesPassingFinalValidation(syntax, overloadResolutionResult, receiver, default(ImmutableArray<TypeWithAnnotations>), diagnostics);
9188TypeWithAnnotations? returnTypeOverride = null)
9193var returnType = returnTypeOverride ?? methodSymbol.ReturnTypeWithAnnotations;
9274static bool checkConstraints(CSharpCompilation compilation, ConversionsBase conversions, NamedTypeSymbol delegateType, ImmutableArray<TypeWithAnnotations> typeArguments)
Binder\Binder_Patterns.cs (12)
332declType: TypeWithAnnotations.Create(narrowedType, NullableAnnotation.NotAnnotated),
849TypeWithAnnotations declType = BindType(typeSyntax, diagnostics, out AliasSymbol aliasOpt);
858TypeWithAnnotations declType,
917private TypeWithAnnotations BindRecursivePatternType(
933return TypeWithAnnotations.Create(inputType.StrippedType(), NullableAnnotation.NotAnnotated);
964TypeWithAnnotations declTypeWithAnnotations = BindRecursivePatternType(typeSyntax, inputType, diagnostics, ref hasErrors, out BoundTypeExpression? boundDeclType);
979positionalClause, declType, ImmutableArray<TypeWithAnnotations>.Empty, permitDesignations, ref hasErrors, patternsBuilder, diagnostics);
1147ImmutableArray<TypeWithAnnotations> elementTypesWithAnnotations,
1348var declType = TypeWithState.ForType(inputType).ToTypeWithAnnotations(Compilation);
1375addSubpatternsForTuple(ImmutableArray<TypeWithAnnotations>.Empty);
1424void addSubpatternsForTuple(ImmutableArray<TypeWithAnnotations> elementTypes)
1547typeArgumentsWithAnnotations: default(ImmutableArray<TypeWithAnnotations>),
Binder\Binder_Query.cs (8)
56var typeRestriction = BindTypeArgument(fromClause.Type, diagnostics);
397var castType = BindTypeArgument(join.Type, diagnostics);
817new AnonymousTypeField(fieldName, fieldValue.Syntax.Location, TypeWithAnnotations.Create(TypeOrError(fieldValue)), RefKind.None, ScopedKind.None);
841private UnboundLambda MakeQueryUnboundLambdaWithCast(RangeVariableMap qvm, RangeVariableSymbol parameter, ExpressionSyntax expression, TypeSyntax castTypeSyntax, TypeWithAnnotations castType, bool withDependencies)
879return MakeQueryInvocation(node, receiver, methodName, default(SeparatedSyntaxList<TypeSyntax>), default(ImmutableArray<TypeWithAnnotations>), ImmutableArray.Create(arg), diagnostics
892return MakeQueryInvocation(node, receiver, methodName, default(SeparatedSyntaxList<TypeSyntax>), default(ImmutableArray<TypeWithAnnotations>), args, diagnostics
899protected BoundCall MakeQueryInvocation(CSharpSyntaxNode node, BoundExpression receiver, string methodName, TypeSyntax typeArgSyntax, TypeWithAnnotations typeArg, BindingDiagnosticBag diagnostics
912protected BoundCall MakeQueryInvocation(CSharpSyntaxNode node, BoundExpression receiver, string methodName, SeparatedSyntaxList<TypeSyntax> typeArgsSyntax, ImmutableArray<TypeWithAnnotations> typeArgs, ImmutableArray<BoundExpression> args, BindingDiagnosticBag diagnostics
Binder\Binder_Statements.cs (13)
722TypeWithAnnotations declType = BindVariableTypeWithAnnotations(node.Declaration, diagnostics, typeSyntax, ref isConst, isVar: out isVar, alias: out alias);
787private TypeWithAnnotations BindVariableTypeWithAnnotations(CSharpSyntaxNode declarationNode, BindingDiagnosticBag diagnostics, TypeSyntax typeSyntax, ref bool isConst, out bool isVar, out AliasSymbol alias)
800TypeWithAnnotations declType = BindTypeOrVarKeyword(typeSyntax.SkipScoped(out _).SkipRef(), diagnostics, out isVar, out alias);
955TypeWithAnnotations declTypeOpt,
981TypeWithAnnotations declTypeOpt,
1026declTypeOpt = TypeWithAnnotations.Create(initializerType);
1031declTypeOpt = TypeWithAnnotations.Create(CreateErrorType("var"));
1046declTypeOpt = TypeWithAnnotations.Create(CreateErrorType("var"));
1374TypeSymbol pointerType = new PointerTypeSymbol(TypeWithAnnotations.Create(elementType));
1479return op1.SetInferredTypeWithAnnotations(TypeWithAnnotations.Create(inferredType));
2298var targetElementTypes = default(ImmutableArray<TypeWithAnnotations>);
2468ImmutableArray<TypeWithAnnotations> targetElementTypes)
2720TypeWithAnnotations declType = BindTypeOrVarKeyword(typeSyntax, diagnostics, out isVar, out alias);
Binder\Binder_Symbols.cs (37)
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)
300internal TypeWithAnnotations BindType(ExpressionSyntax syntax, BindingDiagnosticBag diagnostics, ConsList<TypeSymbol> basesBeingResolved = null, bool suppressUseSiteDiagnostics = false)
309internal TypeWithAnnotations BindType(ExpressionSyntax syntax, BindingDiagnosticBag diagnostics, out AliasSymbol alias, ConsList<TypeSymbol> basesBeingResolved = null)
339return TypeWithAnnotations.Create(new ExtendedErrorTypeSymbol(GetContainingNamespaceOrType(symbol.Symbol), symbol.Symbol, LookupResultKind.NotATypeOrNamespace, diagnosticInfo));
399/// stack frames due to their use of large struct like <see cref="TypeWithAnnotations"/>.
457return TypeWithAnnotations.Create(
473return TypeWithAnnotations.Create(AreNullableAnnotationsEnabled(tupleTypeSyntax.CloseParenToken), BindTupleType(tupleTypeSyntax, diagnostics, basesBeingResolved));
519void reportNullableReferenceTypesIfNeeded(SyntaxToken questionToken, TypeWithAnnotations typeArgument = default)
541TypeWithAnnotations typeArgument = BindType(typeArgumentSyntax, diagnostics, basesBeingResolved);
542TypeWithAnnotations constructedType = typeArgument.SetIsAnnotated(Compilation);
569return TypeWithAnnotations.Create(AreNullableAnnotationsEnabled(predefinedType.Keyword), type);
582return TypeWithAnnotations.Create(new ExtendedErrorTypeSymbol(left, LookupResultKind.NotATypeOrNamespace, diagnostics.Add(ErrorCode.ERR_ColColWithTypeAlias, node.Alias.Location, node.Alias.Identifier.Text)));
591var elementType = BindType(node.ElementType, diagnostics, basesBeingResolved);
599return TypeWithAnnotations.Create(new PointerTypeSymbol(elementType));
605return TypeWithAnnotations.Create(CreateErrorType());
609internal static CSDiagnosticInfo? GetNullableUnconstrainedTypeParameterDiagnosticIfNecessary(LanguageVersion languageVersion, in TypeWithAnnotations type)
625private TypeWithAnnotations BindArrayType(
632TypeWithAnnotations type = BindType(node.ElementType, diagnostics, basesBeingResolved);
668type = TypeWithAnnotations.Create(AreNullableAnnotationsEnabled(rankSpecifier.CloseBracketToken), array);
679var types = ArrayBuilder<TypeWithAnnotations>.GetInstance(numElements);
691var argumentType = BindType(argumentSyntax.Type, diagnostics, basesBeingResolved);
832return TypeWithAnnotations.Create(new ExtendedErrorTypeSymbol(qualifierOpt ?? this.Compilation.Assembly.GlobalNamespace, string.Empty, arity: 0, errorInfo: null));
858return TypeWithAnnotations.Create(new ExtendedErrorTypeSymbol(
866return TypeWithAnnotations.Create(errorResult);
1148private TypeWithAnnotations BindGenericSimpleNamespaceOrTypeOrAliasSymbol(
1254return TypeWithAnnotations.Create(AreNullableAnnotationsEnabled(node.TypeArgumentList.GreaterThanToken), resultType);
1335private ImmutableArray<TypeWithAnnotations> BindTypeArguments(SeparatedSyntaxList<TypeSyntax> typeArguments, BindingDiagnosticBag diagnostics, ConsList<TypeSymbol> basesBeingResolved = null)
1338var args = ArrayBuilder<TypeWithAnnotations>.GetInstance(typeArguments.Count);
1347private TypeWithAnnotations BindTypeArgument(TypeSyntax typeArgument, BindingDiagnosticBag diagnostics, ConsList<TypeSymbol> basesBeingResolved = null)
1360var arg = typeArgument.Kind() == SyntaxKind.OmittedTypeArgument
1361? TypeWithAnnotations.Create(UnboundArgumentErrorTypeSymbol.Instance)
1370private NamedTypeSymbol ConstructNamedTypeUnlessTypeArgumentOmitted(SyntaxNode typeSyntax, NamedTypeSymbol type, SeparatedSyntaxList<TypeSyntax> typeArgumentsSyntax, ImmutableArray<TypeWithAnnotations> typeArguments, BindingDiagnosticBag diagnostics)
1398ImmutableArray<TypeWithAnnotations> typeArguments,
1555ImmutableArray<TypeWithAnnotations> typeArguments,
1624TypeWithAnnotations type = right.TypeWithAnnotations;
Binder\ForEachLoopBinder.cs (15)
179TypeWithAnnotations inferredType;
212TypeWithAnnotations inferredType;
250TypeWithAnnotations iterationVariableType;
284TypeWithAnnotations declType = BindTypeOrVarKeyword(typeSyntax, diagnostics, out isVar, out alias);
288declType = inferredType.HasType ? inferredType : TypeWithAnnotations.Create(CreateErrorType("var"));
348iterationVariableType = inferredType.HasType ? inferredType : TypeWithAnnotations.Create(CreateErrorType("var"));
606internal TypeWithAnnotations InferCollectionElementType(BindingDiagnosticBag diagnostics, ExpressionSyntax collectionSyntax)
612GetEnumeratorInfoAndInferCollectionElementType(ref builder, ref collectionExpr, diagnostics, out TypeWithAnnotations inferredType);
616private bool GetEnumeratorInfoAndInferCollectionElementType(ref ForEachEnumeratorInfo.Builder builder, ref BoundExpression collectionExpr, BindingDiagnosticBag diagnostics, out TypeWithAnnotations inferredType)
627inferredType = TypeWithAnnotations.Create(DynamicTypeSymbol.Instance);
635inferredType = TypeWithAnnotations.Create(GetSpecialType(SpecialType.System_Char, diagnostics, collectionExpr.Syntax));
988builder.ElementTypeWithAnnotations = builder.CurrentPropertyGetter?.ReturnTypeWithAnnotations ?? TypeWithAnnotations.Create(GetSpecialType(SpecialType.System_Object, diagnostics, errorLocationSyntax));
1080builder.ElementTypeWithAnnotations = TypeWithAnnotations.Create(
1088TypeWithAnnotations.Create(GetSpecialType(SpecialType.System_Char, diagnostics, _syntax)) :
1217var typeArguments = ArrayBuilder<TypeWithAnnotations>.GetInstance();
Binder\Semantics\Conversions\ConversionsBase.cs (33)
1410if (anonymousFunction.HasExplicitReturnType(out var refKind, out var returnType))
1686internal bool HasTopLevelNullabilityIdentityConversion(TypeWithAnnotations source, TypeWithAnnotations destination)
1718internal bool HasTopLevelNullabilityImplicitConversion(TypeWithAnnotations source, TypeWithAnnotations destination)
1738private static bool IsPossiblyNullableTypeTypeParameter(in TypeWithAnnotations typeWithAnnotations)
1749public bool HasAnyNullabilityImplicitConversion(TypeWithAnnotations source, TypeWithAnnotations destination)
1813(ConversionsBase conversions, BoundExpression s, TypeWithAnnotations d, bool isChecked, ref CompoundUseSiteInfo<AssemblySymbol> u, bool forCast) =>
1830(ConversionsBase conversions, TypeWithAnnotations s, TypeWithAnnotations d, bool _, ref CompoundUseSiteInfo<AssemblySymbol> u, bool _) =>
2132private delegate Conversion ClassifyConversionFromExpressionDelegate(ConversionsBase conversions, BoundExpression sourceExpression, TypeWithAnnotations destination, bool isChecked, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo, bool forCast);
2133private delegate Conversion ClassifyConversionFromTypeDelegate(ConversionsBase conversions, TypeWithAnnotations source, TypeWithAnnotations destination, bool isChecked, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo, bool forCast);
2147(ConversionsBase conversions, BoundExpression s, TypeWithAnnotations d, bool isChecked, ref CompoundUseSiteInfo<AssemblySymbol> u, bool forCast)
2165(ConversionsBase conversions, BoundExpression s, TypeWithAnnotations d, bool isChecked, ref CompoundUseSiteInfo<AssemblySymbol> u, bool forCast) =>
2218(ConversionsBase conversions, TypeWithAnnotations s, TypeWithAnnotations d, bool _, ref CompoundUseSiteInfo<AssemblySymbol> u, bool _) =>
2237(ConversionsBase conversions, TypeWithAnnotations s, TypeWithAnnotations d, bool isChecked, ref CompoundUseSiteInfo<AssemblySymbol> u, bool forCast) =>
2258ImmutableArray<TypeWithAnnotations> sourceTypes;
2259ImmutableArray<TypeWithAnnotations> destTypes;
2443TypeWithAnnotations elementType = source.ElementTypeWithAnnotations;
2444TypeWithAnnotations argument0 = destinationAgg.TypeArgumentWithDefinitionUseSiteDiagnostics(0, ref useSiteInfo);
2454private bool HasImplicitReferenceConversion(TypeWithAnnotations source, TypeWithAnnotations destination, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
2938var typeParameters = ArrayBuilder<TypeWithAnnotations>.GetInstance();
2939var sourceTypeArguments = ArrayBuilder<TypeWithAnnotations>.GetInstance();
2940var destinationTypeArguments = ArrayBuilder<TypeWithAnnotations>.GetInstance();
2954var sourceTypeArgument = sourceTypeArguments[paramIndex];
2955var destinationTypeArgument = destinationTypeArguments[paramIndex];
3186bool hasConversion(RefKind refKind, TypeWithAnnotations sourceType, TypeWithAnnotations destinationType, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
Binder\Semantics\OverloadResolution\MethodTypeInference.cs (167)
72public readonly ImmutableArray<TypeWithAnnotations> InferredTypeArguments;
81ImmutableArray<TypeWithAnnotations> inferredTypeArguments,
96internal abstract TypeWithAnnotations GetTypeWithAnnotations(BoundExpression expr);
98internal abstract TypeWithAnnotations GetMethodGroupResultType(BoundMethodGroup group, MethodSymbol method);
102internal override TypeWithAnnotations GetTypeWithAnnotations(BoundExpression expr)
104return TypeWithAnnotations.Create(expr.GetTypeOrFunctionType());
107internal override TypeWithAnnotations GetMethodGroupResultType(BoundMethodGroup group, MethodSymbol method)
135private readonly ImmutableArray<TypeWithAnnotations> _formalParameterTypes;
140private readonly (TypeWithAnnotations Type, bool FromFunctionType)[] _fixedResults;
141private readonly HashSet<TypeWithAnnotations>[] _exactBounds;
142private readonly HashSet<TypeWithAnnotations>[] _upperBounds;
143private readonly HashSet<TypeWithAnnotations>[] _lowerBounds;
173ImmutableArray<TypeWithAnnotations> formalParameterTypes,
318ImmutableArray<TypeWithAnnotations> formalParameterTypes,
331_fixedResults = new (TypeWithAnnotations, bool)[methodTypeParameters.Length];
332_exactBounds = new HashSet<TypeWithAnnotations>[methodTypeParameters.Length];
333_upperBounds = new HashSet<TypeWithAnnotations>[methodTypeParameters.Length];
334_lowerBounds = new HashSet<TypeWithAnnotations>[methodTypeParameters.Length];
400var fixedType = _fixedResults[i].Type;
428private ImmutableArray<TypeWithAnnotations> GetResults(out bool inferredFromFunctionType)
448var fixedResultType = _fixedResults[i].Type;
466_fixedResults[i] = (TypeWithAnnotations.Create(new ExtendedErrorTypeSymbol(_constructedContainingTypeOfMethod, _methodTypeParameters[i].Name, 0, null, false)), false);
483private bool IsUnfixedTypeParameter(TypeWithAnnotations type)
508private void AddBound(TypeWithAnnotations addedBound, HashSet<TypeWithAnnotations>[] collectedBounds, TypeWithAnnotations methodTypeParameterWithAnnotations)
517collectedBounds[methodTypeParameterIndex] = new HashSet<TypeWithAnnotations>(TypeWithAnnotations.EqualsComparer.ConsiderEverythingComparer);
543static (typeParameter, i, self) => self.IsUnfixed(i) ? TypeWithAnnotations.Create(typeParameter) : self._fixedResults[i].Type,
585TypeWithAnnotations target = _formalParameterTypes[arg];
592private void MakeExplicitParameterTypeInferences(BoundExpression argument, TypeWithAnnotations target, ExactOrBoundsKind kind, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
616var argumentType = _extensions.GetTypeWithAnnotations(argument);
629private bool MakeExplicitParameterTypeInferences(BoundTupleLiteral argument, TypeWithAnnotations target, ExactOrBoundsKind kind, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
661var destType = destTypes[i];
779var formalType = _formalParameterTypes[arg];
785private void MakeOutputTypeInferences(Binder binder, BoundExpression argument, TypeWithAnnotations formalType, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
804private void MakeOutputTypeInferences(Binder binder, BoundTupleLiteral argument, TypeWithAnnotations formalType, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
829var destType = destTypes[i];
1250private void OutputTypeInference(Binder binder, BoundExpression expression, TypeWithAnnotations target, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
1275var sourceType = _extensions.GetTypeWithAnnotations(expression);
1283private bool InferredReturnTypeInference(BoundExpression source, TypeWithAnnotations target, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
1301var returnType = delegateType.DelegateInvokeMethod.ReturnTypeWithAnnotations;
1307var inferredReturnType = InferReturnType(source, delegateType, ref useSiteInfo);
1356TypeWithAnnotations sourceReturnType = method.ReturnTypeWithAnnotations;
1375var returnType = MethodGroupReturnType(binder, originalMethodGroup, fixedParameters, method.RefKind, isFunctionPointerResolution, ref useSiteInfo, in callingConventionInfo);
1385private TypeWithAnnotations MethodGroupReturnType(
1402TypeWithAnnotations type = default;
1424private void ExplicitParameterTypeInference(BoundExpression source, TypeWithAnnotations target, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
1479private void ExplicitReturnTypeInference(BoundExpression source, TypeWithAnnotations target, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
1496if (!anonymousFunction.HasExplicitReturnType(out _, out TypeWithAnnotations anonymousFunctionReturnType))
1515private void ExactInference(TypeWithAnnotations source, TypeWithAnnotations target, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
1562private bool ExactTypeParameterInference(TypeWithAnnotations source, TypeWithAnnotations target)
1577private bool ExactArrayInference(TypeWithAnnotations source, TypeWithAnnotations target, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
1607private void ExactOrBoundsInference(ExactOrBoundsKind kind, TypeWithAnnotations source, TypeWithAnnotations target, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
1623private bool ExactOrBoundsNullableInference(ExactOrBoundsKind kind, TypeWithAnnotations source, TypeWithAnnotations target, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
1643static bool isNullableOnly(TypeWithAnnotations type)
1647private bool ExactNullableInference(TypeWithAnnotations source, TypeWithAnnotations target, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
1652private bool LowerBoundTupleInference(TypeWithAnnotations source, TypeWithAnnotations target, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
1661ImmutableArray<TypeWithAnnotations> sourceTypes;
1662ImmutableArray<TypeWithAnnotations> targetTypes;
1679private bool ExactConstructedInference(TypeWithAnnotations source, TypeWithAnnotations target, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
1709private bool ExactPointerInference(TypeWithAnnotations source, TypeWithAnnotations target, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
1769var sourceTypeArguments = ArrayBuilder<TypeWithAnnotations>.GetInstance();
1770var targetTypeArguments = ArrayBuilder<TypeWithAnnotations>.GetInstance();
1790private void LowerBoundInference(TypeWithAnnotations source, TypeWithAnnotations target, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
1877private bool LowerBoundTypeParameterInference(TypeWithAnnotations source, TypeWithAnnotations target)
1892private static TypeWithAnnotations GetMatchingElementType(ArrayTypeSymbol source, TypeSymbol target, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
1946var elementSource = arraySource.ElementTypeWithAnnotations;
1947var elementTarget = GetMatchingElementType(arraySource, target, ref useSiteInfo);
1965private bool LowerBoundNullableInference(TypeWithAnnotations source, TypeWithAnnotations target, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
2167var sourceTypeArguments = ArrayBuilder<TypeWithAnnotations>.GetInstance();
2168var targetTypeArguments = ArrayBuilder<TypeWithAnnotations>.GetInstance();
2180var sourceTypeArgument = sourceTypeArguments[arg];
2181var targetTypeArgument = targetTypeArguments[arg];
2254private void UpperBoundInference(TypeWithAnnotations source, TypeWithAnnotations target, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
2315private bool UpperBoundTypeParameterInference(TypeWithAnnotations source, TypeWithAnnotations target)
2329private bool UpperBoundArrayInference(TypeWithAnnotations source, TypeWithAnnotations target, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
2347var elementTarget = arrayTarget.ElementTypeWithAnnotations;
2348var elementSource = GetMatchingElementType(arrayTarget, source.Type, ref useSiteInfo);
2366private bool UpperBoundNullableInference(TypeWithAnnotations source, TypeWithAnnotations target, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
2371private bool UpperBoundConstructedInference(TypeWithAnnotations sourceWithAnnotations, TypeWithAnnotations targetWithAnnotations, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
2517var sourceTypeArguments = ArrayBuilder<TypeWithAnnotations>.GetInstance();
2518var targetTypeArguments = ArrayBuilder<TypeWithAnnotations>.GetInstance();
2530var sourceTypeArgument = sourceTypeArguments[arg];
2531var targetTypeArgument = targetTypeArguments[arg];
2624var withoutNullability = Fix(_compilation, _conversions.WithNullability(false), typeParameter, exact, lower, upper, ref discardedUseSiteInfo).Type;
2636private static (TypeWithAnnotations Type, bool FromFunctionType) Fix(
2640HashSet<TypeWithAnnotations>? exact,
2641HashSet<TypeWithAnnotations>? lower,
2642HashSet<TypeWithAnnotations>? upper,
2657var candidates = new Dictionary<TypeWithAnnotations, TypeWithAnnotations>(EqualsIgnoringDynamicTupleNamesAndNullabilityComparer.Instance);
2704var initialCandidates = ArrayBuilder<TypeWithAnnotations>.GetInstance();
2729TypeWithAnnotations best = default;
2730foreach (var candidate in initialCandidates)
2732foreach (var candidate2 in initialCandidates)
2770best = TypeWithAnnotations.Create(resultType, best.NullableAnnotation);
2776static bool containsFunctionTypes([NotNullWhen(true)] HashSet<TypeWithAnnotations>? types)
2781static bool containsNonFunctionTypes([NotNullWhen(true)] HashSet<TypeWithAnnotations>? types)
2786static bool isFunctionType(TypeWithAnnotations type, [NotNullWhen(true)] out FunctionTypeSymbol? functionType)
2811static HashSet<TypeWithAnnotations>? removeTypes(HashSet<TypeWithAnnotations>? types, Func<TypeWithAnnotations, bool> predicate)
2817HashSet<TypeWithAnnotations>? updated = null;
2818foreach (var type in types)
2822updated ??= new HashSet<TypeWithAnnotations>(TypeWithAnnotations.EqualsComparer.ConsiderEverythingComparer);
2830private static bool ImplicitConversionExists(TypeWithAnnotations sourceWithAnnotations, TypeWithAnnotations destinationWithAnnotations, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo, ConversionsBase conversions)
2854private TypeWithAnnotations InferReturnType(BoundExpression source, NamedTypeSymbol target, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
2935var returnType = anonymousFunction.InferReturnType(_conversions, fixedDelegate, ref useSiteInfo, out bool inferredFromFunctionType);
2994public static ImmutableArray<TypeWithAnnotations> InferTypeArgumentsFromFirstArgument(
3008return default(ImmutableArray<TypeWithAnnotations>);
3027return default(ImmutableArray<TypeWithAnnotations>);
3041var dest = _formalParameterTypes[0];
3073private ImmutableArray<TypeWithAnnotations> GetInferredTypeArguments(out bool inferredFromFunctionType)
3075var builder = ArrayBuilder<TypeWithAnnotations>.GetInstance(_fixedResults.Length);
3095private static void GetAllCandidates(Dictionary<TypeWithAnnotations, TypeWithAnnotations> candidates, ArrayBuilder<TypeWithAnnotations> builder)
3101Dictionary<TypeWithAnnotations, TypeWithAnnotations> candidates,
3102HashSet<TypeWithAnnotations> bounds,
3106foreach (var candidate in bounds)
3108var type = candidate;
3124Dictionary<TypeWithAnnotations, TypeWithAnnotations> candidates,
3125TypeWithAnnotations newCandidate,
3128if (candidates.TryGetValue(newCandidate, out TypeWithAnnotations oldCandidate))
3139Dictionary<TypeWithAnnotations, TypeWithAnnotations> candidates,
3140HashSet<TypeWithAnnotations> bounds,
3141ArrayBuilder<TypeWithAnnotations> initialCandidates,
3150foreach (var bound in bounds)
3152foreach (var candidate in initialCandidates)
3158TypeWithAnnotations source;
3159TypeWithAnnotations destination;
3173if (conversions.IncludeNullability && candidates.TryGetValue(bound, out var oldBound))
3180var newBound = TypeWithAnnotations.Create(oldBound.Type, newAnnotation);
3200Dictionary<TypeWithAnnotations, TypeWithAnnotations> candidates,
3201TypeWithAnnotations oldCandidate,
3202TypeWithAnnotations newCandidate,
3211if (candidates.TryGetValue(oldCandidate, out TypeWithAnnotations latest))
3222TypeWithAnnotations merged = latest.MergeEquivalentTypes(newCandidate, variance);
3231private sealed class EqualsIgnoringDynamicTupleNamesAndNullabilityComparer : EqualityComparer<TypeWithAnnotations>
3235public override int GetHashCode(TypeWithAnnotations obj)
3240public override bool Equals(TypeWithAnnotations x, TypeWithAnnotations y)
Binder\Semantics\OverloadResolution\OverloadResolution.cs (22)
119ArrayBuilder<TypeWithAnnotations> typeArguments,
149ArrayBuilder<TypeWithAnnotations> typeArguments = ArrayBuilder<TypeWithAnnotations>.GetInstance();
159ArrayBuilder<TypeWithAnnotations> typeArguments,
231ArrayBuilder<TypeWithAnnotations> typeArguments,
340var typeArgumentsBuilder = ArrayBuilder<TypeWithAnnotations>.GetInstance();
819ArrayBuilder<TypeWithAnnotations> typeArguments,
2548var x = lambda.GetInferredReturnType(ref useSiteInfo, out _);
2973var x = lambda.InferReturnType(Conversions, d1, ref useSiteInfo, out _);
3082out ImmutableArray<TypeWithAnnotations> parameterTypes,
3095internal readonly ImmutableArray<TypeWithAnnotations> ParameterTypes;
3098internal EffectiveParameters(ImmutableArray<TypeWithAnnotations> types, ImmutableArray<RefKind> refKinds)
3145var types = ArrayBuilder<TypeWithAnnotations>.GetInstance();
3234var types = ArrayBuilder<TypeWithAnnotations>.GetInstance();
3245var type = parameter.TypeWithAnnotations;
3267ArrayBuilder<TypeWithAnnotations> typeArguments,
3351ArrayBuilder<TypeWithAnnotations> typeArguments,
3417ArrayBuilder<TypeWithAnnotations> typeArgumentsBuilder,
3452ImmutableArray<TypeWithAnnotations> typeArguments;
3548private ImmutableArray<TypeWithAnnotations> InferMethodTypeArguments(
3593return default(ImmutableArray<TypeWithAnnotations>);
3599return default(ImmutableArray<TypeWithAnnotations>);
BoundTree\Constructors.cs (5)
486public BoundTypeExpression(SyntaxNode syntax, AliasSymbol? aliasOpt, BoundTypeExpression? boundContainingTypeOpt, ImmutableArray<BoundExpression> boundDimensionsOpt, TypeWithAnnotations typeWithAnnotations, bool hasErrors = false)
492public BoundTypeExpression(SyntaxNode syntax, AliasSymbol? aliasOpt, BoundTypeExpression? boundContainingTypeOpt, TypeWithAnnotations typeWithAnnotations, bool hasErrors = false)
497public BoundTypeExpression(SyntaxNode syntax, AliasSymbol? aliasOpt, TypeWithAnnotations typeWithAnnotations, bool hasErrors = false)
503: this(syntax, aliasOpt, null, TypeWithAnnotations.Create(type), hasErrors)
507public 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,
463public bool HasExplicitReturnType(out RefKind refKind, out TypeWithAnnotations returnType)
469public TypeWithAnnotations InferReturnType(ConversionsBase conversions, NamedTypeSymbol delegateType, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo, out bool inferredFromFunctionType)
480public TypeWithAnnotations ParameterTypeWithAnnotations(int index) { return Data.ParameterTypeWithAnnotations(index); }
547public abstract bool HasExplicitReturnType(out RefKind refKind, out TypeWithAnnotations returnType);
554public abstract TypeWithAnnotations ParameterTypeWithAnnotations(int index);
595var type = lambda.InferredReturnType.TypeWithAnnotations;
605var type = BindForErrorRecovery().InferredReturnType.TypeWithAnnotations;
618private static TypeWithAnnotations DelegateReturnTypeWithAnnotations(MethodSymbol? invokeMethod, out RefKind refKind)
629internal (ImmutableArray<RefKind>, ArrayBuilder<ScopedKind>, ImmutableArray<TypeWithAnnotations>, bool) CollectParameterProperties()
633var parameterTypesBuilder = ArrayBuilder<TypeWithAnnotations>.GetInstance(ParameterCount);
640var type = ParameterTypeWithAnnotations(i);
679if (!HasExplicitReturnType(out var returnRefKind, out var returnType))
683var returnTypes = ArrayBuilder<(BoundReturnStatement, TypeWithAnnotations)>.GetInstance();
723returnType = TypeWithAnnotations.Create(Binder.Compilation.GetSpecialType(SpecialType.System_Void));
740var returnType = DelegateReturnTypeWithAnnotations(invokeMethod, out RefKind refKind);
843TypeWithAnnotations returnType,
844ImmutableArray<TypeWithAnnotations> parameterTypes,
860var returnType = DelegateReturnTypeWithAnnotations(invokeMethod, out RefKind refKind);
865private void ValidateUnsafeParameters(BindingDiagnosticBag diagnostics, ImmutableArray<TypeWithAnnotations> targetParameterTypes)
892ImmutableArray<TypeWithAnnotations> parameterTypes,
895bool hasExplicitReturnType = HasExplicitReturnType(out var refKind, out var returnType);
914var returnTypes = ArrayBuilder<(BoundReturnStatement, TypeWithAnnotations)>.GetInstance();
924? TypeWithAnnotations.Create(this.Binder.Compilation.GetSpecialType(SpecialType.System_Void))
925: TypeWithAnnotations.Create(LambdaSymbol.InferenceFailureReturnType);
949ImmutableArray<TypeWithAnnotations> parameterTypes,
951TypeWithAnnotations returnType,
985public readonly ImmutableArray<TypeWithAnnotations> ParameterTypes;
989public static readonly ReturnInferenceCacheKey Empty = new ReturnInferenceCacheKey(ImmutableArray<TypeWithAnnotations>.Empty, ImmutableArray<RefKind>.Empty, null);
991private ReturnInferenceCacheKey(ImmutableArray<TypeWithAnnotations> parameterTypes, ImmutableArray<RefKind> parameterRefKinds, NamedTypeSymbol? taskLikeReturnTypeOpt)
1031foreach (var type in ParameterTypes)
1051out ImmutableArray<TypeWithAnnotations> parameterTypes,
1057parameterTypes = ImmutableArray<TypeWithAnnotations>.Empty;
1066var typesBuilder = ArrayBuilder<TypeWithAnnotations>.GetInstance(parameterCount);
1143?? rebind(ReallyInferReturnType(delegateType: null, ImmutableArray<TypeWithAnnotations>.Empty, ImmutableArray<RefKind>.Empty));
1159ImmutableArray<TypeWithAnnotations> parameterTypes,
1162var returnType = inferredReturnType.TypeWithAnnotations;
1174returnType = TypeWithAnnotations.Create(t);
1389private readonly TypeWithAnnotations _returnType;
1393private readonly ImmutableArray<TypeWithAnnotations> _parameterTypesWithAnnotations;
1405TypeWithAnnotations returnType,
1409ImmutableArray<TypeWithAnnotations> parameterTypesWithAnnotations,
1437public override bool HasExplicitReturnType(out RefKind refKind, out TypeWithAnnotations returnType)
1517public override TypeWithAnnotations ParameterTypeWithAnnotations(int index)
Compilation\CSharpCompilation.cs (10)
2068var firstType = method.Parameters[0].TypeWithAnnotations;
2202return ArrayTypeSymbol.CreateCSharpArray(this.Assembly, TypeWithAnnotations.Create(elementType, elementNullableAnnotation), rank);
2215return new PointerTypeSymbol(TypeWithAnnotations.Create(elementType, elementNullableAnnotation));
3778var returnTypeWithAnnotations = TypeWithAnnotations.Create(returnType.EnsureCSharpSymbolOrNull(nameof(returnType)), returnType.NullableAnnotation.ToInternalAnnotation());
3780type => TypeWithAnnotations.Create(type.EnsureCSharpSymbolOrNull(nameof(parameterTypes)), type.NullableAnnotation.ToInternalAnnotation()));
3828var typesBuilder = ArrayBuilder<TypeWithAnnotations>.GetInstance(elementTypes.Length);
3834typesBuilder.Add(TypeWithAnnotations.Create(elementType, annotation));
3872(t, a) => TypeWithAnnotations.Create(t.Type, a.ToInternalAnnotation())));
3902fields.Add(new AnonymousTypeField(name, location, TypeWithAnnotations.Create(type, nullableAnnotation), RefKind.None, ScopedKind.None));
FlowAnalysis\NullableWalker.cs (196)
100public readonly TypeWithAnnotations LValueType;
102public VisitResult(TypeWithState rValueType, TypeWithAnnotations lValueType)
114LValueType = TypeWithAnnotations.Create(type, annotation);
133public TypeWithAnnotations LValueType => VisitResult.LValueType;
181private ArrayBuilder<(BoundReturnStatement, TypeWithAnnotations)>? _returnTypesOpt;
219private PooledDictionary<BoundExpression, Func<TypeWithAnnotations, TypeWithState>>? _targetTypedAnalysisCompletionOpt;
224/// 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>)"/>.
226private PooledDictionary<BoundExpression, Func<TypeWithAnnotations, TypeWithState>> TargetTypedAnalysisCompletion
227=> _targetTypedAnalysisCompletionOpt ??= PooledDictionary<BoundExpression, Func<TypeWithAnnotations, TypeWithState>>.GetInstance();
291private TypeWithAnnotations LvalueResultType
296private void SetLvalueResultType(BoundExpression? expression, TypeWithAnnotations type)
311private void SetResult(BoundExpression? expression, TypeWithState resultType, TypeWithAnnotations lvalueType, bool updateAnalyzedNullability = true, bool? isLvalue = null)
320private void SetAnalyzedNullability(BoundExpression? expression, TypeWithState resultType, TypeWithAnnotations lvalueType, bool? isLvalue = null)
426ArrayBuilder<(BoundReturnStatement, TypeWithAnnotations)>? returnTypesOpt,
688TypeWithAnnotations symbolType;
906var type = memberToInitialize.GetTypeOrReturnType();
1638ArrayBuilder<(BoundReturnStatement, TypeWithAnnotations)>? returnTypesOpt)
1684ArrayBuilder<(BoundReturnStatement, TypeWithAnnotations)>? returnTypesOpt,
1865if (!_variables.TryGetType(local, out TypeWithAnnotations localType))
1874if (!_variables.TryGetType(parameter, out TypeWithAnnotations parameterType))
2149private TypeWithAnnotations VisitLvalueWithAnnotations(BoundExpression node)
2190private static bool ShouldReportNullableAssignment(TypeWithAnnotations type, NullableFlowState state)
2226TypeWithAnnotations targetType,
2304TypeWithAnnotations overriddenType,
2306TypeWithAnnotations overridingType,
2377static bool isBadAssignment(TypeWithState valueState, TypeWithAnnotations destinationType, FlowAnalysisAnnotations destinationAnnotations)
2453TypeWithAnnotations targetType,
2496static bool areEquivalentTypes(TypeWithAnnotations target, TypeWithState assignedValue) =>
2563TypeWithAnnotations fieldOrPropertyType = member.GetTypeOrReturnType();
2734var parameterType = i >= signatureParameters.Length ? parameter.TypeWithAnnotations : signatureParameters[i].TypeWithAnnotations;
2740private void EnterParameter(ParameterSymbol parameter, TypeWithAnnotations parameterType)
2769var parameterLValueType = ApplyLValueAnnotations(parameter.TypeWithAnnotations, parameterAnnotations);
2785internal static TypeWithState GetParameterState(TypeWithAnnotations parameterType, FlowAnalysisAnnotations parameterAnnotations)
2815TryGetReturnType(out TypeWithAnnotations returnType, out FlowAnalysisAnnotations returnAnnotations))
2873private TypeWithState VisitRefExpression(BoundExpression expr, TypeWithAnnotations destinationType)
2879var lvalueResultType = LvalueResultType;
2895private bool TryGetReturnType(out TypeWithAnnotations type, out FlowAnalysisAnnotations annotations)
2906var returnType = delegateOrMethod.ReturnTypeWithAnnotations;
2950var type = GetDeclaredLocalResult(local);
2958type = TypeWithAnnotations.Create(node.Type, type.NullableAnnotation);
3192var resultType = ResultType.ToTypeWithAnnotations(compilation);
3293TypeWithAnnotations type = local.TypeWithAnnotations;
3521(TypeWithAnnotations resultTypeWithAnnotations) =>
3601var parameterType = constructor.ParameterTypesWithAnnotations[0];
3602if (AreNullableAndUnderlyingTypes(type, parameterType.Type, out TypeWithAnnotations underlyingType))
3850Action<int, Symbol>? visitMemberAssignment(BoundAssignmentOperator node, int containingSlot, Symbol symbol, bool delayCompletionForType, Func<TypeWithAnnotations, TypeWithState>? conversionCompletion = null)
3861var type = ApplyLValueAnnotations(symbol.GetTypeOrReturnType(), GetObjectInitializerMemberLValueAnnotations(symbol));
3883Action<int, Symbol>? visitMemberAssignmentAsContinuation(BoundAssignmentOperator node, Func<TypeWithAnnotations, TypeWithState> conversionCompletion)
4061return GetOrCreatePlaceholderSlot(node, TypeWithAnnotations.Create(node.Type, NullableAnnotation.NotAnnotated));
4064private int GetOrCreatePlaceholderSlot(object identifier, TypeWithAnnotations type)
4166var elementType = type switch
4214TypeWithAnnotations inferredType = (bestType is null)
4216: TypeWithAnnotations.Create(bestType);
4266static TypeWithAnnotations getSpanElementType(NamedTypeSymbol namedType)
4273static TypeSymbol setSpanElementType(NamedTypeSymbol namedType, TypeWithAnnotations elementType)
4294internal static TypeWithAnnotations BestTypeForLambdaReturns(
4295ArrayBuilder<(BoundExpression expr, TypeWithAnnotations resultType, bool isChecked)> returns,
4317var resultTypes = ArrayBuilder<TypeWithAnnotations>.GetInstance(n);
4330TypeWithAnnotations inferredType;
4334var bestTypeWithObliviousAnnotation = TypeWithAnnotations.Create(bestType);
4346inferredType = TypeWithAnnotations.Create(bestType, BestTypeInferrer.GetNullableAnnotation(resultTypes));
4393TypeWithAnnotations result;
4397result = TypeWithAnnotations.Create(type);
4626SetResult(binary, TypeWithState.ForType(binary.Type), TypeWithAnnotations.Create(binary.Type));
4672var targetTypeWithNullability = ApplyLValueAnnotations(parameter.TypeWithAnnotations, parameterAnnotations);
4676targetTypeWithNullability = TypeWithAnnotations.Create(MakeNullableOf(targetTypeWithNullability));
4717TypeWithAnnotations.Create(expr.Type),
5104TypeWithAnnotations targetType = VisitLvalueWithAnnotations(leftOperand);
5110targetType = TypeWithAnnotations.Create(node.Type, NullableAnnotation.NotAnnotated);
5198TypeWithAnnotations.Create(rightType),
5234TypeWithAnnotations explicitType = boundConversion.ConversionGroupOpt?.ExplicitType ?? default;
5236TypeWithAnnotations targetType = fromExplicitCast ? explicitType : TypeWithAnnotations.Create(boundConversion.Type);
5374var accessTypeWithAnnotations = LvalueResultType;
5425TypeWithAnnotations consequenceLValue;
5426TypeWithAnnotations alternativeLValue;
5447SetResult(node, TypeWithState.Create(refResultType, rValueState), TypeWithAnnotations.Create(refResultType, lValueAnnotation));
5488TypeWithAnnotations resultTypeWithAnnotations;
5507resultTypeWithAnnotations = TypeWithAnnotations.Create(resultType);
5520BoundExpression alternative, Conversion alternativeConversion, bool alternativeEndReachable, TypeWithAnnotations resultTypeWithAnnotations, bool wasTargetTyped)
5577(TypeWithAnnotations resultTypeWithAnnotations) =>
5599(TypeWithAnnotations LValueType, TypeWithState RValueType) visitConditionalRefOperand(LocalState state, BoundExpression operand)
5603TypeWithAnnotations lValueType = VisitLvalueWithAnnotations(operand);
5612TypeWithAnnotations targetType,
5660private static BoundExpression CreatePlaceholderIfNecessary(BoundExpression expr, TypeWithAnnotations type)
5775var parameterType = method.Parameters[0].TypeWithAnnotations;
6020private static TypeWithAnnotations ApplyLValueAnnotations(TypeWithAnnotations declaredType, FlowAnalysisAnnotations flowAnalysisAnnotations)
6052private static TypeWithAnnotations ApplyUnconditionalAnnotations(TypeWithAnnotations declaredType, FlowAnalysisAnnotations annotations)
6239(ParameterSymbol? parameter, TypeWithAnnotations parameterType, FlowAnalysisAnnotations parameterAnnotations, bool isExpandedParamsArgument) =
6297(ParameterSymbol? parameter, TypeWithAnnotations parameterType, FlowAnalysisAnnotations parameterAnnotations, _) =
6554TypeWithAnnotations parameterType,
6609var lvalueResultType = result.LValueType;
6691TypeWithAnnotations parameterType,
6721var lValueType = result.LValueType;
6745var declaredType = result.LValueType;
6747var lValueType = ApplyLValueAnnotations(declaredType, leftAnnotations);
6750var varType = worstCaseParameterWithState.ToAnnotatedTypeWithAnnotations(compilation);
6804void trackNullableStateForAssignment(BoundExpression parameterValue, TypeWithAnnotations lValueType, int targetSlot, TypeWithState parameterWithState, bool isSuppressed, FlowAnalysisAnnotations parameterAnnotations)
6986private (ParameterSymbol? Parameter, TypeWithAnnotations Type, FlowAnalysisAnnotations Annotations, bool isExpandedParamsArgument) GetCorrespondingParameter(
7004var type = parameter.TypeWithAnnotations;
7046parameterTypes: out ImmutableArray<TypeWithAnnotations> parameterTypes,
7079internal override TypeWithAnnotations GetTypeWithAnnotations(BoundExpression expr)
7081return TypeWithAnnotations.Create(expr.GetTypeOrFunctionType(), GetNullableAnnotation(expr));
7111internal override TypeWithAnnotations GetMethodGroupResultType(BoundMethodGroup group, MethodSymbol method)
7138var argumentResult = visitArgumentResult.RValueType.ToTypeWithAnnotations(compilation);
7143BoundExpression getArgumentForMethodTypeInference(BoundExpression argument, TypeWithAnnotations argumentType, Optional<LocalState> lambdaState)
7427TypeWithAnnotations explicitType = node.ConversionGroupOpt?.ExplicitType ?? default;
7429TypeWithAnnotations targetType = fromExplicitCast ? explicitType : TypeWithAnnotations.Create(node.Type);
7459private TypeWithState VisitOptionalImplicitConversion(BoundExpression expr, TypeWithAnnotations targetTypeOpt, bool useLegacyWarnings, bool trackMembers, AssignmentKind assignmentKind)
7471private (TypeWithState resultType, Func<TypeWithAnnotations, TypeWithState>? completion) VisitOptionalImplicitConversion(
7473TypeWithAnnotations targetTypeOpt,
7485(TypeWithState resultType, Func<TypeWithAnnotations, TypeWithState>? completion) visitConversion(
7487TypeWithAnnotations targetTypeOpt,
7522Func<TypeWithAnnotations, TypeWithState> visitConversionAsContinuation(BoundExpression expr, bool useLegacyWarnings, bool trackMembers, AssignmentKind assignmentKind, BoundExpression operand, Conversion conversion, TypeWithState operandType)
7524return (TypeWithAnnotations targetTypeOpt) =>
7533private static bool AreNullableAndUnderlyingTypes([NotNullWhen(true)] TypeSymbol? nullableTypeOpt, [NotNullWhen(true)] TypeSymbol? underlyingTypeOpt, out TypeWithAnnotations underlyingTypeWithAnnotations)
7538var typeArg = nullableTypeOpt.GetNullableUnderlyingTypeWithAnnotations();
7573ImmutableArray<TypeWithAnnotations> elementTypesWithAnnotations = elementTypes.SelectAsArray(a => a.ToTypeWithAnnotations(compilation));
7911TypeWithAnnotations targetTypeWithNullability,
7931if (TargetTypedAnalysisCompletion.TryGetValue(conversionOperand, out Func<TypeWithAnnotations, TypeWithState>? completion))
8123if (AreNullableAndUnderlyingTypes(targetType, operandType.Type, out TypeWithAnnotations underlyingType))
8237static TypeWithState calculateResultType(TypeWithAnnotations targetTypeWithNullability, bool fromExplicitCast, NullableFlowState resultState, bool isSuppressed, TypeSymbol targetType)
8253static NullableFlowState getReferenceConversionResultState(TypeWithAnnotations targetType, TypeWithState operandType)
8287static NullableFlowState getBoxingConversionResultState(TypeWithAnnotations targetType, TypeWithState operandType)
8347foreach (var constraintType in typeParameter1.ConstraintTypesNoUseSiteDiagnostics)
8437TypeWithAnnotations targetTypeWithNullability,
8468TypeWithAnnotations.Create(conversion.BestUserDefinedConversionAnalysis!.FromType),
8488var parameterType = ApplyLValueAnnotations(parameter.TypeWithAnnotations, parameterAnnotations);
8494var underlyingOperandTypeWithAnnotations = operandType.Type.GetNullableUnderlyingTypeWithAnnotations();
8520var methodReturnType = method.ReturnTypeWithAnnotations;
8539TypeWithAnnotations.Create(conversion.BestUserDefinedConversionAnalysis!.ToType),
8611TypeWithAnnotations.Create(newType, visitResult.LValueType.NullableAnnotation));
8617private TypeWithState GetLiftedReturnType(TypeWithAnnotations returnType, NullableFlowState operandState)
8638private TypeWithState GetLiftedReturnTypeIfNecessary(bool isLifted, TypeWithAnnotations returnType, NullableFlowState operandState)
8645private TypeSymbol MakeNullableOf(TypeWithAnnotations underlying)
8652TypeWithAnnotations targetType,
8752(TypeWithAnnotations resultTypeWithAnnotations) =>
8833var argTypeWithAnnotations = TypeWithAnnotations.Create(argType, NullableAnnotation.NotAnnotated);
8930var parameterType = parameter.TypeWithAnnotations;
9020var lvalueResult = TypeWithAnnotations.Create(node.Type, NullableAnnotation.NotAnnotated);
9028var parameterType = GetDeclaredParameterResult(parameter);
9057TypeWithAnnotations declaredType = LvalueResultType;
9058TypeWithAnnotations leftLValueType = ApplyLValueAnnotations(declaredType, leftAnnotations);
9090var lvalueType = rightState.ToTypeWithAnnotations(compilation);
9105var type = property.TypeWithAnnotations;
9107var lValueType = ApplyLValueAnnotations(type, annotations);
9378var lvalueType = variable.Type;
9430AreNullableAndUnderlyingTypes(lvalueType.Type, operandType.Type, out TypeWithAnnotations underlyingType))
9446internal readonly TypeWithAnnotations Type;
9449internal DeconstructionVariable(BoundExpression expression, TypeWithAnnotations type)
9533var operandLvalue = LvalueResultType;
9540TypeWithAnnotations targetTypeOfOperandConversion;
9596var operandTypeWithAnnotations = operandType.ToTypeWithAnnotations(compilation);
9633TypeWithAnnotations declaredType = LvalueResultType;
9634TypeWithAnnotations leftLValueType = declaredType;
9649TypeWithAnnotations.Create(node.Operator.LeftType),
9731var paramType = parameter.TypeWithAnnotations;
9766private TypeWithAnnotations GetDeclaredLocalResult(LocalSymbol local)
9768return _variables.TryGetType(local, out TypeWithAnnotations type) ?
9773private TypeWithAnnotations GetDeclaredParameterResult(ParameterSymbol parameter)
9775return _variables.TryGetType(parameter, out TypeWithAnnotations type) ?
9891var type = member.GetTypeOrReturnType();
9994TypeWithAnnotations targetTypeWithAnnotations;
10030targetTypeWithAnnotations = TypeWithAnnotations.Create(node.Expression.Type);
10037targetTypeWithAnnotations = TypeWithAnnotations.Create(ForEachLoopBinder.GetIEnumerableOfT(resultType, isAsync, compilation, ref discardedUseSiteInfo, out bool foundMultiple));
10088TypeWithAnnotations.Create(node.EnumeratorInfoOpt.ElementType, NullableAnnotation.NotAnnotated).ToTypeWithState();
10152TypeWithAnnotations sourceType = sourceState.ToTypeWithAnnotations(compilation);
10181TypeWithAnnotations destinationType = iterationVariable.TypeWithAnnotations;
10277var type = TypeWithAnnotations.Create(node.Type);
10378var type = TypeWithAnnotations.Create(node.Type);
10386var type = TypeWithAnnotations.Create(node.Type);
10408var type = TypeWithAnnotations.Create(node.Type, node.NullableAnnotation);
10738var result = TypeWithAnnotations.Create(node.Type);
10758var result = TypeWithAnnotations.Create(node.Type, NullableAnnotation.Oblivious);
10864var result = TypeWithAnnotations.Create(node.Type, NullableAnnotation.Oblivious);
10933private static bool IsNullabilityMismatch(TypeWithAnnotations type1, TypeWithAnnotations type2)
11035var result = TypeWithAnnotations.Create(node.Type, node.IsInferred ? NullableAnnotation.Annotated : node.NullableAnnotation);
11079TypeWithAnnotations elementType = InMethodBinder.GetIteratorElementTypeFromReturnType(compilation, RefKind.None,
11132var typeWithAnnotations = TypeWithAnnotations.Create(node.Type, node.NullableAnnotation);
11197var 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;
495var type = property.TypeWithAnnotations;
520TypeWithAnnotations type = getIndexerOutputType(inputType, e.IndexerAccess, isSlice: false);
532TypeWithAnnotations type = getIndexerOutputType(inputType, e.IndexerAccess, isSlice: true);
644var inferredType = value.ToTypeWithAnnotations(compilation, asAnnotatedType: boundLocal.DeclarationKind == BoundLocalDeclarationKind.WithInferredType);
645if (_variables.TryGetType(local, out var existingType))
648inferredType = TypeWithAnnotations.Create(inferredType.Type, existingType.NullableAnnotation.Join(inferredType.NullableAnnotation));
791int makeDagTempSlot(TypeWithAnnotations type, BoundDagTemp temp)
799var type = TypeWithAnnotations.Create(t, NullableAnnotation.Annotated);
806static TypeWithAnnotations getIndexerOutputType(TypeSymbol inputType, BoundExpression e, bool isSlice)
814? TypeWithAnnotations.Create(isNullableEnabled: true, inputType, isAnnotated: false)
912var inferredTypeWithAnnotations = TypeWithAnnotations.Create(inferredType);
946TypeWithAnnotations inferredTypeWithAnnotations,
993(TypeWithAnnotations inferredTypeWithAnnotations) =>
Generated\BoundNodes.xml.Generated.cs (9)
1056public BoundTypeExpression(SyntaxNode syntax, AliasSymbol? aliasOpt, BoundTypeExpression? boundContainingTypeOpt, ImmutableArray<BoundExpression> boundDimensionsOpt, TypeWithAnnotations typeWithAnnotations, TypeSymbol type, bool hasErrors = false)
1072public TypeWithAnnotations TypeWithAnnotations { get; }
1077public BoundTypeExpression Update(AliasSymbol? aliasOpt, BoundTypeExpression? boundContainingTypeOpt, ImmutableArray<BoundExpression> boundDimensionsOpt, TypeWithAnnotations typeWithAnnotations, TypeSymbol type)
5726public BoundDynamicMemberAccess(SyntaxNode syntax, BoundExpression receiver, ImmutableArray<TypeWithAnnotations> typeArgumentsOpt, string name, bool invoked, bool indexed, TypeSymbol type, bool hasErrors = false)
5743public ImmutableArray<TypeWithAnnotations> TypeArgumentsOpt { get; }
5751public BoundDynamicMemberAccess Update(BoundExpression receiver, ImmutableArray<TypeWithAnnotations> typeArgumentsOpt, string name, bool invoked, bool indexed, TypeSymbol type)
5963public 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)
5979public ImmutableArray<TypeWithAnnotations> TypeArgumentsOpt { get; }
5990public 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)
175var pendingExceptionLocal = new SynthesizedLocal(_F.CurrentFunction, TypeWithAnnotations.Create(exceptionType), SynthesizedLocalKind.TryAwaitPendingException, tryStatementSyntax);
177var pendingBranchVar = new SynthesizedLocal(_F.CurrentFunction, TypeWithAnnotations.Create(_F.SpecialType(SpecialType.System_Int32)), SynthesizedLocalKind.TryAwaitPendingBranch, tryStatementSyntax);
975this.returnValue = returnValue = new SynthesizedLocal(containingMethod, TypeWithAnnotations.Create(valueOpt.Type), SynthesizedLocalKind.AsyncMethodReturnValue, _syntaxOpt);
1009this.pendingCaughtException = new SynthesizedLocal(F.CurrentFunction, TypeWithAnnotations.Create(F.SpecialType(SpecialType.System_Object)), SynthesizedLocalKind.TryAwaitPendingCaughtException, tryStatementSyntax);
1010this.pendingCatch = new SynthesizedLocal(F.CurrentFunction, TypeWithAnnotations.Create(F.SpecialType(SpecialType.System_Int32)), SynthesizedLocalKind.TryAwaitPendingCatch, tryStatementSyntax);
Lowering\ClosureConversion\ClosureConversion.cs (11)
651var frameTypeParameters = ImmutableArray.Create(_currentTypeParameters.SelectAsArray(t => TypeWithAnnotations.Create(t)), 0, frame.Arity);
655LocalSymbol framePointer = new SynthesizedLocal(_topLevelMethod, TypeWithAnnotations.Create(frameType), SynthesizedLocalKind.LambdaDisplayClass, frame.ScopeSyntaxOpt);
945private ImmutableArray<TypeWithAnnotations> SubstituteTypeArguments(ImmutableArray<TypeWithAnnotations> typeArguments)
969var builder = ArrayBuilder<TypeWithAnnotations>.GetInstance(typeArguments.Length);
970foreach (var typeArg in typeArguments)
972TypeWithAnnotations oldTypeArg;
973TypeWithAnnotations newTypeArg = typeArg;
998ImmutableArray<TypeWithAnnotations> typeArgumentsOpt,
1010var realTypeArguments = ImmutableArray.Create(_currentTypeParameters.SelectAsArray(t => TypeWithAnnotations.Create(t)), 0, totalTypeArgumentCount - originalMethod.Arity);
1623RemapLambdaOrLocalFunction(node.Syntax, node.Symbol, default(ImmutableArray<TypeWithAnnotations>), closureKind, ref referencedMethod, out receiver, out constructedFrame);
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)
118typeArgs: typeArgs.IsDefault ? default(ImmutableArray<TypeWithAnnotations>) : typeArgs.SelectAsArray(t => TypeWithAnnotations.Create(t)),
217public StateMachineFieldSymbol StateMachineField(TypeWithAnnotations type, string name, bool isPublic = false, bool isThis = false)
228var result = new StateMachineFieldSymbol(CurrentType, TypeWithAnnotations.Create(type), name, isPublic, isThis);
563return new SynthesizedLocal(CurrentFunction, TypeWithAnnotations.Create(type), kind, syntax, isPinned,
583TypeWithAnnotations.Create(type),
594return SynthesizedParameterSymbol.Create(container, TypeWithAnnotations.Create(type), ordinal, RefKind.None, name);
1160public BoundExpression NullRef(TypeWithAnnotations type)
1195public BoundExpression Typeof(TypeWithAnnotations type)
1200public ImmutableArray<BoundExpression> TypeOfs(ImmutableArray<TypeWithAnnotations> typeArguments)
1558TypeWithAnnotations.Create(type),
1597temp = new SynthesizedLocal(this.CurrentFunction, TypeWithAnnotations.Create(node.Type), SynthesizedLocalKind.LoweringTemp);
Symbols\ArrayTypeSymbol.cs (24)
21private readonly TypeWithAnnotations _elementTypeWithAnnotations;
25TypeWithAnnotations elementTypeWithAnnotations,
37TypeWithAnnotations elementTypeWithAnnotations,
49TypeWithAnnotations elementTypeWithAnnotations,
66TypeWithAnnotations elementType,
75TypeWithAnnotations elementTypeWithAnnotations,
82TypeWithAnnotations elementTypeWithAnnotations,
91TypeWithAnnotations elementType)
96internal ArrayTypeSymbol WithElementType(TypeWithAnnotations elementTypeWithAnnotations)
101protected abstract ArrayTypeSymbol WithElementTypeCore(TypeWithAnnotations elementTypeWithAnnotations);
104TypeWithAnnotations elementTypeWithAnnotations,
200public TypeWithAnnotations ElementTypeWithAnnotations
392TypeWithAnnotations oldElementType = ElementTypeWithAnnotations;
393TypeWithAnnotations newElementType;
405internal override TypeSymbol SetNullabilityForReferenceTypes(Func<TypeWithAnnotations, TypeWithAnnotations> transform)
413TypeWithAnnotations elementType = ElementTypeWithAnnotations.MergeEquivalentTypes(((ArrayTypeSymbol)other).ElementTypeWithAnnotations, variance);
499TypeWithAnnotations elementTypeWithAnnotations,
508protected override ArrayTypeSymbol WithElementTypeCore(TypeWithAnnotations newElementType)
557TypeWithAnnotations elementTypeWithAnnotations,
591TypeWithAnnotations elementTypeWithAnnotations,
598protected override ArrayTypeSymbol WithElementTypeCore(TypeWithAnnotations elementTypeWithAnnotations)
618TypeWithAnnotations elementTypeWithAnnotations,
631protected override ArrayTypeSymbol WithElementTypeCore(TypeWithAnnotations elementTypeWithAnnotations)
Symbols\ConstraintsHelper.cs (32)
74ImmutableArray<TypeWithAnnotations> constraintTypes,
103ImmutableArray<TypeWithAnnotations> constraintTypes,
123var constraintTypesBuilder = ArrayBuilder<TypeWithAnnotations>.GetInstance();
130foreach (var constraintType in constraintTypes)
315internal static ImmutableArray<ImmutableArray<TypeWithAnnotations>> MakeTypeParameterConstraintTypes(
325return ImmutableArray<ImmutableArray<TypeWithAnnotations>>.Empty;
339return ImmutableArray<ImmutableArray<TypeWithAnnotations>>.Empty;
839ImmutableArray<TypeWithAnnotations> typeArguments,
876TypeWithAnnotations typeArgument,
955TypeWithAnnotations typeArgument,
981var constraintTypes = ArrayBuilder<TypeWithAnnotations>.GetInstance();
983ImmutableArray<TypeWithAnnotations> originalConstraintTypes = typeParameter.ConstraintTypesWithDefinitionUseSiteDiagnostics(ref useSiteInfo);
995foreach (var constraintType in constraintTypes)
1015static bool errorIfNotSatisfiesConstructorConstraint(Symbol containingSymbol, TypeParameterSymbol typeParameter, TypeWithAnnotations typeArgument, ArrayBuilder<TypeParameterDiagnosticInfo> diagnosticsBuilder)
1041TypeWithAnnotations typeArgument,
1065TypeWithAnnotations typeArgument,
1069TypeWithAnnotations constraintType,
1121static NullableFlowState getTypeArgumentState(in TypeWithAnnotations typeWithAnnotations)
1145foreach (var constraintType in typeParameter.ConstraintTypesNoUseSiteDiagnostics)
1160static bool constraintTypeAllows(in TypeWithAnnotations typeWithAnnotations, NullableFlowState state)
1182foreach (var constraintType in typeParameter.ConstraintTypesNoUseSiteDiagnostics)
1241TypeWithAnnotations typeArgument,
1242TypeWithAnnotations constraintType,
1283foreach (var typeArgumentConstraint in typeParameter.ConstraintTypesWithDefinitionUseSiteDiagnostics(ref useSiteInfo))
1326private static bool IsReferenceType(TypeParameterSymbol typeParameter, ImmutableArray<TypeWithAnnotations> constraintTypes)
1331private static bool IsValueType(TypeParameterSymbol typeParameter, ImmutableArray<TypeWithAnnotations> constraintTypes)
1519internal static TypeWithAnnotations ConstraintWithMostSignificantNullability(TypeWithAnnotations type1, TypeWithAnnotations type2)
1539internal static bool IsObjectConstraint(TypeWithAnnotations type, ref TypeWithAnnotations bestObjectConstraint)
1565internal 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,
332TypeWithAnnotations substitutedReturnType,
333ImmutableArray<TypeWithAnnotations> substitutedParameterTypes,
350var mergedReturnType = ReturnTypeWithAnnotations.MergeEquivalentTypes(signature.ReturnTypeWithAnnotations, returnVariance);
352var mergedParameterTypes = ImmutableArray<TypeWithAnnotations>.Empty;
356var paramMergedTypesBuilder = ArrayBuilder<TypeWithAnnotations>.GetInstance(_parameters.Length);
369var mergedParameterType = thisParam.TypeWithAnnotations.MergeEquivalentTypes(otherParam.TypeWithAnnotations, paramVariance);
398public FunctionPointerMethodSymbol SetNullabilityForReferenceTypes(Func<TypeWithAnnotations, TypeWithAnnotations> transform)
400var transformedReturn = transform(ReturnTypeWithAnnotations);
402var transformedParameterTypes = ImmutableArray<TypeWithAnnotations>.Empty;
406var paramTypesBuilder = ArrayBuilder<TypeWithAnnotations>.GetInstance(_parameters.Length);
409var transformedType = transform(param.TypeWithAnnotations);
442TypeWithAnnotations returnType,
445ImmutableArray<TypeWithAnnotations> substitutedParameterTypes,
463var substitutedType = substitutedParameterTypes[i];
487TypeWithAnnotations returnTypeWithAnnotations,
489ImmutableArray<TypeWithAnnotations> parameterTypes,
518TypeWithAnnotations returnType,
546var returnType = TypeWithAnnotations.Create(retInfo.Type, customModifiers: CSharpCustomModifier.Convert(retInfo.CustomModifiers));
566var paramType = TypeWithAnnotations.Create(param.Type, customModifiers: CSharpCustomModifier.Convert(param.CustomModifiers));
602bool madeChanges = ReturnTypeWithAnnotations.ApplyNullableTransforms(defaultTransformFlag, transforms, ref position, out var newReturnType);
603var newParamTypes = ImmutableArray<TypeWithAnnotations>.Empty;
606var paramTypesBuilder = ArrayBuilder<TypeWithAnnotations>.GetInstance(Parameters.Length);
610madeParamChanges |= param.TypeWithAnnotations.ApplyNullableTransforms(defaultTransformFlag, transforms, ref position, out var newParamType);
765public override TypeWithAnnotations ReturnTypeWithAnnotations { get; }
820public 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);
607internal override ImmutableArray<TypeWithAnnotations> GetConstraintTypes(ConsList<TypeParameterSymbol> inProgress)
610return (bounds != null) ? bounds.ConstraintTypes : ImmutableArray<TypeWithAnnotations>.Empty;
Symbols\Retargeting\RetargetingSymbolTranslator.cs (22)
180public TypeWithAnnotations Retarget(TypeWithAnnotations underlyingType, RetargetOptions options, NamedTypeSymbol asDynamicIfNoPiaContainingType = null)
515var oldArguments = ArrayBuilder<TypeWithAnnotations>.GetInstance();
534var newArguments = ArrayBuilder<TypeWithAnnotations>.GetInstance(oldArguments.Count);
536foreach (var arg in oldArguments)
538var newArg = Retarget(arg, RetargetOptions.RetargetPrimitiveTypesByTypeCode); // generic instantiation is a signature
595private bool IsNoPiaIllegalGenericInstantiation(ArrayBuilder<TypeWithAnnotations> oldArguments, ArrayBuilder<TypeWithAnnotations> newArguments, int startOfNonInterfaceArguments)
671foreach (var argument in namedType.TypeArgumentsWithAnnotationsNoUseSiteDiagnostics)
697TypeWithAnnotations oldElement = type.ElementTypeWithAnnotations;
698TypeWithAnnotations newElement = Retarget(oldElement, RetargetOptions.RetargetPrimitiveTypesByTypeCode);
748TypeWithAnnotations oldPointed = type.PointedAtTypeWithAnnotations;
749TypeWithAnnotations newPointed = Retarget(oldPointed, RetargetOptions.RetargetPrimitiveTypesByTypeCode);
762var newReturn = Retarget(signature.ReturnTypeWithAnnotations, RetargetOptions.RetargetPrimitiveTypesByTypeCode);
766var newParameterTypes = ImmutableArray<TypeWithAnnotations>.Empty;
772var newParameterTypesBuilder = ArrayBuilder<TypeWithAnnotations>.GetInstance(paramCount);
778var newParameterType = Retarget(parameter.TypeWithAnnotations, RetargetOptions.RetargetPrimitiveTypesByTypeCode);
869public ImmutableArray<TypeWithAnnotations> Retarget(ImmutableArray<TypeWithAnnotations> sequence)
871var result = ArrayBuilder<TypeWithAnnotations>.GetInstance(sequence.Length);
873foreach (var ts in sequence)
1139var targetType = Retarget(@event.TypeWithAnnotations, RetargetOptions.RetargetPrimitiveTypesByTypeCode);
Symbols\Source\LocalFunctionOrSourceMemberMethodSymbol.cs (8)
12private TypeWithAnnotations.Boxed? _lazyIteratorElementType;
19_lazyIteratorElementType = TypeWithAnnotations.Boxed.Sentinel;
23internal sealed override TypeWithAnnotations IteratorElementTypeWithAnnotations
27if (_lazyIteratorElementType == TypeWithAnnotations.Boxed.Sentinel)
29TypeWithAnnotations elementType = InMethodBinder.GetIteratorElementTypeFromReturnType(DeclaringCompilation, RefKind, ReturnType, errorLocation: null, diagnostics: null);
33elementType = TypeWithAnnotations.Create(new ExtendedErrorTypeSymbol(DeclaringCompilation, name: "", arity: 0, errorInfo: null, unreported: false));
36Interlocked.CompareExchange(ref _lazyIteratorElementType, new TypeWithAnnotations.Boxed(elementType), TypeWithAnnotations.Boxed.Sentinel);
Symbols\Source\ParameterHelpers.cs (5)
40parameterCreationFunc: (Binder context, Symbol owner, TypeWithAnnotations parameterType,
80parameterCreationFunc: (Binder binder, FunctionPointerMethodSymbol owner, TypeWithAnnotations parameterType,
122Func<Binder, TOwningSymbol, TypeWithAnnotations, TParameterSyntax, RefKind, int, SyntaxToken, SyntaxToken, bool, ScopedKind, BindingDiagnosticBag, TParameterSymbol> parameterCreationFunc,
179var parameterType = withTypeParametersBinder.BindType(parameterSyntax.Type, diagnostics, suppressUseSiteDiagnostics: suppressUseSiteDiagnostics);
614TypeWithAnnotations typeWithAnnotations,
Symbols\Source\SourceDelegateMethodSymbol.cs (24)
20private readonly TypeWithAnnotations _returnType;
24TypeWithAnnotations returnType,
53var returnType = binder.BindType(returnTypeSyntax, diagnostics);
56var voidType = TypeWithAnnotations.Create(binder.GetSpecialType(SpecialType.System_Void, diagnostics, syntax));
58var objectType = TypeWithAnnotations.Create(binder.GetSpecialType(SpecialType.System_Object, diagnostics, syntax));
59var intPtrType = TypeWithAnnotations.Create(binder.GetSpecialType(SpecialType.System_IntPtr, diagnostics, syntax));
81var iAsyncResultType = TypeWithAnnotations.Create(binder.GetSpecialType(SpecialType.System_IAsyncResult, diagnostics, syntax));
82var asyncCallbackType = TypeWithAnnotations.Create(binder.GetSpecialType(SpecialType.System_AsyncCallback, diagnostics, syntax));
157public override ImmutableArray<ImmutableArray<TypeWithAnnotations>> GetTypeParameterConstraintTypes()
158=> ImmutableArray<ImmutableArray<TypeWithAnnotations>>.Empty;
163public sealed override TypeWithAnnotations ReturnTypeWithAnnotations
218TypeWithAnnotations voidType,
219TypeWithAnnotations objectType,
220TypeWithAnnotations intPtrType,
267TypeWithAnnotations returnType,
366TypeWithAnnotations iAsyncResultType,
367TypeWithAnnotations objectType,
368TypeWithAnnotations asyncCallbackType,
411TypeWithAnnotations iAsyncResultType,
Symbols\Source\SourceMemberContainerSymbol.cs (13)
4035TypeWithAnnotations.Create(compilation.GetSpecialType(SpecialType.System_Void)),
4074TypeWithAnnotations.Create(this),
4082TypeWithAnnotations.Create(compilation.GetSpecialType(SpecialType.System_Void)),
4122TypeWithAnnotations.Create(compilation.GetWellKnownType(WellKnownType.System_Text_StringBuilder)),
4129returnType: TypeWithAnnotations.Create(compilation.GetSpecialType(SpecialType.System_Boolean)),
4184returnType: TypeWithAnnotations.Create(compilation.GetSpecialType(SpecialType.System_String)),
4358TypeWithAnnotations.Create(compilation.GetSpecialType(SpecialType.System_Int32)),
4387TypeWithAnnotations.Create(compilation.GetWellKnownType(WellKnownType.System_Type)),
4448TypeWithAnnotations.Create(this),
4456TypeWithAnnotations.Create(compilation.GetSpecialType(SpecialType.System_Boolean)),
5017builder.AddValue(TypeWithAnnotations.Create(baseType));
5021builder.AddValue(TypeWithAnnotations.Create(@interface));
5081AddSynthesizedAttribute(ref attributes, moduleBuilder.SynthesizeNullableAttributeIfNecessary(this, nullableContextValue, TypeWithAnnotations.Create(baseType)));
Symbols\Source\SourceNamedTypeSymbol.cs (24)
32private ImmutableArray<ImmutableArray<TypeWithAnnotations>> _lazyTypeParameterConstraintTypes;
272internal ImmutableArray<TypeWithAnnotations> GetTypeParameterConstraintTypes(int ordinal)
275return (constraintTypes.Length > 0) ? constraintTypes[ordinal] : ImmutableArray<TypeWithAnnotations>.Empty;
278private ImmutableArray<ImmutableArray<TypeWithAnnotations>> GetTypeParameterConstraintTypes()
318private ImmutableArray<ImmutableArray<TypeWithAnnotations>> MakeTypeParameterConstraintTypes(BindingDiagnosticBag diagnostics)
512ImmutableArray<TypeWithAnnotations> originalConstraintTypes = constraint.ConstraintTypes;
513ArrayBuilder<TypeWithAnnotations> mergedConstraintTypes = null;
514SmallDictionary<TypeWithAnnotations, int> originalConstraintTypesMap = null;
561static bool mergeConstraints(ImmutableArray<TypeWithAnnotations> originalConstraintTypes,
562ref SmallDictionary<TypeWithAnnotations, int> originalConstraintTypesMap, ref ArrayBuilder<TypeWithAnnotations> mergedConstraintTypes,
582TypeWithAnnotations.EqualsComparer.IgnoreNullableModifiersForReferenceTypesComparer);
583SmallDictionary<TypeWithAnnotations, int> clauseConstraintTypesMap = toDictionary(clause.ConstraintTypes, originalConstraintTypesMap.Comparer);
587TypeWithAnnotations constraintType1 = mergedConstraintTypes?[index1] ?? originalConstraintTypes[index1];
597TypeWithAnnotations constraintType2 = clause.ConstraintTypes[index2];
611mergedConstraintTypes = ArrayBuilder<TypeWithAnnotations>.GetInstance(originalConstraintTypes.Length);
619foreach (var constraintType in clauseConstraintTypesMap.Keys)
631static SmallDictionary<TypeWithAnnotations, int> toDictionary(ImmutableArray<TypeWithAnnotations> constraintTypes, IEqualityComparer<TypeWithAnnotations> comparer)
633var result = new SmallDictionary<TypeWithAnnotations, int>(comparer);
666ImmutableArray<TypeWithAnnotations> originalConstraintTypes = constraint.ConstraintTypes;
699static void mergeConstraints(ref TypeParameterConstraintKind mergedKind, ImmutableArray<TypeWithAnnotations> originalConstraintTypes, TypeParameterConstraintClause clause)
740internal sealed override ImmutableArray<TypeWithAnnotations> TypeArgumentsWithAnnotationsNoUseSiteDiagnostics
Symbols\Synthesized\Records\SynthesizedRecordObjEquals.cs (3)
26protected override (TypeWithAnnotations ReturnType, ImmutableArray<ParameterSymbol> Parameters, bool IsVararg, ImmutableArray<TypeParameterConstraintClause> DeclaredConstraintsForOverrideOrImplementation)
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)
88protected override (TypeWithAnnotations ReturnType, ImmutableArray<ParameterSymbol> Parameters, bool IsVararg, ImmutableArray<TypeParameterConstraintClause> DeclaredConstraintsForOverrideOrImplementation) MakeParametersAndBindReturnType(BindingDiagnosticBag diagnostics)
93return (ReturnType: TypeWithAnnotations.Create(Binder.GetSpecialType(compilation, SpecialType.System_Boolean, location, diagnostics)),
96TypeWithAnnotations.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; }
379public override TypeWithAnnotations ReturnTypeWithAnnotations => TypeWithAnnotations.Create(_getAwaiterGetResultCall.Type);
431private readonly TypeWithAnnotations _returnType;
433internal ScriptEntryPoint(NamedTypeSymbol containingType, TypeWithAnnotations returnType) :
445public override TypeWithAnnotations ReturnTypeWithAnnotations => _returnType;
471new SynthesizedLocal(this, TypeWithAnnotations.Create(_containingType), SynthesizedLocalKind.LoweringTemp),
520private readonly TypeWithAnnotations _returnType;
522internal SubmissionEntryPoint(NamedTypeSymbol containingType, TypeWithAnnotations returnType, TypeSymbol submissionArrayType) :
528TypeWithAnnotations.Create(submissionArrayType), 0, RefKind.None, "submissionArray"));
543public override TypeWithAnnotations ReturnTypeWithAnnotations => _returnType;
563new 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)
112foreach (var constraintType in constraintTypes)
149public static TypeWithAnnotations GetNullableUnderlyingTypeWithAnnotations(this TypeSymbol type)
532public static bool TryGetElementTypesWithAnnotationsIfTupleType(this TypeSymbol type, out ImmutableArray<TypeWithAnnotations> elementTypes)
541elementTypes = default(ImmutableArray<TypeWithAnnotations>);
668/// <param name="useDefaultType">If true, use <see cref="TypeWithAnnotations.DefaultType"/>
669/// instead of <see cref="TypeWithAnnotations.Type"/> to avoid early resolution of nullable types</param>
671this TypeWithAnnotations typeWithAnnotationsOpt,
673Func<TypeWithAnnotations, T, bool, bool>? typeWithAnnotationsPredicate,
751TypeWithAnnotations next;
781(TypeWithAnnotations nextTypeWithAnnotations, TypeSymbol? nextType) = getNextIterationElements(fields[i].TypeWithAnnotations, canDigThroughNullable);
812(TypeWithAnnotations nextTypeWithAnnotations, TypeSymbol? nextType) = getNextIterationElements(typeArguments[i], canDigThroughNullable);
861static (TypeWithAnnotations, TypeSymbol?) getNextIterationElements(TypeWithAnnotations type, bool canDigThroughNullable)
862=> canDigThroughNullable ? (default(TypeWithAnnotations), type.NullableUnderlyingTypeOrSelf) : (type, null);
864static 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)
891(TypeWithAnnotations nextTypeWithAnnotations, TypeSymbol? nextType) = getNextIterationElements(currentPointer.Parameters[i].TypeWithAnnotations, canDigThroughNullable);
1164internal static bool ContainsNativeIntegerWrapperType(this TypeWithAnnotations type)
1504foreach (var arg in type.TypeArgumentsWithAnnotationsNoUseSiteDiagnostics)
1861private static bool NormalizeTaskTypesInType(CSharpCompilation compilation, ref TypeWithAnnotations typeWithAnnotations)
1866typeWithAnnotations = TypeWithAnnotations.Create(type, customModifiers: typeWithAnnotations.CustomModifiers);
1879var typeArgumentsBuilder = ArrayBuilder<TypeWithAnnotations>.GetInstance();
1884var typeWithModifier = typeArgumentsBuilder[i];
1890typeArgumentsBuilder[i] = TypeWithAnnotations.Create(typeArgNormalized, customModifiers: typeWithModifier.CustomModifiers);
1930var elementType = arrayType.ElementTypeWithAnnotations;
1941var pointedAtType = pointerType.PointedAtTypeWithAnnotations;
1953var returnType = funcPtrType.Signature.ReturnTypeWithAnnotations;
1956var paramTypes = ImmutableArray<TypeWithAnnotations>.Empty;
1960var paramsBuilder = ArrayBuilder<TypeWithAnnotations>.GetInstance(funcPtrType.Signature.ParameterCount);
1964var paramType = param.TypeWithAnnotations;
1993this 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 (84)
29internal readonly TypeWithAnnotations Value;
30internal Boxed(TypeWithAnnotations value)
72internal static TypeWithAnnotations Create(bool isNullableEnabled, TypeSymbol typeSymbol, bool isAnnotated = false)
82internal static TypeWithAnnotations Create(TypeSymbol typeSymbol, NullableAnnotation nullableAnnotation = NullableAnnotation.Oblivious, ImmutableArray<CustomModifier> customModifiers = default)
105internal TypeWithAnnotations AsAnnotated()
115internal TypeWithAnnotations AsNotAnnotated()
165private static TypeWithAnnotations CreateNonLazyType(TypeSymbol typeSymbol, NullableAnnotation nullableAnnotation, ImmutableArray<CustomModifier> customModifiers)
170private static TypeWithAnnotations CreateLazyNullableType(CSharpCompilation compilation, TypeWithAnnotations underlying)
186public TypeWithAnnotations SetIsAnnotated(CSharpCompilation compilation)
214TypeWithAnnotations makeNullableT()
227private TypeWithAnnotations AsNullableReferenceType() => _extensions.AsNullableReferenceType(this);
228public TypeWithAnnotations AsNotNullableReferenceType() => _extensions.AsNotNullableReferenceType(this);
233internal TypeWithAnnotations MergeEquivalentTypes(TypeWithAnnotations other, VarianceKind variance)
242public TypeWithAnnotations WithModifiers(ImmutableArray<CustomModifier> customModifiers) =>
327public bool Equals(TypeWithAnnotations other, TypeCompareKind comparison)
379internal sealed class EqualsComparer : EqualityComparer<TypeWithAnnotations>
391public override int GetHashCode(TypeWithAnnotations obj)
400public override bool Equals(TypeWithAnnotations x, TypeWithAnnotations y)
410internal bool TypeSymbolEquals(TypeWithAnnotations other, TypeCompareKind comparison) =>
425public TypeWithAnnotations SubstituteType(AbstractTypeMap typeMap) =>
428internal TypeWithAnnotations SubstituteTypeCore(AbstractTypeMap typeMap)
435var newTypeWithModifiers = typeMap.SubstituteType(typeSymbol);
514private bool TypeSymbolEqualsCore(TypeWithAnnotations other, TypeCompareKind comparison)
539public TypeWithAnnotations WithTypeAndModifiers(TypeSymbol typeSymbol, ImmutableArray<CustomModifier> customModifiers) =>
542public TypeWithAnnotations WithType(TypeSymbol typeSymbol) =>
562TypeWithAnnotations typeWithAnnotationsOpt,
597private static void AddNullableTransforms(TypeWithAnnotations typeWithAnnotations, ArrayBuilder<byte> transforms)
633public bool ApplyNullableTransforms(byte defaultTransformFlag, ImmutableArray<byte> transforms, ref int position, out TypeWithAnnotations result)
696public TypeWithAnnotations WithTopLevelNonNullability()
707public TypeWithAnnotations SetUnknownNullabilityForReferenceTypes()
734return other is TypeWithAnnotations t && this.Equals(t, TypeCompareKind.ConsiderEverything);
752public static bool operator ==(TypeWithAnnotations? x, TypeWithAnnotations? y)
760public static bool operator !=(TypeWithAnnotations? x, TypeWithAnnotations? y)
766internal bool IsSameAs(TypeWithAnnotations other)
822internal static Extensions CreateLazy(CSharpCompilation compilation, TypeWithAnnotations underlying)
831internal abstract TypeWithAnnotations AsNullableReferenceType(TypeWithAnnotations type);
832internal abstract TypeWithAnnotations AsNotNullableReferenceType(TypeWithAnnotations type);
834internal abstract TypeWithAnnotations WithModifiers(TypeWithAnnotations type, ImmutableArray<CustomModifier> customModifiers);
847internal abstract TypeWithAnnotations WithTypeAndModifiers(TypeWithAnnotations type, TypeSymbol typeSymbol, ImmutableArray<CustomModifier> customModifiers);
849internal abstract bool TypeSymbolEquals(TypeWithAnnotations type, TypeWithAnnotations other, TypeCompareKind comparison);
850internal abstract TypeWithAnnotations SubstituteType(TypeWithAnnotations type, AbstractTypeMap typeMap);
851internal abstract void ReportDiagnosticsIfObsolete(TypeWithAnnotations type, Binder binder, SyntaxNode syntax, BindingDiagnosticBag diagnostics);
879internal override TypeWithAnnotations WithModifiers(TypeWithAnnotations type, ImmutableArray<CustomModifier> customModifiers)
886internal override TypeWithAnnotations WithTypeAndModifiers(TypeWithAnnotations type, TypeSymbol typeSymbol, ImmutableArray<CustomModifier> customModifiers)
891internal override TypeWithAnnotations AsNullableReferenceType(TypeWithAnnotations type)
896internal override TypeWithAnnotations AsNotNullableReferenceType(TypeWithAnnotations type)
902internal override bool TypeSymbolEquals(TypeWithAnnotations type, TypeWithAnnotations other, TypeCompareKind comparison)
907internal override TypeWithAnnotations SubstituteType(TypeWithAnnotations type, AbstractTypeMap typeMap)
912internal override void ReportDiagnosticsIfObsolete(TypeWithAnnotations type, Binder binder, SyntaxNode syntax, BindingDiagnosticBag diagnostics)
929private readonly TypeWithAnnotations _underlying;
932public LazyNullableTypeParameter(CSharpCompilation compilation, TypeWithAnnotations underlying)
977internal override TypeWithAnnotations WithModifiers(TypeWithAnnotations type, ImmutableArray<CustomModifier> customModifiers)
987return TypeWithAnnotations.Create(resolvedType, type.NullableAnnotation, customModifiers: customModifiers);
993internal override TypeWithAnnotations WithTypeAndModifiers(TypeWithAnnotations type, TypeSymbol typeSymbol, ImmutableArray<CustomModifier> customModifiers)
997return TypeWithAnnotations.Create(typeSymbol, type.NullableAnnotation, customModifiers: customModifiers);
1003internal override TypeWithAnnotations AsNullableReferenceType(TypeWithAnnotations type)
1008internal override TypeWithAnnotations AsNotNullableReferenceType(TypeWithAnnotations type)
1017internal override TypeWithAnnotations SubstituteType(TypeWithAnnotations type, AbstractTypeMap typeMap)
1024var newUnderlying = _underlying.SubstituteTypeCore(typeMap);
1041internal override void ReportDiagnosticsIfObsolete(TypeWithAnnotations type, Binder binder, SyntaxNode syntax, BindingDiagnosticBag diagnostics)
1053internal override bool TypeSymbolEquals(TypeWithAnnotations type, TypeWithAnnotations other, TypeCompareKind comparison)
Microsoft.CodeAnalysis.CSharp.ExpressionEvaluator.ExpressionCompiler.UnitTests (1)