Repository: goplus/gop
Pull request #1791 (2024-03-07 01:58:37)

deps: update gox because fix  issue-1761
https://github.com/goplus/gop/issues/1761


Patch:
diff --git a/go.mod b/go.mod
index f3d49974..054d75ed 100644
--- a/go.mod
+++ b/go.mod
@@ -5,18 +5,18 @@ go 1.18
 require (
 	github.com/fsnotify/fsnotify v1.7.0
 	github.com/goplus/c2go v0.7.24-0.20240221044754-e542e30f9dbc
-	github.com/goplus/gox v1.14.13-0.20240221143457-e20cebf7f229
+	github.com/goplus/gox v1.14.13-0.20240305210108-429f12385afa
 	github.com/goplus/mod v0.13.8
 	github.com/qiniu/x v1.13.9
-	golang.org/x/tools v0.18.0
+	golang.org/x/tools v0.19.0
 )
 
 require (
 	github.com/json-iterator/go v1.1.12 // indirect
 	github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 // indirect
 	github.com/modern-go/reflect2 v1.0.2 // indirect
-	golang.org/x/mod v0.15.0 // indirect
-	golang.org/x/sys v0.17.0 // indirect
+	golang.org/x/mod v0.16.0 // indirect
+	golang.org/x/sys v0.18.0 // indirect
 )
 
 retract v1.1.12
diff --git a/go.sum b/go.sum
index 5b22eacf..99d1b66a 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.24-0.20240221044754-e542e30f9dbc h1:HGH6KoedGQ+DikZ1n9cDkCpMjODHftxbPqEhb7zDz4I=
 github.com/goplus/c2go v0.7.24-0.20240221044754-e542e30f9dbc/go.mod h1:m+2bOIErSOA4sxyrg0deb7RS6cnC3czzo7AaL9IZ+YE=
-github.com/goplus/gox v1.14.13-0.20240221143457-e20cebf7f229 h1:zKgGmIvM7dvMEMF4Q5K51vo3aPqRf5GjPzlYMZhp7bk=
-github.com/goplus/gox v1.14.13-0.20240221143457-e20cebf7f229/go.mod h1:6b6XYHmyiCevhwuEHcV/jzm7Z2FXLDBhuxgvkjceA+o=
+github.com/goplus/gox v1.14.13-0.20240305210108-429f12385afa h1:YPCZaGJVDDY5nKErDQZcSekvKFC0104/mJPkEHvjkFA=
+github.com/goplus/gox v1.14.13-0.20240305210108-429f12385afa/go.mod h1:Q1x9L9gugS3964fLAsgJWGBw+/5tZFrGgD7Klk8zdJc=
 github.com/goplus/mod v0.13.8 h1:5PbALN7GjvpQidAx2qiE3x/Bgf+ZHPrVZ3C63dfjGrA=
 github.com/goplus/mod v0.13.8/go.mod h1:7/8zsNzGWyB4Qojg+D7SxSgMzpcsDbZsbKo2SHy4Lwk=
 github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
@@ -30,8 +30,9 @@ golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliY
 golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
 golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
 golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
-golang.org/x/mod v0.15.0 h1:SernR4v+D55NyBH2QiEQrlBAnj1ECL6AGrA5+dPaMY8=
 golang.org/x/mod v0.15.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
+golang.org/x/mod v0.16.0 h1:QX4fJ0Rr5cPQCF7O9lh9Se4pmwfwskqZfq5moyldzic=
+golang.org/x/mod v0.16.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
 golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
 golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
 golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
@@ -51,8 +52,8 @@ golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBc
 golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
-golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y=
-golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
+golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4=
+golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
 golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
 golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
 golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
@@ -69,6 +70,6 @@ golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtn
 golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
 golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
 golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58=
-golang.org/x/tools v0.18.0 h1:k8NLag8AGHnn+PHbl7g43CtqZAwG60vZkLqgyZgIHgQ=
-golang.org/x/tools v0.18.0/go.mod h1:GL7B4CwcLLeo59yx/9UWWuNOW1n3VZ4f5axWfML7Lcg=
+golang.org/x/tools v0.19.0 h1:tfGCXNR1OsFG+sVdLAitlpjAvD/I6dHDKnYrpEZUHkw=
+golang.org/x/tools v0.19.0/go.mod h1:qoJWxmGSIBmAeriMx19ogtrEPrGtDbPK634QFIcLAhc=
 golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
