diff --git a/ql/test/extractor-tests/go1.14/interfaces.expected b/ql/test/extractor-tests/go1.14/interfaces.expected new file mode 100644 index 00000000000..152a7672545 --- /dev/null +++ b/ql/test/extractor-tests/go1.14/interfaces.expected @@ -0,0 +1,17 @@ +| A | A | tst.go:4:2:4:2 | m | +| AA | AA | tst.go:4:2:4:2 | m | +| AB | AB | tst.go:4:2:4:2 | m | +| AB | AB | tst.go:9:2:9:2 | n | +| ABC | ABC | tst.go:4:2:4:2 | m | +| ABC | ABC | tst.go:9:2:9:2 | n | +| ABC | ABC | tst.go:14:2:14:2 | o | +| AC | AC | tst.go:4:2:4:2 | m | +| AC | AC | tst.go:13:2:13:2 | n | +| AC | AC | tst.go:14:2:14:2 | o | +| B | B | tst.go:8:2:8:2 | m | +| B | B | tst.go:9:2:9:2 | n | +| BC | BC | tst.go:8:2:8:2 | m | +| BC | BC | tst.go:9:2:9:2 | n | +| BC | BC | tst.go:14:2:14:2 | o | +| C | C | tst.go:13:2:13:2 | n | +| C | C | tst.go:14:2:14:2 | o | diff --git a/ql/test/extractor-tests/go1.14/interfaces.ql b/ql/test/extractor-tests/go1.14/interfaces.ql new file mode 100644 index 00000000000..323713bfb63 --- /dev/null +++ b/ql/test/extractor-tests/go1.14/interfaces.ql @@ -0,0 +1,5 @@ +import go + +from NamedType t +where t.getPackage().getName().matches("%main") +select t, t.getName(), t.getMethod(_) diff --git a/ql/test/extractor-tests/go1.14/tst.go b/ql/test/extractor-tests/go1.14/tst.go new file mode 100644 index 00000000000..d845a1ee2d7 --- /dev/null +++ b/ql/test/extractor-tests/go1.14/tst.go @@ -0,0 +1,44 @@ +package main + +type A interface { + m() +} + +type B interface { + m() + n() +} + +type C interface { + n() + o() +} + +type AA interface { + A + A +} + +type AB interface { + A + B +} + +type BC interface { + B + C +} + +type AC interface { + A + C +} + +type ABC interface { + A + B + C +} + +func main() { +} diff --git a/ql/test/library-tests/semmle/go/Scopes/DeclaredEntity.expected b/ql/test/library-tests/semmle/go/Scopes/DeclaredEntity.expected index a7c50861252..aa235d0b23f 100644 --- a/ql/test/library-tests/semmle/go/Scopes/DeclaredEntity.expected +++ b/ql/test/library-tests/semmle/go/Scopes/DeclaredEntity.expected @@ -13,10 +13,13 @@ | types.go:7:6:7:15 | twoMethods | types.go:7:6:7:15 | twoMethods | | types.go:8:2:8:6 | meth1 | types.go:8:2:8:6 | meth1 | | types.go:9:2:9:6 | meth2 | types.go:9:2:9:6 | meth2 | -| types.go:12:6:12:13 | starImpl | types.go:12:6:12:13 | starImpl | -| types.go:14:18:14:22 | meth1 | types.go:14:18:14:22 | meth1 | -| types.go:18:17:18:21 | meth2 | types.go:18:17:18:21 | meth2 | -| types.go:22:6:22:12 | notImpl | types.go:22:6:22:12 | notImpl | -| types.go:24:16:24:20 | meth1 | types.go:24:16:24:20 | meth1 | -| types.go:24:22:24:22 | a | types.go:24:22:24:22 | a | -| types.go:28:16:28:20 | meth2 | types.go:28:16:28:20 | meth2 | +| types.go:12:6:12:15 | meth1Iface | types.go:12:6:12:15 | meth1Iface | +| types.go:13:2:13:6 | meth1 | types.go:13:2:13:6 | meth1 | +| types.go:16:6:16:23 | twoMethodsEmbedded | types.go:16:6:16:23 | twoMethodsEmbedded | +| types.go:21:6:21:13 | starImpl | types.go:21:6:21:13 | starImpl | +| types.go:23:18:23:22 | meth1 | types.go:23:18:23:22 | meth1 | +| types.go:27:17:27:21 | meth2 | types.go:27:17:27:21 | meth2 | +| types.go:31:6:31:12 | notImpl | types.go:31:6:31:12 | notImpl | +| types.go:33:16:33:20 | meth1 | types.go:33:16:33:20 | meth1 | +| types.go:33:22:33:22 | a | types.go:33:22:33:22 | a | +| types.go:37:16:37:20 | meth2 | types.go:37:16:37:20 | meth2 | diff --git a/ql/test/library-tests/semmle/go/Scopes/EntityRead.expected b/ql/test/library-tests/semmle/go/Scopes/EntityRead.expected index 6cad25226b9..78578b97abb 100644 --- a/ql/test/library-tests/semmle/go/Scopes/EntityRead.expected +++ b/ql/test/library-tests/semmle/go/Scopes/EntityRead.expected @@ -1,5 +1,5 @@ | file://:0:0:0:0 | Println | main.go:10:2:10:12 | selection of Println | -| file://:0:0:0:0 | false | types.go:15:9:15:13 | false | +| file://:0:0:0:0 | false | types.go:24:9:24:13 | false | | main.go:6:2:6:2 | x | main.go:14:9:14:14 | selection of x | | main.go:6:2:6:2 | x | main.go:24:2:24:7 | selection of x | | main.go:13:7:13:10 | recv | main.go:14:9:14:12 | recv | @@ -10,4 +10,4 @@ | main.go:17:26:17:26 | y | main.go:20:12:20:12 | y | | main.go:23:7:23:10 | recv | main.go:24:2:24:5 | recv | | types.go:4:2:4:5 | meth | main.go:18:2:18:7 | selection of meth | -| types.go:24:22:24:22 | a | types.go:25:9:25:9 | a | +| types.go:33:22:33:22 | a | types.go:34:9:34:9 | a | diff --git a/ql/test/library-tests/semmle/go/Scopes/EntityReference.expected b/ql/test/library-tests/semmle/go/Scopes/EntityReference.expected index f93a4e30c01..97fa0236baf 100644 --- a/ql/test/library-tests/semmle/go/Scopes/EntityReference.expected +++ b/ql/test/library-tests/semmle/go/Scopes/EntityReference.expected @@ -1,17 +1,18 @@ | file://:0:0:0:0 | Println | | main.go:10:2:10:12 | selection of Println | | file://:0:0:0:0 | Println | | main.go:10:6:10:12 | Println | | file://:0:0:0:0 | bool | | types.go:8:10:8:13 | bool | -| file://:0:0:0:0 | bool | | types.go:14:26:14:29 | bool | -| file://:0:0:0:0 | bool | | types.go:24:29:24:32 | bool | -| file://:0:0:0:0 | false | | types.go:15:9:15:13 | false | +| file://:0:0:0:0 | bool | | types.go:13:10:13:13 | bool | +| file://:0:0:0:0 | bool | | types.go:23:26:23:29 | bool | +| file://:0:0:0:0 | bool | | types.go:33:29:33:32 | bool | +| file://:0:0:0:0 | false | | types.go:24:9:24:13 | false | | file://:0:0:0:0 | fmt | | main.go:10:2:10:4 | fmt | | file://:0:0:0:0 | int | | main.go:6:4:6:6 | int | | file://:0:0:0:0 | int | | main.go:13:23:13:25 | int | | file://:0:0:0:0 | int | | types.go:4:9:4:11 | int | | file://:0:0:0:0 | int | | types.go:9:10:9:12 | int | -| file://:0:0:0:0 | int | | types.go:18:25:18:27 | int | -| file://:0:0:0:0 | int | | types.go:24:24:24:26 | int | -| file://:0:0:0:0 | int | | types.go:28:24:28:26 | int | +| file://:0:0:0:0 | int | | types.go:27:25:27:27 | int | +| file://:0:0:0:0 | int | | types.go:33:24:33:26 | int | +| file://:0:0:0:0 | int | | types.go:37:24:37:26 | int | | main.go:5:6:5:6 | t | main.go@5:6:5:6 | main.go:5:6:5:6 | t | | main.go:5:6:5:6 | t | main.go@5:6:5:6 | main.go:13:13:13:13 | t | | main.go:5:6:5:6 | t | main.go@5:6:5:6 | main.go:17:29:17:29 | t | @@ -45,17 +46,22 @@ | types.go:4:2:4:5 | meth | types.go@4:2:4:5 | main.go:18:4:18:7 | meth | | types.go:4:2:4:5 | meth | types.go@4:2:4:5 | types.go:4:2:4:5 | meth | | types.go:7:6:7:15 | twoMethods | types.go@7:6:7:15 | types.go:7:6:7:15 | twoMethods | +| types.go:7:6:7:15 | twoMethods | types.go@7:6:7:15 | types.go:18:2:18:11 | twoMethods | | types.go:8:2:8:6 | meth1 | types.go@8:2:8:6 | types.go:8:2:8:6 | meth1 | | types.go:9:2:9:6 | meth2 | types.go@9:2:9:6 | types.go:9:2:9:6 | meth2 | -| types.go:12:6:12:13 | starImpl | types.go@12:6:12:13 | types.go:12:6:12:13 | starImpl | -| types.go:12:6:12:13 | starImpl | types.go@12:6:12:13 | types.go:14:8:14:15 | starImpl | -| types.go:12:6:12:13 | starImpl | types.go@12:6:12:13 | types.go:18:7:18:14 | starImpl | -| types.go:14:18:14:22 | meth1 | types.go@14:18:14:22 | types.go:14:18:14:22 | meth1 | -| types.go:18:17:18:21 | meth2 | types.go@18:17:18:21 | types.go:18:17:18:21 | meth2 | -| types.go:22:6:22:12 | notImpl | types.go@22:6:22:12 | types.go:22:6:22:12 | notImpl | -| types.go:22:6:22:12 | notImpl | types.go@22:6:22:12 | types.go:24:7:24:13 | notImpl | -| types.go:22:6:22:12 | notImpl | types.go@22:6:22:12 | types.go:28:7:28:13 | notImpl | -| types.go:24:16:24:20 | meth1 | types.go@24:16:24:20 | types.go:24:16:24:20 | meth1 | -| types.go:24:22:24:22 | a | types.go@24:22:24:22 | types.go:24:22:24:22 | a | -| types.go:24:22:24:22 | a | types.go@24:22:24:22 | types.go:25:9:25:9 | a | -| types.go:28:16:28:20 | meth2 | types.go@28:16:28:20 | types.go:28:16:28:20 | meth2 | +| types.go:12:6:12:15 | meth1Iface | types.go@12:6:12:15 | types.go:12:6:12:15 | meth1Iface | +| types.go:12:6:12:15 | meth1Iface | types.go@12:6:12:15 | types.go:17:2:17:11 | meth1Iface | +| types.go:13:2:13:6 | meth1 | types.go@13:2:13:6 | types.go:13:2:13:6 | meth1 | +| types.go:16:6:16:23 | twoMethodsEmbedded | types.go@16:6:16:23 | types.go:16:6:16:23 | twoMethodsEmbedded | +| types.go:21:6:21:13 | starImpl | types.go@21:6:21:13 | types.go:21:6:21:13 | starImpl | +| types.go:21:6:21:13 | starImpl | types.go@21:6:21:13 | types.go:23:8:23:15 | starImpl | +| types.go:21:6:21:13 | starImpl | types.go@21:6:21:13 | types.go:27:7:27:14 | starImpl | +| types.go:23:18:23:22 | meth1 | types.go@23:18:23:22 | types.go:23:18:23:22 | meth1 | +| types.go:27:17:27:21 | meth2 | types.go@27:17:27:21 | types.go:27:17:27:21 | meth2 | +| types.go:31:6:31:12 | notImpl | types.go@31:6:31:12 | types.go:31:6:31:12 | notImpl | +| types.go:31:6:31:12 | notImpl | types.go@31:6:31:12 | types.go:33:7:33:13 | notImpl | +| types.go:31:6:31:12 | notImpl | types.go@31:6:31:12 | types.go:37:7:37:13 | notImpl | +| types.go:33:16:33:20 | meth1 | types.go@33:16:33:20 | types.go:33:16:33:20 | meth1 | +| types.go:33:22:33:22 | a | types.go@33:22:33:22 | types.go:33:22:33:22 | a | +| types.go:33:22:33:22 | a | types.go@33:22:33:22 | types.go:34:9:34:9 | a | +| types.go:37:16:37:20 | meth2 | types.go@37:16:37:20 | types.go:37:16:37:20 | meth2 | diff --git a/ql/test/library-tests/semmle/go/Scopes/EntityType.expected b/ql/test/library-tests/semmle/go/Scopes/EntityType.expected index f03dbbedd99..8c7eac514b1 100644 --- a/ql/test/library-tests/semmle/go/Scopes/EntityType.expected +++ b/ql/test/library-tests/semmle/go/Scopes/EntityType.expected @@ -13,10 +13,13 @@ | types.go:7:6:7:15 | twoMethods | twoMethods | | types.go:8:2:8:6 | meth1 | func() bool | | types.go:9:2:9:6 | meth2 | func() int | -| types.go:12:6:12:13 | starImpl | starImpl | -| types.go:14:18:14:22 | meth1 | func() bool | -| types.go:18:17:18:21 | meth2 | func() int | -| types.go:22:6:22:12 | notImpl | notImpl | -| types.go:24:16:24:20 | meth1 | func(int) bool | -| types.go:24:22:24:22 | a | int | -| types.go:28:16:28:20 | meth2 | func() int | +| types.go:12:6:12:15 | meth1Iface | meth1Iface | +| types.go:13:2:13:6 | meth1 | func() bool | +| types.go:16:6:16:23 | twoMethodsEmbedded | twoMethodsEmbedded | +| types.go:21:6:21:13 | starImpl | starImpl | +| types.go:23:18:23:22 | meth1 | func() bool | +| types.go:27:17:27:21 | meth2 | func() int | +| types.go:31:6:31:12 | notImpl | notImpl | +| types.go:33:16:33:20 | meth1 | func(int) bool | +| types.go:33:22:33:22 | a | int | +| types.go:37:16:37:20 | meth2 | func() int | diff --git a/ql/test/library-tests/semmle/go/Scopes/EntityWrite.expected b/ql/test/library-tests/semmle/go/Scopes/EntityWrite.expected index 139414fcef9..843922048a0 100644 --- a/ql/test/library-tests/semmle/go/Scopes/EntityWrite.expected +++ b/ql/test/library-tests/semmle/go/Scopes/EntityWrite.expected @@ -3,4 +3,4 @@ | main.go:17:10:17:10 | x | main.go:17:10:17:10 | initialization of x | | main.go:17:26:17:26 | y | main.go:17:26:17:26 | initialization of y | | main.go:23:7:23:10 | recv | main.go:23:7:23:10 | initialization of recv | -| types.go:24:22:24:22 | a | types.go:24:22:24:22 | initialization of a | +| types.go:33:22:33:22 | a | types.go:33:22:33:22 | initialization of a | diff --git a/ql/test/library-tests/semmle/go/Scopes/MethodImplements.expected b/ql/test/library-tests/semmle/go/Scopes/MethodImplements.expected index 47e7198548e..b23488d0571 100644 --- a/ql/test/library-tests/semmle/go/Scopes/MethodImplements.expected +++ b/ql/test/library-tests/semmle/go/Scopes/MethodImplements.expected @@ -1,6 +1,10 @@ | iHaveAMethod | meth | iHaveAMethod | meth | +| meth1Iface | meth1 | meth1Iface | meth1 | +| meth1Iface | meth1 | twoMethods | meth1 | | pointer type | meth | iHaveAMethod | meth | +| pointer type | meth1 | meth1Iface | meth1 | | pointer type | meth1 | twoMethods | meth1 | | starImpl | meth2 | twoMethods | meth2 | +| twoMethods | meth1 | meth1Iface | meth1 | | twoMethods | meth1 | twoMethods | meth1 | | twoMethods | meth2 | twoMethods | meth2 | diff --git a/ql/test/library-tests/semmle/go/Scopes/MethodImplementsName.expected b/ql/test/library-tests/semmle/go/Scopes/MethodImplementsName.expected index 713b22eedb9..8ab6008b2ae 100644 --- a/ql/test/library-tests/semmle/go/Scopes/MethodImplementsName.expected +++ b/ql/test/library-tests/semmle/go/Scopes/MethodImplementsName.expected @@ -1,6 +1,10 @@ | iHaveAMethod | meth | github.com/github/codeql-go/ql/test/library-tests/semmle/go/Scopes | iHaveAMethod | meth | +| meth1Iface | meth1 | github.com/github/codeql-go/ql/test/library-tests/semmle/go/Scopes | meth1Iface | meth1 | +| meth1Iface | meth1 | github.com/github/codeql-go/ql/test/library-tests/semmle/go/Scopes | twoMethods | meth1 | | pointer type | meth | github.com/github/codeql-go/ql/test/library-tests/semmle/go/Scopes | iHaveAMethod | meth | +| pointer type | meth1 | github.com/github/codeql-go/ql/test/library-tests/semmle/go/Scopes | meth1Iface | meth1 | | pointer type | meth1 | github.com/github/codeql-go/ql/test/library-tests/semmle/go/Scopes | twoMethods | meth1 | | starImpl | meth2 | github.com/github/codeql-go/ql/test/library-tests/semmle/go/Scopes | twoMethods | meth2 | +| twoMethods | meth1 | github.com/github/codeql-go/ql/test/library-tests/semmle/go/Scopes | meth1Iface | meth1 | | twoMethods | meth1 | github.com/github/codeql-go/ql/test/library-tests/semmle/go/Scopes | twoMethods | meth1 | | twoMethods | meth2 | github.com/github/codeql-go/ql/test/library-tests/semmle/go/Scopes | twoMethods | meth2 | diff --git a/ql/test/library-tests/semmle/go/Scopes/Methods.expected b/ql/test/library-tests/semmle/go/Scopes/Methods.expected index 20d8d5e3234..68ab84c3f2e 100644 --- a/ql/test/library-tests/semmle/go/Scopes/Methods.expected +++ b/ql/test/library-tests/semmle/go/Scopes/Methods.expected @@ -3,7 +3,8 @@ | types.go:4:2:4:5 | meth | github.com/github/codeql-go/ql/test/library-tests/semmle/go/Scopes.iHaveAMethod.meth | file://:0:0:0:0 | | iHaveAMethod | | types.go:8:2:8:6 | meth1 | github.com/github/codeql-go/ql/test/library-tests/semmle/go/Scopes.twoMethods.meth1 | file://:0:0:0:0 | | twoMethods | | types.go:9:2:9:6 | meth2 | github.com/github/codeql-go/ql/test/library-tests/semmle/go/Scopes.twoMethods.meth2 | file://:0:0:0:0 | | twoMethods | -| types.go:14:18:14:22 | meth1 | github.com/github/codeql-go/ql/test/library-tests/semmle/go/Scopes.starImpl.meth1 | file://:0:0:0:0 | | * starImpl | -| types.go:18:17:18:21 | meth2 | github.com/github/codeql-go/ql/test/library-tests/semmle/go/Scopes.starImpl.meth2 | file://:0:0:0:0 | | starImpl | -| types.go:24:16:24:20 | meth1 | github.com/github/codeql-go/ql/test/library-tests/semmle/go/Scopes.notImpl.meth1 | file://:0:0:0:0 | | notImpl | -| types.go:28:16:28:20 | meth2 | github.com/github/codeql-go/ql/test/library-tests/semmle/go/Scopes.notImpl.meth2 | file://:0:0:0:0 | | notImpl | +| types.go:13:2:13:6 | meth1 | github.com/github/codeql-go/ql/test/library-tests/semmle/go/Scopes.meth1Iface.meth1 | file://:0:0:0:0 | | meth1Iface | +| types.go:23:18:23:22 | meth1 | github.com/github/codeql-go/ql/test/library-tests/semmle/go/Scopes.starImpl.meth1 | file://:0:0:0:0 | | * starImpl | +| types.go:27:17:27:21 | meth2 | github.com/github/codeql-go/ql/test/library-tests/semmle/go/Scopes.starImpl.meth2 | file://:0:0:0:0 | | starImpl | +| types.go:33:16:33:20 | meth1 | github.com/github/codeql-go/ql/test/library-tests/semmle/go/Scopes.notImpl.meth1 | file://:0:0:0:0 | | notImpl | +| types.go:37:16:37:20 | meth2 | github.com/github/codeql-go/ql/test/library-tests/semmle/go/Scopes.notImpl.meth2 | file://:0:0:0:0 | | notImpl | diff --git a/ql/test/library-tests/semmle/go/Scopes/TypeImplements.expected b/ql/test/library-tests/semmle/go/Scopes/TypeImplements.expected index 06a6e5eede7..d58feba2c03 100644 --- a/ql/test/library-tests/semmle/go/Scopes/TypeImplements.expected +++ b/ql/test/library-tests/semmle/go/Scopes/TypeImplements.expected @@ -1,6 +1,17 @@ +| * starImpl | meth1Iface | | * starImpl | twoMethods | +| * starImpl | twoMethodsEmbedded | | * t | iHaveAMethod | | iHaveAMethod | iHaveAMethod | +| interface { meth1 func() bool } | meth1Iface | +| interface { meth1 func() bool; meth2 func() int } | meth1Iface | | interface { meth1 func() bool; meth2 func() int } | twoMethods | +| interface { meth1 func() bool; meth2 func() int } | twoMethodsEmbedded | | interface { meth func() int } | iHaveAMethod | +| meth1Iface | meth1Iface | +| twoMethods | meth1Iface | | twoMethods | twoMethods | +| twoMethods | twoMethodsEmbedded | +| twoMethodsEmbedded | meth1Iface | +| twoMethodsEmbedded | twoMethods | +| twoMethodsEmbedded | twoMethodsEmbedded | diff --git a/ql/test/library-tests/semmle/go/Scopes/types.go b/ql/test/library-tests/semmle/go/Scopes/types.go index eab2b1838f7..5486d0faa74 100644 --- a/ql/test/library-tests/semmle/go/Scopes/types.go +++ b/ql/test/library-tests/semmle/go/Scopes/types.go @@ -9,6 +9,15 @@ type twoMethods interface { meth2() int } +type meth1Iface interface { + meth1() bool +} + +type twoMethodsEmbedded interface { + meth1Iface + twoMethods +} + type starImpl struct{} func (*starImpl) meth1() bool {