From dc4140dc5fce8e1aae1cc0a6d4598a44424d6712 Mon Sep 17 00:00:00 2001 From: Jamesernator Date: Sat, 15 Oct 2016 07:38:57 +1300 Subject: [PATCH] Fixed incorrect compilation of async iterator methods (#4719) --- packages/babel-helper-remap-async-to-generator/src/index.js | 4 ++++ .../test/fixtures/async-generators/class-method/expected.js | 2 +- .../test/fixtures/async-generators/object-method/expected.js | 2 +- .../test/fixtures/async-generators/static-method/expected.js | 2 +- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/babel-helper-remap-async-to-generator/src/index.js b/packages/babel-helper-remap-async-to-generator/src/index.js index 64c2a47439..056606da3a 100644 --- a/packages/babel-helper-remap-async-to-generator/src/index.js +++ b/packages/babel-helper-remap-async-to-generator/src/index.js @@ -90,6 +90,10 @@ function classOrObjectMethod(path: NodePath, callId: Object) { [] )) ]; + + // Regardless of whether or not the wrapped function is a an async method + // or generator the outer function should not be + node.generator = false; } function plainFunction(path: NodePath, callId: Object) { diff --git a/packages/babel-plugin-transform-async-generator-functions/test/fixtures/async-generators/class-method/expected.js b/packages/babel-plugin-transform-async-generator-functions/test/fixtures/async-generators/class-method/expected.js index a774b790eb..4d300b50dc 100644 --- a/packages/babel-plugin-transform-async-generator-functions/test/fixtures/async-generators/class-method/expected.js +++ b/packages/babel-plugin-transform-async-generator-functions/test/fixtures/async-generators/class-method/expected.js @@ -1,5 +1,5 @@ class C { - *g() { + g() { var _this = this; return babelHelpers.asyncGenerator.wrap(function* () { diff --git a/packages/babel-plugin-transform-async-generator-functions/test/fixtures/async-generators/object-method/expected.js b/packages/babel-plugin-transform-async-generator-functions/test/fixtures/async-generators/object-method/expected.js index e4fefacc6c..c374fe93f4 100644 --- a/packages/babel-plugin-transform-async-generator-functions/test/fixtures/async-generators/object-method/expected.js +++ b/packages/babel-plugin-transform-async-generator-functions/test/fixtures/async-generators/object-method/expected.js @@ -1,5 +1,5 @@ ({ - *g() { + g() { var _this = this; return babelHelpers.asyncGenerator.wrap(function* () { diff --git a/packages/babel-plugin-transform-async-generator-functions/test/fixtures/async-generators/static-method/expected.js b/packages/babel-plugin-transform-async-generator-functions/test/fixtures/async-generators/static-method/expected.js index 01bbe95742..7517886206 100644 --- a/packages/babel-plugin-transform-async-generator-functions/test/fixtures/async-generators/static-method/expected.js +++ b/packages/babel-plugin-transform-async-generator-functions/test/fixtures/async-generators/static-method/expected.js @@ -1,5 +1,5 @@ class C { - static *g() { + static g() { var _this = this; return babelHelpers.asyncGenerator.wrap(function* () {