diff --git a/x/typesutil/check.go b/x/typesutil/check.go
index 6ee70a17..737b7f82 100644
--- a/x/typesutil/check.go
+++ b/x/typesutil/check.go
@@ -82,9 +82,6 @@ type Config struct {
 
 	// If IgnoreFuncBodies is set, skip compiling function bodies (optional).
 	IgnoreFuncBodies bool
-
-	// If UpdateGoTypesOverload is set, update go types overload data (optional).
-	UpdateGoTypesOverload bool
 }
 
 // A Checker maintains the state of the type checker.
@@ -178,16 +175,13 @@ func (p *Checker) Files(goFiles []*goast.File, gopFiles []*ast.File) (err error)
 		}
 		// don't return even if err != nil
 	}
-	if len(files) > 0 {
+	if len(files) > 0 && p.goInfo != nil {
 		scope := pkgTypes.Scope()
 		objMap := DeleteObjects(scope, files)
 		checker := types.NewChecker(conf, fset, pkgTypes, p.goInfo)
 		err = checker.Files(files)
 		// TODO: how to process error?
 		CorrectTypesInfo(scope, objMap, p.gopInfo.Uses)
-		if opts.UpdateGoTypesOverload {
-			gox.InitThisGopPkg(pkgTypes)
-		}
 	}
 	return
 }


Test patch:
diff --git a/cl/compile_gop_test.go b/cl/compile_gop_test.go
index 0111303a..e80d076a 100644
--- a/cl/compile_gop_test.go
+++ b/cl/compile_gop_test.go
@@ -964,13 +964,11 @@ d := Var(M)
 const GopPackage = true
 
 var a Var__0[int]
-var b Var__1[map[string]interface {
-}]
+var b Var__1[map[string]interface{}]
 
 func main() {
 	c := Gopx_Var_Cast__0[string]()
-	d := Gopx_Var_Cast__1[map[string]interface {
-	}]()
+	d := Gopx_Var_Cast__1[map[string]interface{}]()
 }
 `)
 }
diff --git a/cl/compile_test.go b/cl/compile_test.go
index 5fc9b105..7a1f7bdb 100644
--- a/cl/compile_test.go
+++ b/cl/compile_test.go
@@ -642,8 +642,7 @@ case interface{}(true):
 
 func main() {
 	switch {
-	case interface {
-	}(true):
+	case interface{}(true):
 	}
 }
 `)
@@ -1086,11 +1085,9 @@ func foo(v interface{}) {
 }
 `, `package main
 
