@@ -212,6 +212,23 @@ class Ellipsis extends @ellipsis, Expr {
212212 override string toString ( ) { result = "..." }
213213}
214214
215+ /**
216+ * A literal expression.
217+ *
218+ * Examples:
219+ *
220+ * ```go
221+ * "hello"
222+ * func(x, y int) int { return x + y }
223+ * map[string]int{"A": 1, "B": 2}
224+ * ```
225+ */
226+ class Literal extends Expr {
227+ Literal ( ) {
228+ this instanceof @basiclit or this instanceof @funclit or this instanceof @compositelit
229+ }
230+ }
231+
215232/**
216233 * A literal expression of basic type.
217234 *
@@ -222,7 +239,7 @@ class Ellipsis extends @ellipsis, Expr {
222239 * "hello"
223240 * ```
224241 */
225- class BasicLit extends @basiclit, Expr {
242+ class BasicLit extends @basiclit, Literal {
226243 /** Gets the value of this literal expressed as a string. */
227244 string getValue ( ) { literals ( this , result , _) }
228245
@@ -319,10 +336,10 @@ class StringLit extends @stringlit, BasicLit { }
319336 * func(x, y int) int { return x + y }
320337 * ```
321338 */
322- class FuncLit extends @funclit, Expr , StmtParent , FuncDef {
339+ class FuncLit extends @funclit, Literal , StmtParent , FuncDef {
323340 override FuncTypeExpr getTypeExpr ( ) { result = getChildExpr ( 0 ) }
324341
325- override SignatureType getType ( ) { result = Expr .super .getType ( ) }
342+ override SignatureType getType ( ) { result = Literal .super .getType ( ) }
326343
327344 /** Gets the body of this function literal. */
328345 override BlockStmt getBody ( ) { result = getChildStmt ( 1 ) }
@@ -342,7 +359,7 @@ class FuncLit extends @funclit, Expr, StmtParent, FuncDef {
342359 * map[string]int{"A": 1, "B": 2}
343360 * ```
344361 */
345- class CompositeLit extends @compositelit, Expr {
362+ class CompositeLit extends @compositelit, Literal {
346363 /** Gets the expression representing the type of this composite literal. */
347364 Expr getTypeExpr ( ) { result = getChildExpr ( 0 ) }
348365
0 commit comments