예제 #1
0
        private ArrayTypeSymbol SubstituteArrayType(ArrayTypeSymbol t)
        {
            var oldElement = t.ElementTypeWithAnnotations;
            TypeWithAnnotations element = oldElement.SubstituteType(this);

            if (element.IsSameAs(oldElement))
            {
                return(t);
            }

            if (t.IsSZArray)
            {
                ImmutableArray <NamedTypeSymbol> interfaces = t.InterfacesNoUseSiteDiagnostics();
                Debug.Assert(0 <= interfaces.Length && interfaces.Length <= 2);

                if (interfaces.Length == 1)
                {
                    Debug.Assert(interfaces[0] is NamedTypeSymbol); // IList<T>
                    interfaces = ImmutableArray.Create <NamedTypeSymbol>(
                        SubstituteNamedType(interfaces[0])
                        );
                }
                else if (interfaces.Length == 2)
                {
                    Debug.Assert(interfaces[0] is NamedTypeSymbol); // IList<T>
                    interfaces = ImmutableArray.Create <NamedTypeSymbol>(
                        SubstituteNamedType(interfaces[0]),
                        SubstituteNamedType(interfaces[1])
                        );
                }
                else if (interfaces.Length != 0)
                {
                    throw ExceptionUtilities.Unreachable;
                }

                return(ArrayTypeSymbol.CreateSZArray(
                           element,
                           t.BaseTypeNoUseSiteDiagnostics,
                           interfaces
                           ));
            }

            return(ArrayTypeSymbol.CreateMDArray(
                       element,
                       t.Rank,
                       t.Sizes,
                       t.LowerBounds,
                       t.BaseTypeNoUseSiteDiagnostics
                       ));
        }