-func bar(p *interface {
-}) {
+func bar(p *interface{}) {
 }
-func foo(v interface {
-}) {
+func foo(v interface{}) {
 	switch t := v.(type) {
 	case int, string:
 		bar(&v)
@@ -1117,11 +1114,9 @@ func foo(v interface{}) {
 }
 `, `package main
 
-func bar(p *interface {
-}) {
+func bar(p *interface{}) {
 }
-func foo(v interface {
-}) {
+func foo(v interface{}) {
 	switch bar(nil); v.(type) {
 	case int, string:
 		bar(&v)
@@ -1139,8 +1134,7 @@ func foo(v interface{}) {
 }
 `, `package main
 
-func foo(v interface {
-}) {
+func foo(v interface{}) {
 	x := v.(int)
 	y, ok := v.(string)
 }
@@ -1655,8 +1649,7 @@ var y *uint32 = (*uint32)(nil)
 
 var a = (*struct {
 })(nil)
-var b = interface {
-}(nil)
+var b = interface{}(nil)
 var c = (func())(nil)
 var x uint32 = uint32(0)
 var y *uint32 = (*uint32)(nil)
@@ -1936,8 +1929,7 @@ z := []
 func main() {
 	x := []float64{1, 3.4, 5}
 	y := []int{1}
-	z := []interface {
-	}{}
+	z := []interface{}{}
 }
 `)
 	gopClTest(t, `
@@ -3039,8 +3031,7 @@ func main() {
 
 import "fmt"
 
-func foo(format string, args ...interface {
-}) (int, error) {
+func foo(format string, args ...interface{}) (int, error) {
 	return fmt.Printf(format, args...)
 }
 func main() {
@@ -3058,8 +3049,7 @@ func main() {
 }
 `, `package main
 
-func foo(format string, args ...interface {
-}) (int, error) {
+func foo(format string, args ...interface{}) (int, error) {
 	return 0, nil
 }
 func main() {
@@ -3092,8 +3082,7 @@ func TestFunc(t *testing.T) {
 func main() {
 }`, `package main
 
-func foo(format string, a [10]int, args ...interface {
-}) {
+func foo(format string, a [10]int, args ...interface{}) {
 }
 func main() {
 }
@@ -3387,8 +3376,7 @@ bar(fmt.Printf)
 
 import "fmt"
 
-func bar(foo func(string, ...interface {
-}) (int, error)) {
+func bar(foo func(string, ...interface{}) (int, error)) {
 	foo("Hello, %v!\n", "Go+")
 }
 func main() {
@@ -3429,13 +3417,11 @@ import (
 func foo(x string) string {
 	return strings.NewReplacer("?", "!").Replace(x)
 }
-func printf(format string, args ...interface {
-}) (n int, err error) {
+func printf(format string, args ...interface{}) (n int, err error) {
 	n, err = fmt.Printf(format, args...)
 	return
 }
-func bar(foo func(string, ...interface {
-}) (int, error)) {
+func bar(foo func(string, ...interface{}) (int, error)) {
 	foo("Hello, %v!\n", "Go+")
 }
 func main() {
@@ -3471,8 +3457,7 @@ func main() {
 
 import "fmt"
 
-func foo(args ...interface {
-}) {
+func foo(args ...interface{}) {
 	fmt.Println(args...)
 }
 func main() {
@@ -3497,8 +3482,7 @@ import "fmt"
 func main() {
 	foo("Hello", 123)
 }
-func foo(args ...interface {
-}) {
+func foo(args ...interface{}) {
 	fmt.Println(args...)
 }
 `)
@@ -3959,10 +3943,8 @@ println {}
 import "fmt"
 
 func main() {
-	fmt.Println([]interface {
-	}{})
-	fmt.Println(map[string]interface {
-	}{})
+	fmt.Println([]interface{}{})
+	fmt.Println(map[string]interface{}{})
 }
 `)
 }
@@ -4024,8 +4006,7 @@ println(a)
 
 import "fmt"
 
-var a interface {
-} = 100
+var a interface{} = 100
 
 func main() {
 	fmt.Println(a)
diff --git a/x/typesutil/info_test.go b/x/typesutil/info_test.go
index 42b76216..86faca94 100644
--- a/x/typesutil/info_test.go
+++ b/x/typesutil/info_test.go
@@ -21,7 +21,6 @@ import (
 	"github.com/goplus/gop/parser"
 	"github.com/goplus/gop/token"
 	"github.com/goplus/gop/x/typesutil"
-	"github.com/goplus/gox"
 	"github.com/goplus/mod/env"
 	"github.com/goplus/mod/gopmod"
 	"github.com/goplus/mod/modfile"
@@ -62,16 +61,16 @@ func spxParserConf() parser.Config {
 	}
 }
 
-func parseMixedSource(mod *gopmod.Module, fset *token.FileSet, name, src string, goname string, gosrc string, parserConf parser.Config, updateGoTypesOverload bool) (*types.Package, *typesutil.Info, *types.Info, error) {
+func parseMixedSource(mod *gopmod.Module, fset *token.FileSet, name, src string, goname string, gosrc string, parserConf parser.Config) (*typesutil.Info, *types.Info, error) {
 	f, err := parser.ParseEntry(fset, name, src, parserConf)
 	if err != nil {
-		return nil, nil, nil, err
+		return nil, nil, err
 	}
 	var gofiles []*goast.File
 	if len(gosrc) > 0 {
 		f, err := goparser.ParseFile(fset, goname, gosrc, goparser.ParseComments)
 		if err != nil {
-			return nil, nil, nil, err
+			return nil, nil, err
 		}
 		gofiles = append(gofiles, f)
 	}
@@ -79,10 +78,9 @@ func parseMixedSource(mod *gopmod.Module, fset *token.FileSet, name, src string,
 	conf := &types.Config{}
 	conf.Importer = gop.NewImporter(nil, &env.Gop{Root: "../..", Version: "1.0"}, fset)
 	chkOpts := &typesutil.Config{
-		Types:                 types.NewPackage("main", f.Name.Name),
-		Fset:                  fset,
-		Mod:                   mod,
-		UpdateGoTypesOverload: updateGoTypesOverload,
+		Types: types.NewPackage("main", f.Name.Name),
+		Fset:  fset,
+		Mod:   mod,
 	}
 	info := &typesutil.Info{
 		Types:      make(map[ast.Expr]types.TypeAndValue),
@@ -103,7 +101,7 @@ func parseMixedSource(mod *gopmod.Module, fset *token.FileSet, name, src string,
 	}
 	check := typesutil.NewChecker(conf, chkOpts, ginfo, info)
 	err = check.Files(gofiles, []*ast.File{f})
-	return chkOpts.Types, info, ginfo, err
+	return info, ginfo, err
 }
 
 func parseSource(fset *token.FileSet, filename string, src interface{}, mode parser.Mode) (*types.Package, *typesutil.Info, error) {
@@ -168,7 +166,7 @@ func testSpxInfo(t *testing.T, name string, src string, expect string) {
 
 func testGopInfoEx(t *testing.T, mod *gopmod.Module, name string, src string, goname string, gosrc string, expect string, parseConf parser.Config) {
 	fset := token.NewFileSet()
-	_, info, _, err := parseMixedSource(mod, fset, name, src, goname, gosrc, parseConf, false)
+	info, _, err := parseMixedSource(mod, fset, name, src, goname, gosrc, parseConf)
 	if err != nil {
 		t.Fatal("parserMixedSource error", err)
 	}
@@ -1881,103 +1879,3 @@ func _() {
 }
 `)
 }
-
-func TestAddress2(t *testing.T) {
-	testInfo(t, `package load
-import "os"
-
-func _() { _ = os.Stdout }
-func _() {
-	var a int
-	_ = a
-}
-func _() {
-	var p *int
-	_ = *p
-}
-func _() {
-	var s []int
-	_ = s[0]
-}
-func _() {
-	var s struct{f int}
-	_ = s.f
-}
-func _() {
-	var a [10]int
-	_ = a[0]
-}
-func _(x int) {
-	_ = x
-}
-func _()(x int) {
-	_ = x
-	return
-}
-type T int
-func (x T) _() {
-	_ = x
-}
-
-func _() {
-	var a, b int
-	_ = a + b
-}
-func _() {
-	_ = &[]int{1}
-}
-func _() {
-	_ = func(){}
-}
-func f() { _ = f }
-func _() {
-	var m map[int]int
-	_ = m[0]
-	_, _ = m[0]
-}
-func _() {
-	var ch chan int
-	_ = <-ch
-	_, _ = <-ch
-}
-`)
-}
-
-func TestMixedPackage(t *testing.T) {
-	fset := token.NewFileSet()
-	pkg, _, _, err := parseMixedSource(gopmod.Default, fset, "main.gop", `
-Test
-Test 100
-var n N
-n.test
-n.test 100
-`, "main.go", `
-package main
-
-func Test__0() {
-}
-func Test__1(n int) {
-}
-type N struct {
-}
-func (p *N) Test__0() {
-}
-func (p *N) Test__1(n int) {
-}`, parser.Config{}, true)
-	if err != nil {
-		t.Fatal(err)
-	}
-	obj := pkg.Scope().Lookup("N")
-	named := obj.Type().(*types.Named)
-	if named.NumMethods() == 2 {
-		t.Fatal("found overload method failed")
-	}
-	ext, ok := gox.CheckFuncEx(named.Method(2).Type().(*types.Signature))
-	if !ok {
-		t.Fatal("checkFuncEx failed")
-	}
-	m, ok := ext.(*gox.TyOverloadMethod)
-	if !ok || len(m.Methods) != 2 {
-		t.Fatal("check TyOverloadMethod failed")
-	}
-}