diff --git a/go/ql/lib/semmle/go/AST.qll b/go/ql/lib/semmle/go/AST.qll index 64c6231d1054..c5e388ba000f 100644 --- a/go/ql/lib/semmle/go/AST.qll +++ b/go/ql/lib/semmle/go/AST.qll @@ -55,6 +55,8 @@ class AstNode extends @node, Locatable { kind = "commentgroup" and result = this.(File).getCommentGroup(i) or kind = "comment" and result = this.(CommentGroup).getComment(i) + or + kind = "typeparamdecl" and result = this.(TypeParamDeclParent).getTypeParameterDecl(i) } /** diff --git a/go/ql/test/library-tests/semmle/go/PrintAst/PrintAst.expected b/go/ql/test/library-tests/semmle/go/PrintAst/PrintAst.expected index 0c71ba870e4a..66aa26430633 100644 --- a/go/ql/test/library-tests/semmle/go/PrintAst/PrintAst.expected +++ b/go/ql/test/library-tests/semmle/go/PrintAst/PrintAst.expected @@ -1,16 +1,3 @@ -other.go: -# 8| [TypeParamDecl] type parameter declaration -# 8| 0: [Ident, TypeName] int -# 8| Type = int -# 8| 1: [Ident, TypeName] U -# 8| Type = U -# 17| [TypeParamDecl] type parameter declaration -# 17| 0: [TypeSetLiteralExpr] type set literal -# 17| Type = ~string -# 17| 0: [Ident, TypeName] string -# 17| Type = string -# 17| 1: [Ident, TypeName] T -# 17| Type = T go.mod: # 0| [GoModFile] go.mod # 1| 0: [GoModModuleLine] go.mod module line @@ -652,6 +639,11 @@ other.go: # 11| Type = int # 11| 0: [Ident, VariableName] myNested # 11| Type = func() int +# 8| 3: [TypeParamDecl] type parameter declaration +# 8| 0: [Ident, TypeName] int +# 8| Type = int +# 8| 1: [Ident, TypeName] U +# 8| Type = U # 15| 5: [VarDecl] variable declaration # 15| 0: [ValueSpec] value declaration specifier # 15| 0: [Ident, VariableName] x @@ -669,6 +661,13 @@ other.go: # 17| Type = []T # 17| 0: [Ident, TypeName] T # 17| Type = T +# 17| 2: [TypeParamDecl] type parameter declaration +# 17| 0: [TypeSetLiteralExpr] type set literal +# 17| Type = ~string +# 17| 0: [Ident, TypeName] string +# 17| Type = string +# 17| 1: [Ident, TypeName] T +# 17| Type = T # 19| 7: [MethodDecl] function declaration # 19| 0: [FunctionName, Ident] f # 19| Type = func() diff --git a/go/ql/test/library-tests/semmle/go/PrintAst/PrintAstExcludeComments.expected b/go/ql/test/library-tests/semmle/go/PrintAst/PrintAstExcludeComments.expected index 1592cc4ca751..099aa4e6144f 100644 --- a/go/ql/test/library-tests/semmle/go/PrintAst/PrintAstExcludeComments.expected +++ b/go/ql/test/library-tests/semmle/go/PrintAst/PrintAstExcludeComments.expected @@ -1,16 +1,3 @@ -other.go: -# 8| [TypeParamDecl] type parameter declaration -# 8| 0: [Ident, TypeName] int -# 8| Type = int -# 8| 1: [Ident, TypeName] U -# 8| Type = U -# 17| [TypeParamDecl] type parameter declaration -# 17| 0: [TypeSetLiteralExpr] type set literal -# 17| Type = ~string -# 17| 0: [Ident, TypeName] string -# 17| Type = string -# 17| 1: [Ident, TypeName] T -# 17| Type = T go.mod: # 0| [GoModFile] go.mod # 1| 0: [GoModModuleLine] go.mod module line @@ -632,6 +619,11 @@ other.go: # 11| Type = int # 11| 0: [Ident, VariableName] myNested # 11| Type = func() int +# 8| 3: [TypeParamDecl] type parameter declaration +# 8| 0: [Ident, TypeName] int +# 8| Type = int +# 8| 1: [Ident, TypeName] U +# 8| Type = U # 15| 5: [VarDecl] variable declaration # 15| 0: [ValueSpec] value declaration specifier # 15| 0: [Ident, VariableName] x @@ -649,6 +641,13 @@ other.go: # 17| Type = []T # 17| 0: [Ident, TypeName] T # 17| Type = T +# 17| 2: [TypeParamDecl] type parameter declaration +# 17| 0: [TypeSetLiteralExpr] type set literal +# 17| Type = ~string +# 17| 0: [Ident, TypeName] string +# 17| Type = string +# 17| 1: [Ident, TypeName] T +# 17| Type = T # 19| 7: [MethodDecl] function declaration # 19| 0: [FunctionName, Ident] f # 19| Type = func() diff --git a/go/ql/test/library-tests/semmle/go/PrintAst/PrintAstNestedFunction.expected b/go/ql/test/library-tests/semmle/go/PrintAst/PrintAstNestedFunction.expected index 36f054fbe1aa..9be02352b2b7 100644 --- a/go/ql/test/library-tests/semmle/go/PrintAst/PrintAstNestedFunction.expected +++ b/go/ql/test/library-tests/semmle/go/PrintAst/PrintAstNestedFunction.expected @@ -1,16 +1,3 @@ -other.go: -# 8| [TypeParamDecl] type parameter declaration -# 8| 0: [Ident, TypeName] int -# 8| Type = int -# 8| 1: [Ident, TypeName] U -# 8| Type = U -# 17| [TypeParamDecl] type parameter declaration -# 17| 0: [TypeSetLiteralExpr] type set literal -# 17| Type = ~string -# 17| 0: [Ident, TypeName] string -# 17| Type = string -# 17| 1: [Ident, TypeName] T -# 17| Type = T go.mod: # 0| [GoModFile] go.mod # 1| 0: [GoModModuleLine] go.mod module line @@ -69,6 +56,11 @@ other.go: # 11| Type = int # 11| 0: [Ident, VariableName] myNested # 11| Type = func() int +# 8| 3: [TypeParamDecl] type parameter declaration +# 8| 0: [Ident, TypeName] int +# 8| Type = int +# 8| 1: [Ident, TypeName] U +# 8| Type = U # 15| 2: [VarDecl] variable declaration # 15| 0: [ValueSpec] value declaration specifier # 15| 0: [Ident, VariableName] x @@ -86,3 +78,10 @@ other.go: # 17| Type = []T # 17| 0: [Ident, TypeName] T # 17| Type = T +# 17| 2: [TypeParamDecl] type parameter declaration +# 17| 0: [TypeSetLiteralExpr] type set literal +# 17| Type = ~string +# 17| 0: [Ident, TypeName] string +# 17| Type = string +# 17| 1: [Ident, TypeName] T +# 17| Type = T diff --git a/go/ql/test/library-tests/semmle/go/PrintAst/PrintAstRestrictFile.expected b/go/ql/test/library-tests/semmle/go/PrintAst/PrintAstRestrictFile.expected index 3d313a087b48..45e6789e0139 100644 --- a/go/ql/test/library-tests/semmle/go/PrintAst/PrintAstRestrictFile.expected +++ b/go/ql/test/library-tests/semmle/go/PrintAst/PrintAstRestrictFile.expected @@ -1,16 +1,4 @@ other.go: -# 8| [TypeParamDecl] type parameter declaration -# 8| 0: [Ident, TypeName] int -# 8| Type = int -# 8| 1: [Ident, TypeName] U -# 8| Type = U -# 17| [TypeParamDecl] type parameter declaration -# 17| 0: [TypeSetLiteralExpr] type set literal -# 17| Type = ~string -# 17| 0: [Ident, TypeName] string -# 17| Type = string -# 17| 1: [Ident, TypeName] T -# 17| Type = T # 0| [GoFile] other.go # 1| package: [Ident] main # 3| 1: [FuncDecl] function declaration @@ -53,6 +41,11 @@ other.go: # 11| Type = int # 11| 0: [Ident, VariableName] myNested # 11| Type = func() int +# 8| 3: [TypeParamDecl] type parameter declaration +# 8| 0: [Ident, TypeName] int +# 8| Type = int +# 8| 1: [Ident, TypeName] U +# 8| Type = U # 15| 5: [VarDecl] variable declaration # 15| 0: [ValueSpec] value declaration specifier # 15| 0: [Ident, VariableName] x @@ -70,6 +63,13 @@ other.go: # 17| Type = []T # 17| 0: [Ident, TypeName] T # 17| Type = T +# 17| 2: [TypeParamDecl] type parameter declaration +# 17| 0: [TypeSetLiteralExpr] type set literal +# 17| Type = ~string +# 17| 0: [Ident, TypeName] string +# 17| Type = string +# 17| 1: [Ident, TypeName] T +# 17| Type = T # 19| 7: [MethodDecl] function declaration # 19| 0: [FunctionName, Ident] f # 19| Type = func() diff --git a/go/ql/test/library-tests/semmle/go/PrintAst/PrintAstRestrictFunction.expected b/go/ql/test/library-tests/semmle/go/PrintAst/PrintAstRestrictFunction.expected index 4ba6522d3267..3073a43383a3 100644 --- a/go/ql/test/library-tests/semmle/go/PrintAst/PrintAstRestrictFunction.expected +++ b/go/ql/test/library-tests/semmle/go/PrintAst/PrintAstRestrictFunction.expected @@ -4,13 +4,6 @@ other.go: # 8| Type = int # 8| 1: [Ident, TypeName] U # 8| Type = U -# 17| [TypeParamDecl] type parameter declaration -# 17| 0: [TypeSetLiteralExpr] type set literal -# 17| Type = ~string -# 17| 0: [Ident, TypeName] string -# 17| Type = string -# 17| 1: [Ident, TypeName] T -# 17| Type = T go.mod: # 0| [GoModFile] go.mod # 1| 0: [GoModModuleLine] go.mod module line @@ -66,3 +59,10 @@ other.go: # 17| Type = []T # 17| 0: [Ident, TypeName] T # 17| Type = T +# 17| 2: [TypeParamDecl] type parameter declaration +# 17| 0: [TypeSetLiteralExpr] type set literal +# 17| Type = ~string +# 17| 0: [Ident, TypeName] string +# 17| Type = string +# 17| 1: [Ident, TypeName] T +# 17| Type = T