本文整理汇总了C#中Microsoft.CodeAnalysis.CSharp.Symbols.TypeParameterSymbol类的典型用法代码示例。如果您正苦于以下问题:C# TypeParameterSymbol类的具体用法?C# TypeParameterSymbol怎么用?C# TypeParameterSymbol使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TypeParameterSymbol类属于Microsoft.CodeAnalysis.CSharp.Symbols命名空间,在下文中一共展示了TypeParameterSymbol类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RetargetingTypeParameterSymbol
public RetargetingTypeParameterSymbol(RetargetingModuleSymbol retargetingModule, TypeParameterSymbol underlyingTypeParameter)
: base(underlyingTypeParameter)
{
Debug.Assert((object)retargetingModule != null);
Debug.Assert(!(underlyingTypeParameter is RetargetingTypeParameterSymbol));
_retargetingModule = retargetingModule;
}
示例2: DependsOn
public static bool DependsOn(this TypeParameterSymbol typeParameter1, TypeParameterSymbol typeParameter2)
{
Debug.Assert((object)typeParameter1 != null);
Debug.Assert((object)typeParameter2 != null);
Func<TypeParameterSymbol, IEnumerable<TypeParameterSymbol>> dependencies = x => x.ConstraintTypesNoUseSiteDiagnostics.OfType<TypeParameterSymbol>();
return dependencies.TransitiveClosure(typeParameter1).Contains(typeParameter2);
}
示例3: SubstitutedTypeParameterSymbol
internal SubstitutedTypeParameterSymbol(Symbol newContainer, TypeMap map, TypeParameterSymbol substitutedFrom)
{
_container = newContainer;
// it is important that we don't use the map here in the constructor, as the map is still being filled
// in by TypeMap.WithAlphaRename. Instead, we can use the map lazily when yielding the constraints.
_map = map;
_substitutedFrom = substitutedFrom;
}
示例4: RetargetingTypeParameterSymbol
public RetargetingTypeParameterSymbol(RetargetingModuleSymbol retargetingModule, TypeParameterSymbol underlyingTypeParameter)
{
Debug.Assert((object)retargetingModule != null);
Debug.Assert((object)underlyingTypeParameter != null);
Debug.Assert(!(underlyingTypeParameter is RetargetingTypeParameterSymbol));
this.retargetingModule = retargetingModule;
this.underlyingTypeParameter = underlyingTypeParameter;
}
示例5: SubstituteTypeParameter
protected sealed override TypeSymbol SubstituteTypeParameter(TypeParameterSymbol typeParameter)
{
// It might need to be substituted directly.
TypeSymbol result;
if (Mapping.TryGetValue(typeParameter, out result))
{
return result;
}
return typeParameter;
}
示例6: SubstituteTypeParameter
protected sealed override TypeWithModifiers SubstituteTypeParameter(TypeParameterSymbol typeParameter)
{
// It might need to be substituted directly.
TypeWithModifiers result;
if (Mapping.TryGetValue(typeParameter, out result))
{
return result;
}
return new TypeWithModifiers(typeParameter);
}
示例7: EETypeParameterSymbol
public EETypeParameterSymbol(
Symbol container,
TypeParameterSymbol sourceTypeParameter,
int ordinal,
Func<TypeMap> getTypeMap)
{
Debug.Assert((container.Kind == SymbolKind.NamedType) || (container.Kind == SymbolKind.Method));
_container = container;
_sourceTypeParameter = sourceTypeParameter;
_ordinal = ordinal;
_getTypeMap = getTypeMap;
}
示例8: SubstitutedTypeParameterSymbol
internal SubstitutedTypeParameterSymbol(Symbol newContainer, TypeMap map, TypeParameterSymbol substitutedFrom, int ordinal)
{
_container = newContainer;
// it is important that we don't use the map here in the constructor, as the map is still being filled
// in by TypeMap.WithAlphaRename. Instead, we can use the map lazily when yielding the constraints.
_map = map;
_substitutedFrom = substitutedFrom;
_ordinal = ordinal;
#if DEBUG_ALPHA
_mySequence = _nextSequence++;
#endif
}
示例9: SubstituteTypeParameter
protected sealed override TypeWithModifiers SubstituteTypeParameter(TypeParameterSymbol typeParameter)
{
// It might need to be substituted directly.
TypeWithModifiers result;
if (Mapping.TryGetValue(typeParameter, out result))
{
if (typeParameter.NullabilityPreservation == CodeAnalysis.Symbols.NullabilityPreservationKind.None && result.Type.Kind == SymbolKind.NonNullableReference)
{
return new TypeWithModifiers(((NonNullableReferenceTypeSymbol)result.Type).UnderlyingType);
}
return result;
}
return new TypeWithModifiers(typeParameter);
}
示例10: SynthesizedContainer
/// <summary>
/// Used for <see cref="SynthesizedDelegateSymbol"/> construction.
/// </summary>
protected SynthesizedContainer(NamespaceOrTypeSymbol containingSymbol, string name, int parameterCount, bool returnsVoid)
{
var typeParameters = new TypeParameterSymbol[parameterCount + (returnsVoid ? 0 : 1)];
for (int i = 0; i < parameterCount; i++)
{
typeParameters[i] = new AnonymousTypeManager.AnonymousTypeParameterSymbol(this, i, "T" + (i + 1));
}
if (!returnsVoid)
{
typeParameters[parameterCount] = new AnonymousTypeManager.AnonymousTypeParameterSymbol(this, parameterCount, "TResult");
}
this.containingSymbol = containingSymbol;
this.name = name;
this.TypeMap = TypeMap.Empty;
this.typeParameters = typeParameters.AsImmutableOrNull();
}
示例11: GrowPool
private static void GrowPool(int count)
{
var initialPool = s_parameterPool;
while (count > initialPool.Length)
{
var newPoolSize = ((count + 0x0F) & ~0xF); // grow in increments of 16
var newPool = new TypeParameterSymbol[newPoolSize];
Array.Copy(initialPool, newPool, initialPool.Length);
for (int i = initialPool.Length; i < newPool.Length; i++)
{
newPool[i] = new IndexedTypeParameterSymbol(i);
}
Interlocked.CompareExchange(ref s_parameterPool, newPool, initialPool);
// repeat if race condition occurred and someone else resized the pool before us
// and the new pool is still too small
initialPool = s_parameterPool;
}
}
示例12: Contains
/// <summary>
/// Return true if the given type contains the specified type parameter.
/// </summary>
private static bool Contains(TypeSymbol type, TypeParameterSymbol typeParam)
{
switch (type.Kind)
{
case SymbolKind.ArrayType:
return Contains(((ArrayTypeSymbol)type).ElementType, typeParam);
case SymbolKind.PointerType:
return Contains(((PointerTypeSymbol)type).PointedAtType, typeParam);
case SymbolKind.NamedType:
case SymbolKind.ErrorType:
{
NamedTypeSymbol namedType = (NamedTypeSymbol)type;
while ((object)namedType != null)
{
ImmutableArray<TypeSymbol> typeParts = namedType.IsTupleType ? namedType.TupleElementTypes : namedType.TypeArgumentsNoUseSiteDiagnostics;
foreach (TypeSymbol typePart in typeParts)
{
if (Contains(typePart, typeParam))
{
return true;
}
}
namedType = namedType.ContainingType;
}
return false;
}
case SymbolKind.TypeParameter:
return type == typeParam;
default:
return false;
}
}
示例13: AddSubstitution
private static void AddSubstitution(ref MutableTypeMap substitution, TypeParameterSymbol tp1, TypeWithModifiers t2)
{
if (substitution == null)
{
substitution = new MutableTypeMap();
}
// MutableTypeMap.Add will throw if the key has already been added. However,
// if t1 was already in the substitution, it would have been substituted at the
// start of CanUnifyHelper and we wouldn't be here.
substitution.Add(tp1, t2);
}
示例14: GenerateConflictingConstraintsError
private static TypeParameterDiagnosticInfo GenerateConflictingConstraintsError(TypeParameterSymbol typeParameter, TypeSymbol deducedBase, bool classConflict)
{
// "Type parameter '{0}' inherits conflicting constraints '{1}' and '{2}'"
return new TypeParameterDiagnosticInfo(typeParameter, new CSDiagnosticInfo(ErrorCode.ERR_BaseConstraintConflict, typeParameter, deducedBase, classConflict ? "class" : "struct"));
}
示例15: IsValueType
private static bool IsValueType(TypeParameterSymbol typeParameter, ImmutableArray<TypeSymbol> constraintTypes)
{
return typeParameter.HasValueTypeConstraint || TypeParameterSymbol.IsValueTypeFromConstraintTypes(constraintTypes);
}