Skip to content

Commit 0991c16

Browse files
working on nesting types
1 parent 7e10671 commit 0991c16

File tree

1 file changed

+6
-34
lines changed

1 file changed

+6
-34
lines changed

compiler/internal/typeparams/collect.go

Lines changed: 6 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -116,21 +116,10 @@ func (c *visitor) Visit(n ast.Node) (w ast.Visitor) {
116116
}
117117

118118
instance, ok := c.info.Instances[ident]
119-
if ok {
120-
c.addNamedInstance(ident, instance)
121-
return
122-
}
123-
124-
def, ok := c.info.Defs[ident]
125-
if ok && def != nil {
126-
c.addNestedNamed(ident, def)
119+
if !ok {
127120
return
128121
}
129122

130-
return
131-
}
132-
133-
func (c *visitor) addNamedInstance(ident *ast.Ident, instance types.Instance) {
134123
obj := c.info.ObjectOf(ident)
135124

136125
// For types embedded in structs, the object the identifier resolves to is a
@@ -144,39 +133,22 @@ func (c *visitor) addNamedInstance(ident *ast.Ident, instance types.Instance) {
144133
if t, ok := typ.(*types.Named); ok {
145134
obj = t.Obj()
146135
}
147-
inst := Instance{
136+
c.instances.Add(Instance{
148137
Object: obj,
149138
TArgs: c.resolver.SubstituteAll(instance.TypeArgs),
150-
}
151-
fmt.Printf(">>>[add Named instance] %v\n", inst) // TODO(grantnelson-wf): remove
152-
c.instances.Add(inst)
139+
})
153140

154141
if t, ok := obj.Type().(*types.Named); ok {
155142
for i := 0; i < t.NumMethods(); i++ {
156143
method := t.Method(i)
157-
inst2 := Instance{
144+
c.instances.Add(Instance{
158145
Object: method.Origin(),
159146
TArgs: c.resolver.SubstituteAll(instance.TypeArgs),
160-
}
161-
fmt.Printf(">>>[add Named instance's method] %v\n", inst2) // TODO(grantnelson-wf): remove
162-
c.instances.Add(inst2)
147+
})
163148
}
164149
}
165-
}
166-
167-
// TODO(grantnelson-wf): finish or remove
168-
func (c *visitor) addNestedNamed(ident *ast.Ident, obj types.Object) {
169-
typ := obj.Type()
170-
if ptr, ok := typ.(*types.Pointer); ok {
171-
typ = ptr.Elem()
172-
}
173-
if t, ok := typ.(*types.Named); ok {
174-
obj = t.Obj()
175-
}
176150

177-
if t, ok := obj.(*types.TypeName); ok {
178-
fmt.Printf(">>>[add Nested named] %s => %v\n\t%v\n", ident.Name, t, c.resolver) // TODO(grantnelson-wf): remove
179-
}
151+
return
180152
}
181153

182154
// seedVisitor implements ast.Visitor that collects information necessary to

0 commit comments

Comments
 (0)