Skip to content
forked from goplus/xgo

Commit 4082321

Browse files
authored
Merge pull request goplus#2684 from xushiwei/overload
gogen v1.21.3: overload-conflict
2 parents 392de3b + c528e80 commit 4082321

File tree

8 files changed

+45
-4
lines changed

8 files changed

+45
-4
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import "github.com/goplus/xgo/cl/internal/overload/conflict"
2+
3+
var a, b conflict.Foo
4+
var c = a.Mul(b)
5+
var d = a.Mul(100)
6+
var e = conflict.Mul(a, b)
7+
var f = conflict.Mul(a, 100)
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package main
2+
3+
import "github.com/goplus/xgo/cl/internal/overload/conflict"
4+
5+
var a, b conflict.Foo
6+
var c = a.Mul(b)
7+
var d = a.MulInt(100)
8+
var e = conflict.Mul(a, b)
9+
var f = conflict.MulInt(a, 100)

cl/compile.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1243,7 +1243,6 @@ func preloadFile(p *gogen.Package, ctx *blockCtx, f *ast.File, goFile string, ge
12431243
exov := false
12441244
name := d.Name
12451245
LoopFunc:
1246-
12471246
for idx, fn := range d.Funcs {
12481247
switch expr := fn.(type) {
12491248
case *ast.Ident:
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package conflict
2+
3+
const XGoPackage = true
4+
5+
type Foo struct {
6+
}
7+
8+
const XGoo_Foo_Mul = ".Mul,.MulInt"
9+
10+
func (a Foo) MulInt(b int) Foo {
11+
return a
12+
}
13+
14+
func (a Foo) Mul(b Foo) Foo {
15+
return a
16+
}
17+
18+
const XGoo_Mul = "Mul,MulInt"
19+
20+
func Mul(a, b Foo) Foo {
21+
return a
22+
}
23+
24+
func MulInt(a Foo, b int) Foo {
25+
return a
26+
}

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ require (
88
github.com/fsnotify/fsnotify v1.9.0
99
github.com/goccy/go-yaml v1.19.2
1010
github.com/goplus/cobra v1.9.13 //xgo:class
11-
github.com/goplus/gogen v1.21.2
11+
github.com/goplus/gogen v1.21.3
1212
github.com/goplus/lib v0.3.1
1313
github.com/goplus/mod v0.20.0
1414
github.com/qiniu/x v1.16.5

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ github.com/goccy/go-yaml v1.19.2 h1:PmFC1S6h8ljIz6gMRBopkjP1TVT7xuwrButHID66PoM=
44
github.com/goccy/go-yaml v1.19.2/go.mod h1:XBurs7gK8ATbW4ZPGKgcbrY1Br56PdM69F7LkFRi1kA=
55
github.com/goplus/cobra v1.9.13 h1:onu/65rXILVMc7RBvdY1mGdOIZ/F4C/6o7DWgglwFaw=
66
github.com/goplus/cobra v1.9.13/go.mod h1:p4LhfNJDKEpiGjGiNn0crUXL5dUPA5DX2ztYpEJR34E=
7-
github.com/goplus/gogen v1.21.2 h1:xbXPgZOZiQx/WBM0nZxVSxFbtdCMZCRB+lguDnh8pfs=
8-
github.com/goplus/gogen v1.21.2/go.mod h1:Y7ulYW3wonQ3d9er00b0uGFEV/IUZa6okWJZh892ACQ=
7+
github.com/goplus/gogen v1.21.3 h1:0f6MWmAieymEVuhGPl5h9MSb4FmwbTsOpyVKPL54e3U=
8+
github.com/goplus/gogen v1.21.3/go.mod h1:Y7ulYW3wonQ3d9er00b0uGFEV/IUZa6okWJZh892ACQ=
99
github.com/goplus/lib v0.3.1 h1:Xws4DBVvgOMu58awqB972wtvTacDbk3nqcbHjdx9KSg=
1010
github.com/goplus/lib v0.3.1/go.mod h1:SgJv3oPqLLHCu0gcL46ejOP3x7/2ry2Jtxu7ta32kp0=
1111
github.com/goplus/mod v0.20.0 h1:vCONoomlfNLwfv5BDxqQTzaat3hHNaHLAovtkhJPwgw=

0 commit comments

Comments
 (0)