internal override bool Equals(TypeSymbol t2, TypeCompareKind comparison) { if ((object)this == (object)t2) { return true; } ByRefReturnErrorTypeSymbol other = t2 as ByRefReturnErrorTypeSymbol; return (object)other != null && _referencedType.Equals(other._referencedType, comparison) && ((comparison & TypeCompareKind.IgnoreCustomModifiersAndArraySizesAndLowerBounds) != 0 || _countOfCustomModifiersPrecedingByRef == other._countOfCustomModifiersPrecedingByRef); }
public static bool Equals(this ITypeSymbol first, ITypeSymbol second, TypeCompareKind typeCompareKind) { return(first.Equals(second, new Microsoft.CodeAnalysis.SymbolEqualityComparer(typeCompareKind))); }
private SymbolEqualityComparer(TypeCompareKind compareKind) { CompareKind = compareKind; }
public static bool HaveSameReturnTypes(MethodSymbol member1, MethodSymbol member2, TypeCompareKind typeComparison) { return(HaveSameReturnTypes(member1, GetTypeMap(member1), member2, GetTypeMap(member2), typeComparison)); }
internal override bool Equals(TypeSymbol t2, TypeCompareKind comparison) { return((object)t2 == this); }
internal bool Equals(FunctionPointerParameterSymbol other, TypeCompareKind compareKind, IReadOnlyDictionary <TypeParameterSymbol, bool>?isValueTypeOverride) => other.Ordinal == Ordinal && _containingSymbol.Equals(other._containingSymbol, compareKind, isValueTypeOverride);
internal abstract override bool Equals(TypeSymbol t2, TypeCompareKind comparison);
internal override bool Equals(TypeSymbol t2, TypeCompareKind comparison) { if (ReferenceEquals(this, t2)) { return true; } // if ignoring dynamic, then treat dynamic the same as the type 'object' if ((comparison & TypeCompareKind.IgnoreDynamic) != 0 && (object)t2 != null && t2.TypeKind == TypeKind.Dynamic && this.SpecialType == Microsoft.CodeAnalysis.SpecialType.System_Object) { return true; } var other = t2 as TopLevel; return (object)other != null && string.Equals(MetadataName, other.MetadataName, StringComparison.Ordinal) && arity == other.arity && string.Equals(_namespaceName, other.NamespaceName, StringComparison.Ordinal) && _containingModule.Equals(other._containingModule); }
private static bool HaveSameParameterTypes( ImmutableArray <ParameterSymbol> params1, TypeMap typeMap1, ImmutableArray <ParameterSymbol> params2, TypeMap typeMap2, bool considerRefKindDifferences, TypeCompareKind typeComparison ) { Debug.Assert(params1.Length == params2.Length); var numParams = params1.Length; for (int i = 0; i < numParams; i++) { var param1 = params1[i]; var param2 = params2[i]; var type1 = SubstituteType(typeMap1, param1.TypeWithAnnotations); var type2 = SubstituteType(typeMap2, param2.TypeWithAnnotations); if (!type1.Equals(type2, typeComparison)) { return(false); } if ( ( typeComparison & TypeCompareKind.IgnoreCustomModifiersAndArraySizesAndLowerBounds ) == 0 && !HaveSameCustomModifiers( param1.RefCustomModifiers, typeMap1, param2.RefCustomModifiers, typeMap2 ) ) { return(false); } var refKind1 = param1.RefKind; var refKind2 = param2.RefKind; // Metadata signatures don't distinguish ref/out, but C# does - even when comparing metadata method signatures. if (considerRefKindDifferences) { if (refKind1 != refKind2) { return(false); } } else { if ((refKind1 == RefKind.None) != (refKind2 == RefKind.None)) { return(false); } } } return(true); }
/// <summary> /// Helper for more complicated cases of Equals like when we have generic instantiations or types nested within them. /// </summary> protected virtual bool EqualsComplicatedCases(NamedTypeSymbol other, TypeCompareKind comparison) { return(true); }
/// <summary> /// Compares this type to another type. /// </summary> public override bool Equals(TypeSymbol t2, TypeCompareKind comparison) { Debug.Assert(!this.IsTupleType); if ((object)t2 == this) { return(true); } if ((object)t2 == null) { return(false); } if ((comparison & TypeCompareKind.IgnoreDynamic) != 0) { if (t2.TypeKind == LanguageTypeKind.Dynamic) { // if ignoring dynamic, then treat dynamic the same as the type 'object' if (this.SpecialType == SpecialType.System_Object) { return(true); } } } NamedTypeSymbol other = t2 as NamedTypeSymbol; if ((object)other == null) { return(false); } // Compare OriginalDefinitions. var thisOriginalDefinition = this.OriginalDefinition; var otherOriginalDefinition = other.OriginalDefinition; bool thisIsOriginalDefinition = ((object)this == (object)thisOriginalDefinition); bool otherIsOriginalDefinition = ((object)other == (object)otherOriginalDefinition); if (thisIsOriginalDefinition && otherIsOriginalDefinition) { // If we continue, we either return false, or get into a cycle. return(false); } if ((thisIsOriginalDefinition || otherIsOriginalDefinition) && (comparison & (TypeCompareKind.IgnoreCustomModifiersAndArraySizesAndLowerBounds | TypeCompareKind.AllNullableIgnoreOptions)) == 0) { return(false); } // CONSIDER: original definitions are not unique for missing metadata type // symbols. Therefore this code may not behave correctly if 'this' is List<int> // where List`1 is a missing metadata type symbol, and other is similarly List<int> // but for a reference-distinct List`1. if (!TypeSymbol.Equals(thisOriginalDefinition, otherOriginalDefinition, TypeCompareKind.ConsiderEverything2)) { return(false); } // The checks above are supposed to handle the vast majority of cases. // More complicated cases are handled in a special helper to make the common case scenario simple/fast (fewer locals and smaller stack frame) return(EqualsComplicatedCases(other, comparison)); }
public static TypeCompareKind AddIgnoreTupleNames(this TypeCompareKind self, bool condition) { return(condition ? (self | TypeCompareKind.IgnoreTupleNames) : self); }
public static TypeCompareKind AddIgnoreDynamic(this TypeCompareKind self, bool condition) { return(condition ? (self | TypeCompareKind.IgnoreDynamic) : self); }
public static TypeCompareKind AddIgnoreCustomModifiersAndArraySizesAndLowerBounds(this TypeCompareKind self, bool condition) { return(condition ? (self | TypeCompareKind.IgnoreCustomModifiersAndArraySizesAndLowerBounds) : self); }
internal override bool Equals(TypeSymbol t2, TypeCompareKind comparison) { return(this.Equals(t2 as PointerTypeSymbol, comparison)); }
internal bool Equals(FunctionPointerParameterSymbol other, TypeCompareKind compareKind) => other.Ordinal == Ordinal && _containingSymbol.Equals(other._containingSymbol, compareKind);
internal override bool Equals(TypeSymbol t2, TypeCompareKind comparison) { if (ReferenceEquals(this, t2)) { return true; } if ((object)t2 == null) { return false; } CrefTypeParameterSymbol other = t2 as CrefTypeParameterSymbol; return (object)other != null && other._name == _name && other._ordinal == _ordinal && other._declaringSyntax.GetSyntax() == _declaringSyntax.GetSyntax(); }
// These object are unique (per index). internal override bool Equals(TypeSymbol t2, TypeCompareKind comparison) { return ReferenceEquals(this, t2); }
public override bool Equals(Symbol obj, TypeCompareKind compareKind) => obj is SynthesizedNamespaceSymbol other && Equals(other, compareKind);
/// <summary> /// For scenarios such as overriding with differing ref kinds (such as out vs in or ref) /// we need to compare function pointer parameters assuming that Ref matches RefReadonly/In /// and Out. This is done because you cannot overload on ref vs out vs in in regular method /// signatures, and we are disallowing similar overloads in source with function pointers. /// </summary> internal static bool RefKindEquals(TypeCompareKind compareKind, RefKind refKind1, RefKind refKind2) => (compareKind & TypeCompareKind.FunctionPointerRefMatchesOutInRefReadonly) != 0 ? (refKind1 == RefKind.None) == (refKind2 == RefKind.None) : refKind1 == refKind2;
internal override bool Equals(TypeSymbol t2, TypeCompareKind comparison, IReadOnlyDictionary <TypeParameterSymbol, bool>?isValueTypeOverrideOpt = null) { return(ReferenceEquals(this, t2)); }
public override bool Equals(Symbol obj, TypeCompareKind compareKind) { return(Equals(obj as TupleErrorFieldSymbol, compareKind)); }
private MetadataEntityReferenceComparer(TypeCompareKind compareKind) { _compareKind = compareKind; }
internal SymbolEqualityComparer(TypeCompareKind compareKind) { CompareKind = compareKind; }
internal override bool Equals(TypeSymbol t2, TypeCompareKind comparison) { if (ReferenceEquals(this, t2)) { return true; } var other = t2 as ExtendedErrorTypeSymbol; if ((object)other == null || _unreported || other._unreported) { return false; } return ((object)this.ContainingType != null ? this.ContainingType.Equals(other.ContainingType, comparison) : (object)this.ContainingSymbol == null ? (object)other.ContainingSymbol == null : this.ContainingSymbol.Equals(other.ContainingSymbol)) && this.Name == other.Name && this.Arity == other.Arity; }
private static bool HaveSameReturnTypes(Symbol member1, TypeMap typeMap1, Symbol member2, TypeMap typeMap2, TypeCompareKind typeComparison) { RefKind refKind1; TypeWithAnnotations unsubstitutedReturnType1; ImmutableArray <CustomModifier> refCustomModifiers1; member1.GetTypeOrReturnType(out refKind1, out unsubstitutedReturnType1, out refCustomModifiers1); RefKind refKind2; TypeWithAnnotations unsubstitutedReturnType2; ImmutableArray <CustomModifier> refCustomModifiers2; member2.GetTypeOrReturnType(out refKind2, out unsubstitutedReturnType2, out refCustomModifiers2); // short-circuit type map building in the easiest cases if (refKind1 != refKind2) { return(false); } var isVoid1 = unsubstitutedReturnType1.IsVoidType(); var isVoid2 = unsubstitutedReturnType2.IsVoidType(); if (isVoid1 != isVoid2) { return(false); } if (isVoid1) { if ((typeComparison & TypeCompareKind.IgnoreCustomModifiersAndArraySizesAndLowerBounds) != 0 || (unsubstitutedReturnType1.CustomModifiers.IsEmpty && unsubstitutedReturnType2.CustomModifiers.IsEmpty)) { return(true); } } var returnType1 = SubstituteType(typeMap1, unsubstitutedReturnType1); var returnType2 = SubstituteType(typeMap2, unsubstitutedReturnType2); if (!returnType1.Equals(returnType2, typeComparison)) { return(false); } if (((typeComparison & TypeCompareKind.IgnoreCustomModifiersAndArraySizesAndLowerBounds) == 0) && !HaveSameCustomModifiers(refCustomModifiers1, typeMap1, refCustomModifiers2, typeMap2)) { return(false); } return(true); }
public override bool Equals(Symbol obj, TypeCompareKind compareKind) { return(Equals(obj as TuplePropertySymbol, compareKind)); }
public override bool Equals(Symbol?other, TypeCompareKind comparison) => NativeIntegerTypeSymbol.EqualsHelper(this, other, comparison, symbol => symbol._underlyingProperty);
public override bool Equals(Symbol?obj, TypeCompareKind compareKind) => obj is DiscardSymbol other && this.TypeWithAnnotations.Equals(other.TypeWithAnnotations, compareKind);
public override bool Equals(Symbol obj, TypeCompareKind compareKind) { return(Equals(obj as TupleParameterSymbol)); }
internal override bool Equals(TypeSymbol t2, TypeCompareKind comparison) { if (ReferenceEquals(this, t2)) { return true; } var other = t2 as ErrorTypeParameterSymbol; return (object)other != null && other._ordinal == _ordinal && other.ContainingType.Equals(this.ContainingType, comparison); }
internal override bool Equals(TypeSymbol t2, TypeCompareKind comparison, IReadOnlyDictionary <TypeParameterSymbol, bool> isValueTypeOverrideOpt = null) { return(this.Equals(t2 as TypeParameterSymbol, comparison, isValueTypeOverrideOpt)); }
internal override bool Equals(TypeSymbol t2, TypeCompareKind comparison) { return(ReferenceEquals(this, t2)); }
internal bool MethodEqualityChecks(FunctionPointerParameterSymbol other, TypeCompareKind compareKind) => FunctionPointerTypeSymbol.RefKindEquals(compareKind, RefKind, other.RefKind) && ((compareKind & TypeCompareKind.IgnoreCustomModifiersAndArraySizesAndLowerBounds) != 0 || RefCustomModifiers.SequenceEqual(other.RefCustomModifiers)) && TypeWithAnnotations.Equals(other.TypeWithAnnotations, compareKind);
public override bool Equals(Symbol obj, TypeCompareKind compareKind) { return(Equals(obj as MissingAssemblySymbol)); }
internal override bool Equals(TypeSymbol t2, TypeCompareKind comparison) { if (ReferenceEquals(this, t2)) { return true; } var other = t2 as Nested; return (object)other != null && string.Equals(MetadataName, other.MetadataName, StringComparison.Ordinal) && arity == other.arity && _containingType.Equals(other._containingType, comparison); }
public override bool Equals(Symbol?obj, TypeCompareKind compareKind) => obj is DiscardSymbol other &&
internal override bool Equals(TypeSymbol t2, TypeCompareKind comparison) { if (ReferenceEquals(this, t2)) { return true; } var other = t2 as AnonymousTypePublicSymbol; return (object)other != null && this.TypeDescriptor.Equals(other.TypeDescriptor, comparison); }
internal override bool Equals(TypeSymbol t2, TypeCompareKind comparison) { if ((object)t2 == (object)this) { return true; } UnboundArgumentErrorTypeSymbol other = t2 as UnboundArgumentErrorTypeSymbol; return (object)other != null && string.Equals(other._name, _name, StringComparison.Ordinal) && object.Equals(other._errorInfo, _errorInfo); }