diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index ea38a8f4b31..ea86b2b9b04 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -5582,7 +5582,7 @@ module ts { needToCaptureLexicalThis = false; while (container && container.kind === SyntaxKind.ArrowFunction) { container = getSuperContainer(container, /*includeFunctions*/ true); - needToCaptureLexicalThis = true; + needToCaptureLexicalThis = languageVersion < ScriptTarget.ES6; } // topmost container must be something that is directly nested in the class declaration diff --git a/tests/baselines/reference/computedPropertyNames31_ES6.js b/tests/baselines/reference/computedPropertyNames31_ES6.js index 2c63dcee077..d17423223e3 100644 --- a/tests/baselines/reference/computedPropertyNames31_ES6.js +++ b/tests/baselines/reference/computedPropertyNames31_ES6.js @@ -23,7 +23,6 @@ class Base { } class C extends Base { foo() { - var _this = this; (() => { var obj = { [super.bar()]() { } // needs capture diff --git a/tests/baselines/reference/emitClassDeclarationWithSuperMethodCall01.js b/tests/baselines/reference/emitClassDeclarationWithSuperMethodCall01.js new file mode 100644 index 00000000000..77b91730156 --- /dev/null +++ b/tests/baselines/reference/emitClassDeclarationWithSuperMethodCall01.js @@ -0,0 +1,23 @@ +//// [emitClassDeclarationWithSuperMethodCall01.ts] + +class Parent { + foo() { + } +} + +class Foo extends Parent { + foo() { + var x = () => super.foo(); + } +} + +//// [emitClassDeclarationWithSuperMethodCall01.js] +class Parent { + foo() { + } +} +class Foo extends Parent { + foo() { + var x = () => super.foo(); + } +} diff --git a/tests/baselines/reference/emitClassDeclarationWithSuperMethodCall01.types b/tests/baselines/reference/emitClassDeclarationWithSuperMethodCall01.types new file mode 100644 index 00000000000..8b68af897ac --- /dev/null +++ b/tests/baselines/reference/emitClassDeclarationWithSuperMethodCall01.types @@ -0,0 +1,26 @@ +=== tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithSuperMethodCall01.ts === + +class Parent { +>Parent : Parent + + foo() { +>foo : () => void + } +} + +class Foo extends Parent { +>Foo : Foo +>Parent : Parent + + foo() { +>foo : () => void + + var x = () => super.foo(); +>x : () => void +>() => super.foo() : () => void +>super.foo() : void +>super.foo : () => void +>super : Parent +>foo : () => void + } +} diff --git a/tests/cases/conformance/decorators/class/method/decoratorOnClassMethod11.ts b/tests/cases/conformance/decorators/class/method/decoratorOnClassMethod11.ts index e3d94ff25d2..6f80fa00bca 100644 --- a/tests/cases/conformance/decorators/class/method/decoratorOnClassMethod11.ts +++ b/tests/cases/conformance/decorators/class/method/decoratorOnClassMethod11.ts @@ -1,9 +1,9 @@ -// @target: ES5 -module M { - class C { - decorator(target: Object, key: string): void { } - - @this.decorator - method() { } - } +// @target: ES5 +module M { + class C { + decorator(target: Object, key: string): void { } + + @this.decorator + method() { } + } } \ No newline at end of file diff --git a/tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithSuperMethodCall01.ts b/tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithSuperMethodCall01.ts new file mode 100644 index 00000000000..d9fdcc167eb --- /dev/null +++ b/tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithSuperMethodCall01.ts @@ -0,0 +1,12 @@ +//@target: es6 + +class Parent { + foo() { + } +} + +class Foo extends Parent { + foo() { + var x = () => super.foo(); + } +} \ No newline at end of file