@@ -2018,22 +2018,26 @@ Mul 100,200,300
2018
2018
008: 7: 9 | a *ast.Ident | var : float64 | variable
2019
2019
009: 7: 9 | a * b *ast.BinaryExpr | value : float64 | value
2020
2020
010: 7:13 | b *ast.Ident | var : float64 | variable
2021
- 011: 13:15 | int *ast.Ident | type : int | type
2022
- 012: 13:20 | int *ast.Ident | type : int | type
2023
- 013: 14:10 | x *ast.Ident | var : int | variable
2024
- 014: 14:10 | x * y *ast.BinaryExpr | value : int | value
2025
- 015: 14:10 | x * y * z *ast.BinaryExpr | value : int | value
2026
- 016: 14:14 | y *ast.Ident | var : int | variable
2027
- 017: 14:18 | z *ast.Ident | var : int | variable
2028
- 018: 18: 1 | Mul *ast.Ident | value : func(a int, b int) int | value
2029
- 019: 18: 1 | Mul 100, 200 *ast.CallExpr | value : int | value
2030
- 020: 18: 5 | 100 *ast.BasicLit | value : untyped int = 100 | constant
2031
- 021: 18: 9 | 200 *ast.BasicLit | value : untyped int = 200 | constant
2032
- 022: 19: 1 | Mul *ast.Ident | value : func(x int, y int, z int) int | value
2033
- 023: 19: 1 | Mul 100, 200, 300 *ast.CallExpr | value : int | value
2034
- 024: 19: 5 | 100 *ast.BasicLit | value : untyped int = 100 | constant
2035
- 025: 19: 9 | 200 *ast.BasicLit | value : untyped int = 200 | constant
2036
- 026: 19:13 | 300 *ast.BasicLit | value : untyped int = 300 | constant
2021
+ 011: 13: 2 | func(x, y, z int) int *ast.FuncType | type : func(x int, y int, z int) int | type
2022
+ 012: 13: 2 | func(x, y, z int) int {
2023
+ return x * y * z
2024
+ } *ast.FuncLit | value : func(x int, y int, z int) int | value
2025
+ 013: 13:15 | int *ast.Ident | type : int | type
2026
+ 014: 13:20 | int *ast.Ident | type : int | type
2027
+ 015: 14:10 | x *ast.Ident | var : int | variable
2028
+ 016: 14:10 | x * y *ast.BinaryExpr | value : int | value
2029
+ 017: 14:10 | x * y * z *ast.BinaryExpr | value : int | value
2030
+ 018: 14:14 | y *ast.Ident | var : int | variable
2031
+ 019: 14:18 | z *ast.Ident | var : int | variable
2032
+ 020: 18: 1 | Mul *ast.Ident | value : func(a int, b int) int | value
2033
+ 021: 18: 1 | Mul 100, 200 *ast.CallExpr | value : int | value
2034
+ 022: 18: 5 | 100 *ast.BasicLit | value : untyped int = 100 | constant
2035
+ 023: 18: 9 | 200 *ast.BasicLit | value : untyped int = 200 | constant
2036
+ 024: 19: 1 | Mul *ast.Ident | value : func(x int, y int, z int) int | value
2037
+ 025: 19: 1 | Mul 100, 200, 300 *ast.CallExpr | value : int | value
2038
+ 026: 19: 5 | 100 *ast.BasicLit | value : untyped int = 100 | constant
2039
+ 027: 19: 9 | 200 *ast.BasicLit | value : untyped int = 200 | constant
2040
+ 028: 19:13 | 300 *ast.BasicLit | value : untyped int = 300 | constant
2037
2041
== defs ==
2038
2042
000: 0: 0 | Gopo_Mul | const main.Gopo_Mul untyped string
2039
2043
001: 2: 6 | MulInt | func main.MulInt(a int, b int) int
@@ -2042,11 +2046,12 @@ Mul 100,200,300
2042
2046
004: 6: 6 | MulFloat | func main.MulFloat(a float64, b float64) float64
2043
2047
005: 6:15 | a | var a float64
2044
2048
006: 6:18 | b | var b float64
2045
- 007: 13: 2 | Mul__2 | func main.Mul__2(x int, y int, z int) int
2046
- 008: 13: 7 | x | var x int
2047
- 009: 13:10 | y | var y int
2048
- 010: 13:13 | z | var z int
2049
- 011: 18: 1 | main | func main.main()
2049
+ 007: 10: 6 | Mul | func main.Mul(__gop_overload_args__ interface{_()})
2050
+ 008: 13: 2 | Mul__2 | func main.Mul__2(x int, y int, z int) int
2051
+ 009: 13: 7 | x | var x int
2052
+ 010: 13:10 | y | var y int
2053
+ 011: 13:13 | z | var z int
2054
+ 012: 18: 1 | main | func main.main()
2050
2055
== uses ==
2051
2056
000: 2:18 | int | type int
2052
2057
001: 2:23 | int | type int
@@ -2120,10 +2125,11 @@ var d = a.mul(c)
2120
2125
005: 9: 7 | a | var a *main.foo
2121
2126
006: 9:15 | mulFoo | func (*main.foo).mulFoo(b *main.foo) *main.foo
2122
2127
007: 9:22 | b | var b *main.foo
2123
- 008: 18: 5 | a | var main.a *main.foo
2124
- 009: 18: 8 | b | var main.b *main.foo
2125
- 010: 19: 5 | c | var main.c *main.foo
2126
- 011: 20: 5 | d | var main.d *main.foo
2128
+ 008: 13:12 | mul | func (main.foo).mul(__gop_overload_args__ interface{_()})
2129
+ 009: 18: 5 | a | var main.a *main.foo
2130
+ 010: 18: 8 | b | var main.b *main.foo
2131
+ 011: 19: 5 | c | var main.c *main.foo
2132
+ 012: 20: 5 | d | var main.d *main.foo
2127
2133
== uses ==
2128
2134
000: 5:10 | foo | type main.foo struct{}
2129
2135
001: 5:24 | int | type int
@@ -2145,3 +2151,96 @@ var d = a.mul(c)
2145
2151
017: 20:11 | mul | func (*main.foo).mulFoo(b *main.foo) *main.foo
2146
2152
018: 20:15 | c | var main.c *main.foo` )
2147
2153
}
2154
+
2155
+ func TestGopOverloadDecl (t * testing.T ) {
2156
+ testGopInfo (t , `
2157
+ func addInt0() {
2158
+ }
2159
+
2160
+ func addInt1(i int) {
2161
+ }
2162
+
2163
+ func addInt2(i, j int) {
2164
+ }
2165
+
2166
+ var addInt3 = func(i, j, k int) {
2167
+ }
2168
+
2169
+ func add = (
2170
+ addInt0
2171
+ addInt1
2172
+ addInt2
2173
+ addInt3
2174
+ func(a, b string) string {
2175
+ return a + b
2176
+ }
2177
+ )
2178
+
2179
+ func init() {
2180
+ add 100, 200
2181
+ add 100, 200, 300
2182
+ add("hello", "world")
2183
+ }
2184
+ ` , `` , `== types ==
2185
+ 000: 0: 0 | "addInt0,addInt1,addInt2,addInt3," *ast.BasicLit | value : untyped string = "addInt0,addInt1,addInt2,addInt3," | constant
2186
+ 001: 5:16 | int *ast.Ident | type : int | type
2187
+ 002: 8:19 | int *ast.Ident | type : int | type
2188
+ 003: 11:15 | func(i, j, k int) *ast.FuncType | type : func(i int, j int, k int) | type
2189
+ 004: 11:15 | func(i, j, k int) {
2190
+ } *ast.FuncLit | value : func(i int, j int, k int) | value
2191
+ 005: 11:28 | int *ast.Ident | type : int | type
2192
+ 006: 19: 2 | func(a, b string) string *ast.FuncType | type : func(a string, b string) string | type
2193
+ 007: 19: 2 | func(a, b string) string {
2194
+ return a + b
2195
+ } *ast.FuncLit | value : func(a string, b string) string | value
2196
+ 008: 19:12 | string *ast.Ident | type : string | type
2197
+ 009: 19:20 | string *ast.Ident | type : string | type
2198
+ 010: 20:10 | a *ast.Ident | var : string | variable
2199
+ 011: 20:10 | a + b *ast.BinaryExpr | value : string | value
2200
+ 012: 20:14 | b *ast.Ident | var : string | variable
2201
+ 013: 25: 2 | add *ast.Ident | value : func(i int, j int) | value
2202
+ 014: 25: 2 | add 100, 200 *ast.CallExpr | void : () | no value
2203
+ 015: 25: 6 | 100 *ast.BasicLit | value : untyped int = 100 | constant
2204
+ 016: 25:11 | 200 *ast.BasicLit | value : untyped int = 200 | constant
2205
+ 017: 26: 2 | add *ast.Ident | var : func(i int, j int, k int) | variable
2206
+ 018: 26: 2 | add 100, 200, 300 *ast.CallExpr | void : () | no value
2207
+ 019: 26: 6 | 100 *ast.BasicLit | value : untyped int = 100 | constant
2208
+ 020: 26:11 | 200 *ast.BasicLit | value : untyped int = 200 | constant
2209
+ 021: 26:16 | 300 *ast.BasicLit | value : untyped int = 300 | constant
2210
+ 022: 27: 2 | add *ast.Ident | value : func(a string, b string) string | value
2211
+ 023: 27: 2 | add("hello", "world") *ast.CallExpr | value : string | value
2212
+ 024: 27: 6 | "hello" *ast.BasicLit | value : untyped string = "hello" | constant
2213
+ 025: 27:15 | "world" *ast.BasicLit | value : untyped string = "world" | constant
2214
+ == defs ==
2215
+ 000: 0: 0 | Gopo_add | const main.Gopo_add untyped string
2216
+ 001: 2: 6 | addInt0 | func main.addInt0()
2217
+ 002: 5: 6 | addInt1 | func main.addInt1(i int)
2218
+ 003: 5:14 | i | var i int
2219
+ 004: 8: 6 | addInt2 | func main.addInt2(i int, j int)
2220
+ 005: 8:14 | i | var i int
2221
+ 006: 8:17 | j | var j int
2222
+ 007: 11: 5 | addInt3 | var main.addInt3 func(i int, j int, k int)
2223
+ 008: 11:20 | i | var i int
2224
+ 009: 11:23 | j | var j int
2225
+ 010: 11:26 | k | var k int
2226
+ 011: 14: 6 | add | func main.add(__gop_overload_args__ interface{_()})
2227
+ 012: 19: 2 | add__4 | func main.add__4(a string, b string) string
2228
+ 013: 19: 7 | a | var a string
2229
+ 014: 19:10 | b | var b string
2230
+ 015: 24: 6 | init | func main.init()
2231
+ == uses ==
2232
+ 000: 5:16 | int | type int
2233
+ 001: 8:19 | int | type int
2234
+ 002: 11:28 | int | type int
2235
+ 003: 15: 2 | addInt0 | func main.addInt0()
2236
+ 004: 16: 2 | addInt1 | func main.addInt1(i int)
2237
+ 005: 17: 2 | addInt2 | func main.addInt2(i int, j int)
2238
+ 006: 18: 2 | addInt3 | var main.addInt3 func(i int, j int, k int)
2239
+ 007: 19:12 | string | type string
2240
+ 008: 19:20 | string | type string
2241
+ 009: 20:10 | a | var a string
2242
+ 010: 20:14 | b | var b string
2243
+ 011: 25: 2 | add | func main.addInt2(i int, j int)
2244
+ 012: 26: 2 | add | var main.addInt3 func(i int, j int, k int)
2245
+ 013: 27: 2 | add | func main.add__4(a string, b string) string` )
2246
+ }
0 commit comments