/// <summary> /// Verify any type parameter symbols within the type /// have the given containing method symbol. /// </summary> private void CheckTypeParameterContainingSymbols(MethodSymbol containingMethod, TypeSymbol type, int nReferencesExpected) { int nReferences = 0; type.VisitType((t, unused1, unused2) => { if (t.TypeKind == TypeKind.TypeParameter) { nReferences++; Assert.Same(t.ContainingSymbol, containingMethod); } return false; }, (object)null); Assert.Equal(nReferencesExpected, nReferences); }
/// <summary> /// (null TypeParameterSymbol "parameter"): Checks if the given type is a type parameter /// or its referent type is a type parameter (array/pointer) or contains a type parameter (aggregate type) /// (non-null TypeParameterSymbol "parameter"): above + also checks if the type parameter /// is the same as "parameter" /// </summary> public static bool ContainsTypeParameter(this TypeSymbol type, TypeParameterSymbol parameter = null) { var result = type.VisitType(s_containsTypeParameterPredicate, parameter); return((object)result != null); }
/// <summary> /// Returns true if all type parameter references within the given /// type belong to containingSymbol or its containing types. /// </summary> public static bool IsContainingSymbolOfAllTypeParameters(this Symbol containingSymbol, TypeSymbol type) { return(type.VisitType(s_hasInvalidTypeParameterFunc, containingSymbol) is null); }
/// <summary> /// Return true if the type contains any dynamic type reference. /// </summary> public static bool ContainsDynamic(this TypeSymbol type) { var result = type.VisitType(s_containsDynamicPredicate, null); return((object)result != null); }
internal static bool TryGetNames(TypeSymbol type, ArrayBuilder <string> namesBuilder) { type.VisitType((t, builder, _ignore) => AddNames(t, builder), namesBuilder); return(namesBuilder.Any(name => name != null)); }
/// <summary> /// Returns true if all type parameter references within the given /// type belong to containingSymbol or its containing types. /// </summary> public static bool IsContainingSymbolOfAllTypeParameters(this Symbol containingSymbol, TypeSymbol type) { return((object)type.VisitType(HasInvalidTypeParameterFunc, containingSymbol) == null); }