/// <summary> /// Parameterize the specified field (reuse if generic /// parameterization isn't necessary). /// </summary> internal Field parameterize(Field f) { // if not generic, short circuit and reuse original Type of = f.type(); if (!of.isGenericParameter()) { return(f); } // create new parameterized version of = parameterize(of); Field pf = new Field(this, f.m_name, f.m_flags, f.m_facets, f.m_lineNum, of); pf.m_reflect = f.m_reflect; return(pf); }
/// <summary> /// Parameterize the specified field (reuse if generic /// parameterization isn't necessary). /// </summary> internal Field parameterize(Field f) { // if not generic, short circuit and reuse original Type of = f.type(); if (!of.isGenericParameter()) return f; // create new parameterized version of = parameterize(of); Field pf = new Field(this, f.m_name, f.m_flags, f.m_facets, f.m_lineNum, of); pf.m_reflect = f.m_reflect; return pf; }
/// <summary> /// Figure out the map type: /// 1) if t was explicit then use it (check that it was a map type) /// 2) if we have field typed as a map , then use its definition /// 3) if inferred is false, then drop back to Obj:Obj /// 4) If inferred is true then return null and we'll infer the common key/val types /// </summary> private MapType toMapType(Type t, Field curField, bool infer) { if (t != null) { try { return (MapType)t; } catch (System.InvalidCastException) { throw err("Invalid map type: " + t); } } if (curField != null) { Type ft = curField.type().toNonNullable(); if (ft is MapType) return (MapType)ft; } if (infer) return null; return defaultMapType; }
/// <summary> /// Figure out the type of the list: /// 1) if t was explicit then use it /// 2) if we have field typed as a list, then use its definition /// 3) if inferred is false, then drop back to list of Obj /// 4) If inferred is true then return null and we'll infer the common type /// </summary> private Type toListOfType(Type t, Field curField, bool infer) { if (t != null) return t; if (curField != null) { Type ft = curField.type().toNonNullable(); if (ft is ListType) return ((ListType)ft).m_v; } if (infer) return null; return Sys.ObjType.toNullable(); }