Skip to content

Commit a8273bf

Browse files
committed
No need for separate ast returns method, as it's never overridden
1 parent 3e7c570 commit a8273bf

File tree

2 files changed

+16
-19
lines changed

2 files changed

+16
-19
lines changed

lib/coffeescript/nodes.js

Lines changed: 9 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/nodes.coffee

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -281,9 +281,15 @@ exports.Base = class Base
281281
# **WARNING: DO NOT OVERRIDE THIS METHOD IN CHILD CLASSES.**
282282
# Only override the component `ast*` methods as needed.
283283
ast: (o, level) ->
284+
# Merge `level` into `o` and perform other universal checks.
284285
o = @astInitialize o, level
286+
# Create serializable representation of this node.
285287
astNode = @astNode o
286-
@astAddReturns astNode
288+
# Mark AST nodes that correspond to expressions that (implicitly) return.
289+
# We can’t do this as part of `astNode` because we need to assemble child
290+
# nodes first before marking the parent being returned.
291+
astNode.returns = yes if @astNode? and @canBeReturned
292+
astNode
287293

288294
astInitialize: (o, level) ->
289295
o = Object.assign {}, o
@@ -318,12 +324,6 @@ exports.Base = class Base
318324
astLocationData: ->
319325
jisonLocationDataToAstLocationData @locationData
320326

321-
# Mark AST nodes that correspond to expressions that (implicitly) return.
322-
astAddReturns: (ast) ->
323-
return ast unless ast?
324-
ast.returns = yes if @canBeReturned
325-
ast
326-
327327
# Determines whether an AST node needs an `ExpressionStatement` wrapper.
328328
# Typically matches our `isStatement()` logic but this allows overriding.
329329
isStatementAst: (o) ->

0 commit comments

Comments
 (0)