public void SetTypeVars(TypeArray typeVars) { if (typeVars == null) { _typeVarsThis = null; _typeVarsAll = null; } else { TypeArray outerTypeVars; if (GetOuterAgg() != null) { Debug.Assert(GetOuterAgg().GetTypeVars() != null); Debug.Assert(GetOuterAgg().GetTypeVarsAll() != null); outerTypeVars = GetOuterAgg().GetTypeVarsAll(); } else { outerTypeVars = TypeArray.Empty; } _typeVarsThis = typeVars; _typeVarsAll = TypeArray.Concat(outerTypeVars, typeVars); } }
public AggregateType(AggregateSymbol parent, TypeArray typeArgsThis, AggregateType outerType) : base(TypeKind.TK_AggregateType) { Debug.Assert(typeArgsThis != null); OuterType = outerType; OwningAggregate = parent; TypeArgsThis = typeArgsThis; // Here we need to check our current type args. If we have an open placeholder, // then we need to have all open placeholders, and we want to flush // our outer type args so that they're open placeholders. // // This is because of the following scenario: // // class B<T> // { // class C<U> // { // } // class D // { // void Foo() // { // Type T = typeof(C<>); // } // } // } // // The outer type will be B<T>, but the inner type will be C<>. However, // this will eventually be represented in IL as B<>.C<>. As such, we should // keep our data structures clear - if we have one open type argument, then // all of them must be open type arguments. // // Ensure that invariant here. Debug.Assert(outerType == null || outerType.TypeArgsAll != null); TypeArgsAll = outerType != null?TypeArray.Concat(outerType.TypeArgsAll, typeArgsThis) : typeArgsThis; }