The effective "bounds" of a type parameter: the constraint types, effective interface set, and effective base type, determined from the declared constraints, with any cycles removed. The fields are exposed by the TypeParameterSymbol as ConstraintTypes, Interfaces, and BaseType.
        private TypeParameterBounds GetBounds(ConsList <TypeParameterSymbol> inProgress)
        {
            Debug.Assert(!inProgress.ContainsReference(this));
            Debug.Assert(!inProgress.Any() || ReferenceEquals(inProgress.Head.ContainingSymbol, this.ContainingSymbol));

            if (ReferenceEquals(_lazyBounds, TypeParameterBounds.Unset))
            {
                var constraintTypes = GetDeclaredConstraintTypes();
                Debug.Assert(!constraintTypes.IsDefault);

                //var diagnostics = ArrayBuilder<TypeParameterDiagnosticInfo>.GetInstance();
                //ArrayBuilder<TypeParameterDiagnosticInfo> useSiteDiagnosticsBuilder = null;
                bool inherited = (_containingSymbol.Kind == SymbolKind.Method) && ((MethodSymbol)_containingSymbol).IsOverride;
                //var bounds = this.ResolveBounds(this.ContainingAssembly.CorLibrary, inProgress.Prepend(this), constraintTypes, inherited, currentCompilation: null,
                //                                diagnosticsBuilder: diagnostics, useSiteDiagnosticsBuilder: ref useSiteDiagnosticsBuilder);
                var bounds = new TypeParameterBounds(ImmutableArray <TypeSymbol> .Empty, ImmutableArray <NamedTypeSymbol> .Empty, null, null);
                //DiagnosticInfo errorInfo = null;

                //if (diagnostics.Count > 0)
                //{
                //    errorInfo = diagnostics[0].DiagnosticInfo;
                //}
                //else if (useSiteDiagnosticsBuilder != null && useSiteDiagnosticsBuilder.Count > 0)
                //{
                //    foreach (var diag in useSiteDiagnosticsBuilder)
                //    {
                //        if (diag.DiagnosticInfo.Severity == DiagnosticSeverity.Error)
                //        {
                //            errorInfo = diag.DiagnosticInfo;
                //            break;
                //        }
                //        else if ((object)errorInfo == null)
                //        {
                //            errorInfo = diag.DiagnosticInfo;
                //        }
                //    }
                //}

                //diagnostics.Free();

                //Interlocked.CompareExchange(ref _lazyBoundsErrorInfo, errorInfo, CSDiagnosticInfo.EmptyErrorInfo);
                Interlocked.CompareExchange(ref _lazyBounds, bounds, TypeParameterBounds.Unset);
            }

            //Debug.Assert(!ReferenceEquals(_lazyBoundsErrorInfo, CSDiagnosticInfo.EmptyErrorInfo));
            return(_lazyBounds);
        }
コード例 #2
0
        private TypeParameterBounds GetBounds(ConsList<TypeParameterSymbol> inProgress)
        {
            Debug.Assert(!inProgress.ContainsReference(this));
            Debug.Assert(!inProgress.Any() || ReferenceEquals(inProgress.Head.ContainingSymbol, this.ContainingSymbol));

            if (ReferenceEquals(_lazyBounds, TypeParameterBounds.Unset))
            {
                var constraintTypes = GetDeclaredConstraintTypes();
                Debug.Assert(!constraintTypes.IsDefault);

                //var diagnostics = ArrayBuilder<TypeParameterDiagnosticInfo>.GetInstance();
                //ArrayBuilder<TypeParameterDiagnosticInfo> useSiteDiagnosticsBuilder = null;
                bool inherited = (_containingSymbol.Kind == SymbolKind.Method) && ((MethodSymbol)_containingSymbol).IsOverride;
                //var bounds = this.ResolveBounds(this.ContainingAssembly.CorLibrary, inProgress.Prepend(this), constraintTypes, inherited, currentCompilation: null,
                //                                diagnosticsBuilder: diagnostics, useSiteDiagnosticsBuilder: ref useSiteDiagnosticsBuilder);
                var bounds = new TypeParameterBounds(ImmutableArray<TypeSymbol>.Empty, ImmutableArray<NamedTypeSymbol>.Empty, null, null);
                //DiagnosticInfo errorInfo = null;

                //if (diagnostics.Count > 0)
                //{
                //    errorInfo = diagnostics[0].DiagnosticInfo;
                //}
                //else if (useSiteDiagnosticsBuilder != null && useSiteDiagnosticsBuilder.Count > 0)
                //{
                //    foreach (var diag in useSiteDiagnosticsBuilder)
                //    {
                //        if (diag.DiagnosticInfo.Severity == DiagnosticSeverity.Error)
                //        {
                //            errorInfo = diag.DiagnosticInfo;
                //            break;
                //        }
                //        else if ((object)errorInfo == null)
                //        {
                //            errorInfo = diag.DiagnosticInfo;
                //        }
                //    }
                //}

                //diagnostics.Free();

                //Interlocked.CompareExchange(ref _lazyBoundsErrorInfo, errorInfo, CSDiagnosticInfo.EmptyErrorInfo);
                Interlocked.CompareExchange(ref _lazyBounds, bounds, TypeParameterBounds.Unset);
            }

            //Debug.Assert(!ReferenceEquals(_lazyBoundsErrorInfo, CSDiagnosticInfo.EmptyErrorInfo));
            return _lazyBounds;
        }