(ref *gen.Elem, root string, params gen.GenericTypeParams)
| 135 | ` |
| 136 | |
| 137 | func (fs *FileSet) nextInline(ref *gen.Elem, root string, params gen.GenericTypeParams) { |
| 138 | switch el := (*ref).(type) { |
| 139 | case *gen.BaseElem: |
| 140 | // ensure that we're not inlining |
| 141 | // a type into itself |
| 142 | typ := el.TypeName() |
| 143 | if el.Value == gen.IDENT && typ != root { |
| 144 | if node, ok := fs.Identities[typ]; ok && node.Complexity() < maxComplex { |
| 145 | infof("inlining %s\n", typ) |
| 146 | |
| 147 | // This should never happen; it will cause |
| 148 | // infinite recursion. |
| 149 | if node == *ref { |
| 150 | panic(fatalloop) |
| 151 | } |
| 152 | |
| 153 | *ref = node.Copy() |
| 154 | fs.nextInline(ref, node.TypeName(), params) |
| 155 | } else if !ok && !el.Resolved() { |
| 156 | if params.ToPointerMap[typ] == "" && (!strings.Contains(typ, "[") || !strings.Contains(typ, "]")) { |
| 157 | // this is the point at which we're sure that |
| 158 | // we've got a type that isn't a primitive, |
| 159 | // a library builtin, or a processed type |
| 160 | warnf("unresolved identifier: %s\n", typ) |
| 161 | } |
| 162 | } |
| 163 | } |
| 164 | case *gen.Struct: |
| 165 | for i := range el.Fields { |
| 166 | fs.nextInline(&el.Fields[i].FieldElem, root, el.TypeParams()) |
| 167 | } |
| 168 | case *gen.Array: |
| 169 | fs.nextInline(&el.Els, root, params) |
| 170 | case *gen.Slice: |
| 171 | fs.nextInline(&el.Els, root, params) |
| 172 | case *gen.Map: |
| 173 | fs.nextInline(&el.Value, root, params) |
| 174 | case *gen.Ptr: |
| 175 | fs.nextInline(&el.Value, root, params) |
| 176 | default: |
| 177 | panic("bad elem type") |
| 178 | } |
| 179 | } |
no test coverage detected