@@ -14,17 +14,14 @@ class ClassOrInterface extends @classorinterface, TypeParameterized {
1414 /** Gets the identifier naming the declared type, if any. */
1515 Identifier getIdentifier ( ) { none ( ) } // Overridden in subtypes.
1616
17- /** Gets the name of the defined class or interface, if any. */
18- string getName ( ) { result = getIdentifier ( ) .getName ( ) }
19-
2017 /**
2118 * Gets the name of the defined class or interface, possibly inferred
2219 * from the context if this is an anonymous class expression.
2320 *
2421 * Has no result if no name could be determined.
2522 */
26- string getInferredName ( ) {
27- result = getName ( ) // Overridden in ClassExpr
23+ string getName ( ) {
24+ result = getIdentifier ( ) . getName ( ) // Overridden in ClassExpr
2825 }
2926
3027 /** Gets the nearest enclosing function or toplevel in which this class or interface occurs. */
@@ -175,8 +172,8 @@ class ClassDefinition extends @classdefinition, ClassOrInterface, AST::ValueNode
175172 */
176173 private string inferNameFromVarDef ( ) {
177174 // in ambiguous cases like `let C = class D {}`, prefer `D` to `C`
178- if exists ( getName ( ) )
179- then result = "class " + getName ( )
175+ if exists ( getIdentifier ( ) )
176+ then result = "class " + getIdentifier ( ) . getName ( )
180177 else
181178 exists ( VarDef vd | this = vd .getSource ( ) |
182179 result = "class " + vd .getTarget ( ) .( VarRef ) .getName ( )
@@ -220,8 +217,8 @@ class ClassDeclStmt extends @classdeclstmt, ClassDefinition, Stmt {
220217 * A class expression.
221218 */
222219class ClassExpr extends @classexpr, ClassDefinition , Expr {
223- override string getInferredName ( ) {
224- result = getName ( )
220+ override string getName ( ) {
221+ result = ClassDefinition . super . getName ( )
225222 or
226223 exists ( VarDef vd | this = vd .getSource ( ) | result = vd .getTarget ( ) .( VarRef ) .getName ( ) )
227224 or
0 commit comments