internal override ImmutableArray <NamedTypeSymbol> InterfacesNoUseSiteDiagnostics( ConsList <TypeSymbol> basesBeingResolved ) { if (_lazyInterfaces.IsDefault) { var declaredInterfaces = GetDeclaredInterfaces(basesBeingResolved); if (!IsInterface) { // only interfaces needs to check for inheritance cycles via interfaces. return(declaredInterfaces); } ImmutableArray <NamedTypeSymbol> result = declaredInterfaces.SelectAsArray( t => BaseTypeAnalysis.TypeDependsOn(t, this) ? CyclicInheritanceError(this, t) : t ); ImmutableInterlocked.InterlockedCompareExchange( ref _lazyInterfaces, result, default(ImmutableArray <NamedTypeSymbol>) ); } return(_lazyInterfaces); }
public override ImmutableArray <NamedTypeSymbol> GetBaseTypesNoUseSiteDiagnostics(ConsList <TypeSymbol> basesBeingResolved) { if (_lazyBaseTypes.IsDefault) { var declaredInterfaces = GetDeclaredBaseTypes(basesBeingResolved); ImmutableArray <NamedTypeSymbol> result = declaredInterfaces .SelectAsArray(t => BaseTypeAnalysis.TypeDependsOn(t, this) ? CyclicInheritanceError(this, t) : t); ImmutableInterlocked.InterlockedCompareExchange(ref _lazyBaseTypes, result, default(ImmutableArray <NamedTypeSymbol>)); } return(_lazyBaseTypes); }
private ImmutableArray <NamedTypeSymbol> MakeAcyclicBaseTypes(ConsList <TypeSymbol> basesBeingResolved, DiagnosticBag diagnostics) { var declaredBaseTypes = GetDeclaredBaseTypes(basesBeingResolved: basesBeingResolved); ArrayBuilder <NamedTypeSymbol> result = ArrayBuilder <NamedTypeSymbol> .GetInstance(); foreach (var t in declaredBaseTypes) { if (BaseTypeAnalysis.TypeDependsOn(depends: t, on: this)) { result.Add(new ExtendedErrorTypeSymbol(t, LookupResultKind.NotReferencable, diagnostics.Add(InternalErrorCode.ERR_CycleInInterfaceInheritance, Locations[0], this, t))); continue; } else { result.Add(t); } HashSet <DiagnosticInfo> useSiteDiagnostics = null; if (t.DeclaringCompilation != this.DeclaringCompilation) { t.AddUseSiteDiagnostics(ref useSiteDiagnostics); foreach (var @interface in t.AllBaseTypesNoUseSiteDiagnostics) { if (@interface.DeclaringCompilation != this.DeclaringCompilation) { @interface.AddUseSiteDiagnostics(ref useSiteDiagnostics); } } } if (!useSiteDiagnostics.IsNullOrEmpty()) { diagnostics.Add(Locations[0], useSiteDiagnostics); } } return(result.ToImmutableAndFree()); }