From b26917bff6c808d020a87ebc9f3230af0c5f96ce Mon Sep 17 00:00:00 2001 From: Rich-Harris Date: Sun, 18 Sep 2016 09:53:00 -0400 Subject: [PATCH 1/2] include superclass when including a class declaration (#932) --- src/ast/nodes/ClassDeclaration.js | 3 +++ test/function/includes-superclass/_config.js | 3 +++ test/function/includes-superclass/base.js | 5 +++++ test/function/includes-superclass/main.js | 6 ++++++ test/function/includes-superclass/thing.js | 7 +++++++ 5 files changed, 24 insertions(+) create mode 100644 test/function/includes-superclass/_config.js create mode 100644 test/function/includes-superclass/base.js create mode 100644 test/function/includes-superclass/main.js create mode 100644 test/function/includes-superclass/thing.js diff --git a/src/ast/nodes/ClassDeclaration.js b/src/ast/nodes/ClassDeclaration.js index f67c87d..f1a1daa 100644 --- a/src/ast/nodes/ClassDeclaration.js +++ b/src/ast/nodes/ClassDeclaration.js @@ -6,6 +6,7 @@ export default class ClassDeclaration extends Node { if ( this.activated ) return; this.activated = true; + if ( this.superClass ) this.superClass.run( this.scope ); this.body.run(); } @@ -26,6 +27,8 @@ export default class ClassDeclaration extends Node { } initialise ( scope ) { + this.scope = scope; + this.name = this.id.name; scope.addDeclaration( this.name, this, false, false ); diff --git a/test/function/includes-superclass/_config.js b/test/function/includes-superclass/_config.js new file mode 100644 index 0000000..7baf385 --- /dev/null +++ b/test/function/includes-superclass/_config.js @@ -0,0 +1,3 @@ +module.exports = { + description: 'includes superclass (#932)' +}; diff --git a/test/function/includes-superclass/base.js b/test/function/includes-superclass/base.js new file mode 100644 index 0000000..c374794 --- /dev/null +++ b/test/function/includes-superclass/base.js @@ -0,0 +1,5 @@ +export class Base { + foo () { + return true; + } +} diff --git a/test/function/includes-superclass/main.js b/test/function/includes-superclass/main.js new file mode 100644 index 0000000..bfb78e8 --- /dev/null +++ b/test/function/includes-superclass/main.js @@ -0,0 +1,6 @@ +import { Thing } from './thing'; + +const thing = new Thing(); + +assert.ok( thing.foo() ); +assert.ok( thing.bar() ); diff --git a/test/function/includes-superclass/thing.js b/test/function/includes-superclass/thing.js new file mode 100644 index 0000000..97b3be8 --- /dev/null +++ b/test/function/includes-superclass/thing.js @@ -0,0 +1,7 @@ +import { Base } from './base.js'; + +export class Thing extends Base { + bar () { + return true; + } +} From 036eae5ab116d5aa343953b2db64d3572d1af317 Mon Sep 17 00:00:00 2001 From: Rich-Harris Date: Sun, 18 Sep 2016 09:56:41 -0400 Subject: [PATCH 2/2] transpile test for 0.12 --- test/function/includes-superclass/_config.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/function/includes-superclass/_config.js b/test/function/includes-superclass/_config.js index 7baf385..e226472 100644 --- a/test/function/includes-superclass/_config.js +++ b/test/function/includes-superclass/_config.js @@ -1,3 +1,4 @@ module.exports = { - description: 'includes superclass (#932)' + description: 'includes superclass (#932)', + buble: true };