Skip to content
This repository was archived by the owner on Jan 5, 2023. It is now read-only.

Commit 40ffa22

Browse files
authored
Merge pull request #171 from owen-mc/typeexprs-extend-typeexpr
Make `ArrayTypeExpr` and so on extend `TypeExpr`
2 parents b164cf3 + c891d22 commit 40ffa22

2 files changed

Lines changed: 14 additions & 14 deletions

File tree

docs/language/learn-ql/go/ast-class-reference.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -380,8 +380,8 @@ All classes in this subsection are subclasses of
380380
Type expressions
381381
~~~~~~~~~~~~~~~~
382382

383-
These classes represent different expressions for types. They do
384-
not have a common superclass.
383+
All classes in this subsection are subclasses of
384+
`TypeExpr <https://help.semmle.com/qldoc/go/semmle/go/Expr.qll/type.Expr$TypeExpr.html>`__.
385385

386386
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------+
387387
| Expression syntax | CodeQL class | Superclasses |

ql/src/semmle/go/Expr.qll

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -687,7 +687,7 @@ class KeyValueExpr extends @keyvalueexpr, Expr {
687687
* [5]int
688688
* ```
689689
*/
690-
class ArrayTypeExpr extends @arraytypeexpr, Expr {
690+
class ArrayTypeExpr extends @arraytypeexpr, TypeExpr {
691691
/** Gets the length expression of this array type. */
692692
Expr getLength() { result = getChildExpr(0) }
693693

@@ -706,7 +706,7 @@ class ArrayTypeExpr extends @arraytypeexpr, Expr {
706706
* struct {x, y int; z float32}
707707
* ```
708708
*/
709-
class StructTypeExpr extends @structtypeexpr, Expr {
709+
class StructTypeExpr extends @structtypeexpr, TypeExpr {
710710
/** Gets the `i`th field declared in this struct type expression (0-based). */
711711
FieldDecl getField(int i) { fields(result, this, i) }
712712

@@ -728,7 +728,7 @@ class StructTypeExpr extends @structtypeexpr, Expr {
728728
* func(a, b int, c float32) (float32, bool)
729729
* ```
730730
*/
731-
class FuncTypeExpr extends @functypeexpr, Expr, ScopeNode {
731+
class FuncTypeExpr extends @functypeexpr, TypeExpr, ScopeNode {
732732
/** Gets the `i`th parameter of this function type (0-based). */
733733
ParameterDecl getParameterDecl(int i) {
734734
result.getFunctionTypeExpr() = this and
@@ -768,7 +768,7 @@ class FuncTypeExpr extends @functypeexpr, Expr, ScopeNode {
768768
* interface { Read(p []byte) (n int, err error); Close() error}
769769
* ```
770770
*/
771-
class InterfaceTypeExpr extends @interfacetypeexpr, Expr {
771+
class InterfaceTypeExpr extends @interfacetypeexpr, TypeExpr {
772772
/** Gets the `i`th method specification of this interface type. */
773773
MethodSpec getMethod(int i) {
774774
result.getInterfaceTypeExpr() = this and
@@ -793,7 +793,7 @@ class InterfaceTypeExpr extends @interfacetypeexpr, Expr {
793793
* map[string]int
794794
* ```
795795
*/
796-
class MapTypeExpr extends @maptypeexpr, Expr {
796+
class MapTypeExpr extends @maptypeexpr, TypeExpr {
797797
/** Gets the expression representing the key type of this map type. */
798798
Expr getKeyTypeExpr() { result = getChildExpr(0) }
799799

@@ -1456,7 +1456,7 @@ class AndNotExpr extends @andnotexpr, BitwiseBinaryExpr {
14561456
* <-chan int
14571457
* ```
14581458
*/
1459-
class ChanTypeExpr extends @chantypeexpr, Expr {
1459+
class ChanTypeExpr extends @chantypeexpr, TypeExpr {
14601460
/**
14611461
* Gets the expression representing the type of values flowing through the channel.
14621462
*/
@@ -1697,12 +1697,12 @@ class LabelName extends Name {
16971697
*/
16981698
private predicate isTypeExprBottomUp(Expr e) {
16991699
e instanceof TypeName or
1700-
e instanceof ArrayTypeExpr or
1701-
e instanceof StructTypeExpr or
1702-
e instanceof FuncTypeExpr or
1703-
e instanceof InterfaceTypeExpr or
1704-
e instanceof MapTypeExpr or
1705-
e instanceof ChanTypeExpr or
1700+
e instanceof @arraytypeexpr or
1701+
e instanceof @structtypeexpr or
1702+
e instanceof @functypeexpr or
1703+
e instanceof @interfacetypeexpr or
1704+
e instanceof @maptypeexpr or
1705+
e instanceof @chantypeexpr or
17061706
isTypeExprBottomUp(e.(ParenExpr).getExpr()) or
17071707
isTypeExprBottomUp(e.(StarExpr).getBase()) or
17081708
isTypeExprBottomUp(e.(Ellipsis).getOperand())

0 commit comments

Comments
 (0)