private NamedTypeSymbol MakeAcyclicBaseType(BindingDiagnosticBag diagnostics) { var typeKind = this.TypeKind; var compilation = this.DeclaringCompilation; NamedTypeSymbol declaredBase; if (typeKind == TypeKind.Enum) { Debug.Assert( (object)GetDeclaredBaseType(basesBeingResolved: null) == null, "Computation skipped for enums" ); declaredBase = compilation.GetSpecialType(SpecialType.System_Enum); } else { declaredBase = GetDeclaredBaseType(basesBeingResolved: null); } if ((object)declaredBase == null) { switch (typeKind) { case TypeKind.Class: if (this.SpecialType == SpecialType.System_Object) { return(null); } declaredBase = compilation.GetSpecialType(SpecialType.System_Object); break; case TypeKind.Struct: declaredBase = compilation.GetSpecialType(SpecialType.System_ValueType); break; case TypeKind.Interface: return(null); case TypeKind.Delegate: declaredBase = compilation.GetSpecialType( SpecialType.System_MulticastDelegate ); break; default: throw ExceptionUtilities.UnexpectedValue(typeKind); } } if (BaseTypeAnalysis.TypeDependsOn(declaredBase, this)) { return(new ExtendedErrorTypeSymbol( declaredBase, LookupResultKind.NotReferencable, diagnostics.Add(ErrorCode.ERR_CircularBase, Locations[0], declaredBase, this) )); } this.SetKnownToHaveNoDeclaredBaseCycles(); var useSiteInfo = new CompoundUseSiteInfo <AssemblySymbol>( diagnostics, ContainingAssembly ); NamedTypeSymbol current = declaredBase; do { if (current.DeclaringCompilation == this.DeclaringCompilation) { break; } current.AddUseSiteInfo(ref useSiteInfo); current = current.BaseTypeNoUseSiteDiagnostics; } while ((object)current != null); diagnostics.Add( useSiteInfo.Diagnostics.IsNullOrEmpty() ? Location.None : (FindBaseRefSyntax(declaredBase) ?? Locations[0]), useSiteInfo ); return(declaredBase); }