diff --git a/cl/compile.go b/cl/compile.go index cab47ce12..43894f725 100644 --- a/cl/compile.go +++ b/cl/compile.go @@ -340,6 +340,7 @@ type pkgCtx struct { *nodeInterp projs map[string]*gmxProject // .gmx => project classes map[*ast.File]*gmxClass + overpos map[string]token.Pos // overload => pos fset *token.FileSet cpkgs *cpackages.Importer syms map[string]loader @@ -493,6 +494,7 @@ func NewPackage(pkgPath string, pkg *ast.Package, conf *Config) (p *gogen.Packag nodeInterp: interp, projs: make(map[string]*gmxProject), classes: make(map[*ast.File]*gmxClass), + overpos: make(map[string]token.Pos), syms: make(map[string]loader), generics: make(map[string]bool), } @@ -663,7 +665,7 @@ func initGopPkg(ctx *pkgCtx, pkg *gogen.Package, gopSyms map[string]bool) { ctx.loadType(lbi.(*ast.Ident).Name) } } - gogen.InitThisGopPkg(pkg.Types) + gogen.InitThisGopPkgEx(pkg.Types, ctx.overpos) } func loadFile(ctx *pkgCtx, f *ast.File) { @@ -1153,6 +1155,11 @@ func preloadFile(p *gogen.Package, ctx *blockCtx, f *ast.File, goFile string, ge ctx.handleErrorf(name.NamePos, "%v", err) break } + if recv != nil { + ctx.overpos[recv.Name+"."+name.Name] = name.NamePos + } else { + ctx.overpos[name.Name] = name.NamePos + } oval := strings.Join(onames, ",") preloadConst(&ast.GenDecl{ Doc: d.Doc, diff --git a/go.mod b/go.mod index cfc589662..3aa2165fb 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.18 require ( github.com/fsnotify/fsnotify v1.7.0 github.com/goplus/c2go v0.7.26 - github.com/goplus/gogen v1.15.2 + github.com/goplus/gogen v1.15.3-0.20240424153048-0d40138c65a5 github.com/goplus/mod v0.13.10 github.com/qiniu/x v1.13.10 golang.org/x/tools v0.19.0 diff --git a/go.sum b/go.sum index d36cd4cc8..38b7648e9 100644 --- a/go.sum +++ b/go.sum @@ -6,8 +6,8 @@ github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyT github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/goplus/c2go v0.7.26 h1:YmihhrbUC6+5RmdRqYzul4igfsyofwj4mM2iwkTTOuc= github.com/goplus/c2go v0.7.26/go.mod h1:ePAStubV/ls8mmdPGQo6VfADTVd46rKuBemE4zzBDnA= -github.com/goplus/gogen v1.15.2 h1:Q6XaSx/Zi5tWnjfAziYsQI6Jv6MgODRpFtOYqNkiiqM= -github.com/goplus/gogen v1.15.2/go.mod h1:92qEzVgv7y8JEFICWG9GvYI5IzfEkxYdsA1DbmnTkqk= +github.com/goplus/gogen v1.15.3-0.20240424153048-0d40138c65a5 h1:OpVAkQH6VJaP4ooZgqeETcgW1Ac9wxLXej0Jl+PlxCs= +github.com/goplus/gogen v1.15.3-0.20240424153048-0d40138c65a5/go.mod h1:92qEzVgv7y8JEFICWG9GvYI5IzfEkxYdsA1DbmnTkqk= github.com/goplus/mod v0.13.10 h1:5Om6KOvo31daN7N30kWU1vC5zhsJPM+uPbcEN/FnlzE= github.com/goplus/mod v0.13.10/go.mod h1:HDuPZgpWiaTp3PUolFgsiX+Q77cbUWB/mikVHfYND3c= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=