Binder\Binder_Lookup.cs (4)
185this.LookupMembersInTypeParameter(result, (TypeParameterSymbol)type, name, arity, basesBeingResolved, options, originalBinder, diagnose, ref useSiteInfo);
1168private void LookupMembersInTypeParameter(LookupResult current, TypeParameterSymbol typeParameter, string name, int arity, ConsList<TypeSymbol> basesBeingResolved, LookupOptions options, Binder originalBinder, bool diagnose, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
1868this.AddMemberLookupSymbolsInfoInTypeParameter(result, (TypeParameterSymbol)type, options, originalBinder);
2033private void AddMemberLookupSymbolsInfoInTypeParameter(LookupSymbolsInfo result, TypeParameterSymbol type, LookupOptions options, Binder originalBinder)
Binder\Semantics\Conversions\ConversionsBase.cs (21)
1757private static bool HasIdentityConversionToAny(NamedTypeSymbol type, ArrayBuilder<(NamedTypeSymbol ParticipatingType, TypeParameterSymbol ConstrainedToTypeOpt)> targetTypes)
2523return HasImplicitReferenceTypeParameterConversion((TypeParameterSymbol)source, destination, ref useSiteInfo);
2702public bool HasImplicitTypeParameterConversion(TypeParameterSymbol source, TypeSymbol destination, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
2715source.DependsOn((TypeParameterSymbol)destination))
2723private bool HasImplicitReferenceTypeParameterConversion(TypeParameterSymbol source, TypeSymbol destination, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
2752source.DependsOn((TypeParameterSymbol)destination))
2761private bool HasImplicitEffectiveBaseConversion(TypeParameterSymbol source, TypeSymbol destination, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
2785private bool HasImplicitEffectiveInterfaceSetConversion(TypeParameterSymbol source, TypeSymbol destination, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
2964TypeParameterSymbol typeParameterSymbol = (TypeParameterSymbol)typeParameters[paramIndex].Type;
3026private bool HasImplicitBoxingTypeParameterConversion(TypeParameterSymbol source, TypeSymbol destination, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
3055source.DependsOn((TypeParameterSymbol)destination))
3082HasImplicitBoxingTypeParameterConversion((TypeParameterSymbol)source, destination, ref useSiteInfo))
3306TypeParameterSymbol s = source as TypeParameterSymbol;
3307TypeParameterSymbol t = destination as TypeParameterSymbol;
3353TypeParameterSymbol s = source as TypeParameterSymbol;
3354TypeParameterSymbol t = destination as TypeParameterSymbol;
Binder\Semantics\Conversions\UserDefinedExplicitConversions.cs (7)
36var d = ArrayBuilder<(NamedTypeSymbol ParticipatingType, TypeParameterSymbol ConstrainedToTypeOpt)>.GetInstance();
74private static void ComputeUserDefinedExplicitConversionTypeSet(TypeSymbol source, TypeSymbol target, ArrayBuilder<(NamedTypeSymbol ParticipatingType, TypeParameterSymbol ConstrainedToTypeOpt)> d, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
90ArrayBuilder<(NamedTypeSymbol ParticipatingType, TypeParameterSymbol ConstrainedToTypeOpt)> d,
102foreach ((NamedTypeSymbol declaringType, TypeParameterSymbol constrainedToTypeOpt) in d)
117foreach ((NamedTypeSymbol declaringType, TypeParameterSymbol constrainedToTypeOpt) in d)
127TypeParameterSymbol constrainedToTypeOpt,
146TypeParameterSymbol constrainedToTypeOpt,
Binder\Semantics\Conversions\UserDefinedImplicitConversions.cs (7)
80var d = ArrayBuilder<(NamedTypeSymbol ParticipatingType, TypeParameterSymbol ConstrainedToTypeOpt)>.GetInstance();
118private static void ComputeUserDefinedImplicitConversionTypeSet(TypeSymbol s, TypeSymbol t, ArrayBuilder<(NamedTypeSymbol ParticipatingType, TypeParameterSymbol ConstrainedToTypeOpt)> d, ref CompoundUseSiteInfo<AssemblySymbol> useSiteInfo)
146ArrayBuilder<(NamedTypeSymbol ParticipatingType, TypeParameterSymbol ConstrainedToTypeOpt)> d,
250foreach ((NamedTypeSymbol declaringType, TypeParameterSymbol constrainedToTypeOpt) in d)
265foreach ((NamedTypeSymbol declaringType, TypeParameterSymbol constrainedToTypeOpt) in d)
275TypeParameterSymbol constrainedToTypeOpt,
946var d = ArrayBuilder<(NamedTypeSymbol ParticipatingType, TypeParameterSymbol ConstrainedToTypeOpt)>.GetInstance();
Binder\WithCrefTypeParametersBinder.cs (10)
22private MultiDictionary<string, TypeParameterSymbol> _lazyTypeParameterMap;
30protected override MultiDictionary<string, TypeParameterSymbol> TypeParameterMap
36MultiDictionary<string, TypeParameterSymbol> map = CreateTypeParameterMap();
44private MultiDictionary<string, TypeParameterSymbol> CreateTypeParameterMap()
46var map = new MultiDictionary<string, TypeParameterSymbol>();
78private void AddTypeParameters(TypeSyntax typeSyntax, MultiDictionary<string, TypeParameterSymbol> map)
103private void AddTypeParameters(MemberCrefSyntax memberSyntax, MultiDictionary<string, TypeParameterSymbol> map)
112private static void AddTypeParameters(GenericNameSyntax genericNameSyntax, MultiDictionary<string, TypeParameterSymbol> map)
132TypeParameterSymbol typeParameterSymbol = new CrefTypeParameterSymbol(name, i, typeParameterSyntax);
145foreach (TypeParameterSymbol typeParameter in kvp.Value)
Symbols\ConstraintsHelper.cs (41)
27public readonly TypeParameterSymbol TypeParameter;
30public TypeParameterDiagnosticInfo(TypeParameterSymbol typeParameter, UseSiteInfo<AssemblySymbol> useSiteInfo)
71this TypeParameterSymbol typeParameter,
73ConsList<TypeParameterSymbol> inProgress,
100this TypeParameterSymbol typeParameter,
102ConsList<TypeParameterSymbol> inProgress,
141var constraintTypeParameter = (TypeParameterSymbol)constraintType.Type;
142ConsList<TypeParameterSymbol> constraintsInProgress;
159constraintsInProgress = ConsList<TypeParameterSymbol>.Empty;
215var underlyingTypeParameter = (TypeParameterSymbol)underlyingType;
318ImmutableArray<TypeParameterSymbol> typeParameters,
348ImmutableArray<TypeParameterSymbol> typeParameters,
386internal static ImmutableArray<TypeParameterConstraintClause> AdjustConstraintKindsBasedOnConstraintTypes(ImmutableArray<TypeParameterSymbol> typeParameters, ImmutableArray<TypeParameterConstraintClause> constraintClauses)
392SmallDictionary<TypeParameterSymbol, bool> isValueTypeMap = TypeParameterConstraintClause.BuildIsValueTypeMap(typeParameters, constraintClauses);
393SmallDictionary<TypeParameterSymbol, bool> isReferenceTypeFromConstraintTypesMap = TypeParameterConstraintClause.BuildIsReferenceTypeFromConstraintTypesMap(typeParameters, constraintClauses);
399var typeParameter = typeParameters[i];
436TypeParameterSymbol typeParameter,
838ImmutableArray<TypeParameterSymbol> typeParameters,
844HashSet<TypeParameterSymbol> ignoreTypeConstraintsDependentOnTypeParametersOpt = null)
875TypeParameterSymbol typeParameter,
954TypeParameterSymbol typeParameter,
959HashSet<TypeParameterSymbol> ignoreTypeConstraintsDependentOnTypeParametersOpt)
1015static bool errorIfNotSatisfiesConstructorConstraint(Symbol containingSymbol, TypeParameterSymbol typeParameter, TypeWithAnnotations typeArgument, ArrayBuilder<TypeParameterDiagnosticInfo> diagnosticsBuilder)
1040TypeParameterSymbol typeParameter,
1064TypeParameterSymbol typeParameter,
1139var typeParameter = type as TypeParameterSymbol;
1177var typeParameter = type as TypeParameterSymbol;
1195TypeParameterSymbol typeParameter,
1272var typeParameter = (TypeParameterSymbol)typeArgument.Type;
1326private static bool IsReferenceType(TypeParameterSymbol typeParameter, ImmutableArray<TypeWithAnnotations> constraintTypes)
1328return typeParameter.HasReferenceTypeConstraint || TypeParameterSymbol.CalculateIsReferenceTypeFromConstraintTypes(constraintTypes);
1331private static bool IsValueType(TypeParameterSymbol typeParameter, ImmutableArray<TypeWithAnnotations> constraintTypes)
1333return typeParameter.HasValueTypeConstraint || TypeParameterSymbol.CalculateIsValueTypeFromConstraintTypes(constraintTypes);
1336private static TypeParameterDiagnosticInfo GenerateConflictingConstraintsError(TypeParameterSymbol typeParameter, TypeSymbol deducedBase, bool classConflict)
1387var typeParameter = (TypeParameterSymbol)typeArgument;
Symbols\MemberSignatureComparer.cs (9)
595public static bool HaveSameConstraints(ImmutableArray<TypeParameterSymbol> typeParameters1, TypeMap typeMap1, ImmutableArray<TypeParameterSymbol> typeParameters2, TypeMap typeMap2)
611public static bool HaveSameConstraints(TypeParameterSymbol typeParameter1, TypeMap typeMap1, TypeParameterSymbol typeParameter2, TypeMap typeMap2)
627private static bool HaveSameTypeConstraints(TypeParameterSymbol typeParameter1, TypeMap typeMap1, TypeParameterSymbol typeParameter2, TypeMap typeMap2, IEqualityComparer<TypeSymbol> comparer)
654public static bool HaveSameNullabilityInConstraints(TypeParameterSymbol typeParameter1, TypeMap typeMap1, TypeParameterSymbol typeParameter2, TypeMap typeMap2)
674private static bool AreConstraintTypesSubset(HashSet<TypeSymbol> constraintTypes1, HashSet<TypeSymbol> constraintTypes2, TypeParameterSymbol typeParameter2)
Symbols\Source\TypeParameterConstraintClause.cs (19)
128internal static SmallDictionary<TypeParameterSymbol, bool> BuildIsValueTypeMap(
129ImmutableArray<TypeParameterSymbol> typeParameters,
134var isValueTypeMap = new SmallDictionary<TypeParameterSymbol, bool>(ReferenceEqualityComparer.Instance);
136foreach (TypeParameterSymbol typeParameter in typeParameters)
138isValueType(typeParameter, constraintClauses, isValueTypeMap, ConsList<TypeParameterSymbol>.Empty);
143static bool isValueType(TypeParameterSymbol thisTypeParameter, ImmutableArray<TypeParameterConstraintClause> constraintClauses, SmallDictionary<TypeParameterSymbol, bool> isValueTypeMap, ConsList<TypeParameterSymbol> inProgress)
172if (type is TypeParameterSymbol typeParameter && (object)typeParameter.ContainingSymbol == (object)container)
193internal static SmallDictionary<TypeParameterSymbol, bool> BuildIsReferenceTypeFromConstraintTypesMap(
194ImmutableArray<TypeParameterSymbol> typeParameters,
199var isReferenceTypeFromConstraintTypesMap = new SmallDictionary<TypeParameterSymbol, bool>(ReferenceEqualityComparer.Instance);
201foreach (TypeParameterSymbol typeParameter in typeParameters)
203isReferenceTypeFromConstraintTypes(typeParameter, constraintClauses, isReferenceTypeFromConstraintTypesMap, ConsList<TypeParameterSymbol>.Empty);
208static bool isReferenceTypeFromConstraintTypes(TypeParameterSymbol thisTypeParameter, ImmutableArray<TypeParameterConstraintClause> constraintClauses,
209SmallDictionary<TypeParameterSymbol, bool> isReferenceTypeFromConstraintTypesMap, ConsList<TypeParameterSymbol> inProgress)
232if (type is TypeParameterSymbol typeParameter)
248else if (TypeParameterSymbol.NonTypeParameterConstraintImpliesReferenceType(type))
Symbols\TypeMap.cs (29)
26internal static ImmutableArray<TypeWithAnnotations> TypeParametersAsTypeSymbolsWithAnnotations(ImmutableArray<TypeParameterSymbol> typeParameters)
31internal static ImmutableArray<TypeWithAnnotations> TypeParametersAsTypeSymbolsWithIgnoredAnnotations(ImmutableArray<TypeParameterSymbol> typeParameters)
42internal TypeMap(ImmutableArray<TypeParameterSymbol> from, ImmutableArray<TypeWithAnnotations> to, bool allowAlpha = false)
50internal TypeMap(ImmutableArray<TypeParameterSymbol> from, ImmutableArray<TypeParameterSymbol> 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)
75TypeParameterSymbol tp = typeParameters[i];
84private static readonly SmallDictionary<TypeParameterSymbol, TypeWithAnnotations> s_emptyDictionary =
85new SmallDictionary<TypeParameterSymbol, TypeWithAnnotations>(ReferenceEqualityComparer.Instance);
103private TypeMap WithAlphaRename(ImmutableArray<TypeParameterSymbol> oldTypeParameters, Symbol newOwner, out ImmutableArray<TypeParameterSymbol> newTypeParameters)
107newTypeParameters = ImmutableArray<TypeParameterSymbol>.Empty;
118ArrayBuilder<TypeParameterSymbol> newTypeParametersBuilder = ArrayBuilder<TypeParameterSymbol>.GetInstance();
125foreach (var tp in oldTypeParameters)
139internal TypeMap WithAlphaRename(NamedTypeSymbol oldOwner, NamedTypeSymbol newOwner, out ImmutableArray<TypeParameterSymbol> newTypeParameters)
145internal TypeMap WithAlphaRename(MethodSymbol oldOwner, Symbol newOwner, out ImmutableArray<TypeParameterSymbol> newTypeParameters)
154out ImmutableArray<TypeParameterSymbol> newTypeParameters,
155out ImmutableArray<TypeParameterSymbol> oldTypeParameters,
173var parameters = ArrayBuilder<TypeParameterSymbol>.GetInstance();
200private static SmallDictionary<TypeParameterSymbol, TypeWithAnnotations> ConstructMapping(ImmutableArray<TypeParameterSymbol> from, ImmutableArray<TypeWithAnnotations> to)
202var mapping = new SmallDictionary<TypeParameterSymbol, TypeWithAnnotations>(ReferenceEqualityComparer.Instance);
208TypeParameterSymbol tp = from[i];
Symbols\TypeSymbolExtensions.cs (19)
67var typeParameter = (TypeParameterSymbol)type;
84return type is TypeParameterSymbol { IsValueType: false, IsNotNullable: false };
111var constraintTypes = ((TypeParameterSymbol)type).ConstraintTypesNoUseSiteDiagnostics;
329public static bool IsMethodTypeParameter(this TypeParameterSymbol p)
1109public static bool ContainsTypeParameter(this TypeSymbol type, TypeParameterSymbol? parameter = null)
1115private static readonly Func<TypeSymbol, TypeParameterSymbol?, bool, bool> s_containsTypeParameterPredicate =
1129public static bool ContainsTypeParameters(this TypeSymbol type, HashSet<TypeParameterSymbol> parameters)
1135private static readonly Func<TypeSymbol, HashSet<TypeParameterSymbol>, bool, bool> s_containsTypeParametersPredicate =
1136(type, parameters, unused) => type.TypeKind == TypeKind.TypeParameter && parameters.Contains((TypeParameterSymbol)type);
1593internal static ImmutableArray<TypeParameterSymbol> GetAllTypeParameters(this NamedTypeSymbol type)
1601var builder = ArrayBuilder<TypeParameterSymbol>.GetInstance();
1610internal static void GetAllTypeParameters(this NamedTypeSymbol type, ArrayBuilder<TypeParameterSymbol> result)
1625internal static TypeParameterSymbol? FindEnclosingTypeParameter(this NamedTypeSymbol type, string name)
1627var allTypeParameters = ArrayBuilder<TypeParameterSymbol>.GetInstance();
1630TypeParameterSymbol? result = null;
1632foreach (TypeParameterSymbol tpEnclosing in allTypeParameters)
1649internal static TypeParameterSymbol? FindEnclosingTypeParameter(this Symbol methodOrType, string name)
1665foreach (var typeParameter in methodOrType.GetMemberTypeParameters())