bool IBoundDeclVisitor <bool> .Visit(BoundTupleType decl) { if (!TryInferParam(decl)) { TupleType paramDecl = ParamType as TupleType; if (paramDecl == null) { mFailed = true; return(false); } if (paramDecl.Fields.Count != decl.Fields.Count) { mFailed = true; return(false); } for (int i = 0; i < paramDecl.Fields.Count; i++) { mParamTypes.Push(paramDecl.Fields[i]); decl.Fields[i].Accept(this); mParamTypes.Pop(); } } return(false); }
public static IBoundDecl[] Expand(this IBoundDecl decl) { // the unit type expands to no values if (ReferenceEquals(decl, Decl.Unit)) { return(new IBoundDecl[0]); } // a tuple expands to its fields BoundTupleType tuple = decl as BoundTupleType; if (tuple != null) { return(tuple.Fields.ToArray()); } // everything else expands to just itself return(new IBoundDecl[] { decl }); }