@@ -97,6 +97,11 @@ func isGopCommon(name string) bool {
97
97
98
98
// InitThisGopPkg initializes a Go+ package.
99
99
func InitThisGopPkg (pkg * types.Package ) {
100
+ InitThisGopPkgEx (pkg , nil )
101
+ }
102
+
103
+ // InitThisGopPkg initializes a Go+ package. pos map overload name to postion.
104
+ func InitThisGopPkgEx (pkg * types.Package , pos map [string ]token.Pos ) {
100
105
scope := pkg .Scope ()
101
106
gopos := make ([]string , 0 , 4 )
102
107
overloads := make (map [omthd ][]types.Object )
@@ -156,15 +161,15 @@ func InitThisGopPkg(pkg *types.Package) {
156
161
}
157
162
}
158
163
if len (fns ) > 0 {
159
- newOverload (pkg , scope , m , fns )
164
+ newOverload (pkg , scope , m , fns , pos )
160
165
}
161
166
delete (overloads , m )
162
167
}
163
168
}
164
169
for key , items := range overloads {
165
170
off := len (key .name ) + 2
166
171
fns := overloadFuncs (off , items )
167
- newOverload (pkg , scope , key , fns )
172
+ newOverload (pkg , scope , key , fns , pos )
168
173
}
169
174
for name , items := range onameds {
170
175
off := len (name ) + 2
@@ -310,19 +315,19 @@ func checkOverloads(scope *types.Scope, gopoName string) (ret []string, exists b
310
315
return
311
316
}
312
317
313
- func newOverload (pkg * types.Package , scope * types.Scope , m omthd , fns []types.Object ) {
318
+ func newOverload (pkg * types.Package , scope * types.Scope , m omthd , fns []types.Object , pos map [ string ]token. Pos ) {
314
319
if m .typ == nil {
315
320
if debugImport {
316
321
log .Println ("==> NewOverloadFunc" , m .name )
317
322
}
318
- o := NewOverloadFunc (token . NoPos , pkg , m .name , fns ... )
323
+ o := NewOverloadFunc (pos [ m . name ] , pkg , m .name , fns ... )
319
324
scope .Insert (o )
320
325
checkGoptsx (pkg , scope , m .name , o )
321
326
} else {
322
327
if debugImport {
323
328
log .Println ("==> NewOverloadMethod" , m .typ .Obj ().Name (), m .name )
324
329
}
325
- NewOverloadMethod (m .typ , token . NoPos , pkg , m .name , fns ... )
330
+ NewOverloadMethod (m .typ , pos [ m . typ . Obj (). Name () + "." + m . name ] , pkg , m .name , fns ... )
326
331
}
327
332
}
328
333
0 commit comments