mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-05-03 03:00:14 -04:00
adding no-argument super calls.
This commit is contained in:
@@ -263,7 +263,9 @@
|
||||
})
|
||||
],
|
||||
Super: [
|
||||
o("SUPER Arguments", function() {
|
||||
o("SUPER", function() {
|
||||
return new CallNode('super', [new SplatNode(new LiteralNode('arguments'))]);
|
||||
}), o("SUPER Arguments", function() {
|
||||
return new CallNode('super', $2);
|
||||
})
|
||||
],
|
||||
|
||||
230
lib/parser.js
230
lib/parser.js
File diff suppressed because one or more lines are too long
@@ -317,6 +317,7 @@ grammar: {
|
||||
|
||||
# Calling super.
|
||||
Super: [
|
||||
o "SUPER", -> new CallNode 'super', [new SplatNode(new LiteralNode('arguments'))]
|
||||
o "SUPER Arguments", -> new CallNode 'super', $2
|
||||
]
|
||||
|
||||
|
||||
@@ -114,7 +114,7 @@ class Hive
|
||||
constructor: (name) -> @name: name
|
||||
|
||||
class Hive.Bee extends Hive
|
||||
constructor: (name) -> super name
|
||||
constructor: (name) -> super
|
||||
|
||||
maya: new Hive.Bee 'Maya'
|
||||
ok maya.name is 'Maya'
|
||||
@@ -170,3 +170,16 @@ list: [3, 2, 1]
|
||||
conn: new Connection list...
|
||||
ok conn instanceof Connection
|
||||
ok conn.out() is '3-2-1'
|
||||
|
||||
|
||||
# Test calling super and passing along all arguments.
|
||||
class Parent
|
||||
method: (args...) -> @args: args
|
||||
|
||||
class Child extends Parent
|
||||
method: -> super
|
||||
|
||||
c: new Child
|
||||
c.method 1, 2, 3, 4
|
||||
ok c.args.join(' ') is '1 2 3 4'
|
||||
|
||||
|
||||
Reference in New Issue
Block a user