Merge pull request #6077 from Microsoft/superInObjectLiterals

allow usage of 'super' in object literal expressions
This commit is contained in:
Vladimir Matveev
2015-12-17 21:53:58 -08:00
29 changed files with 968 additions and 129 deletions

View File

@@ -1,4 +1,4 @@
tests/cases/conformance/es6/computedProperties/computedPropertyNames30_ES5.ts(11,19): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors.
tests/cases/conformance/es6/computedProperties/computedPropertyNames30_ES5.ts(11,19): error TS2466: 'super' cannot be referenced in a computed property name.
==== tests/cases/conformance/es6/computedProperties/computedPropertyNames30_ES5.ts (1 errors) ====
@@ -14,7 +14,7 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames30_ES5.ts(11
//treatment of other similar violations.
[(super(), "prop")]() { }
~~~~~
!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors.
!!! error TS2466: 'super' cannot be referenced in a computed property name.
};
}
}

View File

@@ -1,4 +1,4 @@
tests/cases/conformance/es6/computedProperties/computedPropertyNames30_ES6.ts(11,19): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors.
tests/cases/conformance/es6/computedProperties/computedPropertyNames30_ES6.ts(11,19): error TS2466: 'super' cannot be referenced in a computed property name.
==== tests/cases/conformance/es6/computedProperties/computedPropertyNames30_ES6.ts (1 errors) ====
@@ -14,7 +14,7 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames30_ES6.ts(11
//treatment of other similar violations.
[(super(), "prop")]() { }
~~~~~
!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors.
!!! error TS2466: 'super' cannot be referenced in a computed property name.
};
}
}

View File

@@ -1,4 +1,4 @@
tests/cases/conformance/decorators/class/method/decoratorOnClassMethod12.ts(6,10): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class.
tests/cases/conformance/decorators/class/method/decoratorOnClassMethod12.ts(6,10): error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
==== tests/cases/conformance/decorators/class/method/decoratorOnClassMethod12.ts (1 errors) ====
@@ -9,7 +9,7 @@ tests/cases/conformance/decorators/class/method/decoratorOnClassMethod12.ts(6,10
class C extends S {
@super.decorator
~~~~~
!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class.
!!! error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
method() { }
}
}

View File

@@ -1,6 +1,6 @@
tests/cases/compiler/emitThisInSuperMethodCall.ts(10,17): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class.
tests/cases/compiler/emitThisInSuperMethodCall.ts(17,17): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class.
tests/cases/compiler/emitThisInSuperMethodCall.ts(23,13): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class.
tests/cases/compiler/emitThisInSuperMethodCall.ts(10,17): error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
tests/cases/compiler/emitThisInSuperMethodCall.ts(17,17): error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
tests/cases/compiler/emitThisInSuperMethodCall.ts(23,13): error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
==== tests/cases/compiler/emitThisInSuperMethodCall.ts (3 errors) ====
@@ -15,7 +15,7 @@ tests/cases/compiler/emitThisInSuperMethodCall.ts(23,13): error TS2338: 'super'
function inner() {
super.sayHello();
~~~~~
!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class.
!!! error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
}
};
}
@@ -24,7 +24,7 @@ tests/cases/compiler/emitThisInSuperMethodCall.ts(23,13): error TS2338: 'super'
() => {
super.sayHello();
~~~~~
!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class.
!!! error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
}
}
}
@@ -32,7 +32,7 @@ tests/cases/compiler/emitThisInSuperMethodCall.ts(23,13): error TS2338: 'super'
function inner() {
super.sayHello();
~~~~~
!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class.
!!! error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
}
}
}

View File

@@ -1,12 +1,12 @@
tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(4,9): error TS2335: 'super' can only be referenced in a derived class.
tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(9,9): error TS2335: 'super' can only be referenced in a derived class.
tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(14,9): error TS2335: 'super' can only be referenced in a derived class.
tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(18,9): error TS2335: 'super' can only be referenced in a derived class.
tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(22,9): error TS2335: 'super' can only be referenced in a derived class.
tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(26,9): error TS2335: 'super' can only be referenced in a derived class.
tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(30,16): error TS2335: 'super' can only be referenced in a derived class.
tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(34,9): error TS2335: 'super' can only be referenced in a derived class.
tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(38,9): error TS2335: 'super' can only be referenced in a derived class.
tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(9,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors.
tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(14,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors.
tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(18,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors.
tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(22,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors.
tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(26,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors.
tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(30,16): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors.
tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(34,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors.
tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(38,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors.
tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(46,14): error TS1034: 'super' must be followed by an argument list or member access.
tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(58,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors.
tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(62,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors.
@@ -27,50 +27,50 @@ tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(71,9): error T
fn() {
super();
~~~~~
!!! error TS2335: 'super' can only be referenced in a derived class.
!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors.
}
//super call in class accessor (get and set) with no base type
get foo() {
super();
~~~~~
!!! error TS2335: 'super' can only be referenced in a derived class.
!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors.
return null;
}
set foo(v) {
super();
~~~~~
!!! error TS2335: 'super' can only be referenced in a derived class.
!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors.
}
//super call in class member initializer with no base type
p = super();
~~~~~
!!! error TS2335: 'super' can only be referenced in a derived class.
!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors.
//super call in static class member function with no base type
static fn() {
super();
~~~~~
!!! error TS2335: 'super' can only be referenced in a derived class.
!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors.
}
//super call in static class member initializer with no base type
static k = super();
~~~~~
!!! error TS2335: 'super' can only be referenced in a derived class.
!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors.
//super call in static class accessor (get and set) with no base type
static get q() {
super();
~~~~~
!!! error TS2335: 'super' can only be referenced in a derived class.
!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors.
return null;
}
static set q(n) {
super();
~~~~~
!!! error TS2335: 'super' can only be referenced in a derived class.
!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors.
}
}

View File

@@ -15,8 +15,8 @@ tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess
tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(65,23): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword.
tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(68,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(69,19): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword.
tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(73,13): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class.
tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(76,40): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class.
tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(73,13): error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(76,40): error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(87,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword.
tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(91,23): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword.
tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(94,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
@@ -34,8 +34,8 @@ tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess
tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(120,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword.
tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(121,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword.
tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(122,9): error TS2341: Property 'privateStaticFunc' is private and only accessible within class 'SomeBase'.
tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(127,16): error TS2335: 'super' can only be referenced in a derived class.
tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(127,30): error TS2335: 'super' can only be referenced in a derived class.
tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(127,16): error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(127,30): error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
==== tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts (38 errors) ====
@@ -147,12 +147,12 @@ tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess
function inner() {
super.publicFunc();
~~~~~
!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class.
!!! error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
}
var x = {
test: function () { return super.publicFunc(); }
~~~~~
!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class.
!!! error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
}
}
}
@@ -239,7 +239,7 @@ tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess
// In object literal
var obj = { n: super.wat, p: super.foo() };
~~~~~
!!! error TS2335: 'super' can only be referenced in a derived class.
!!! error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
~~~~~
!!! error TS2335: 'super' can only be referenced in a derived class.
!!! error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.

View File

@@ -1,4 +1,4 @@
tests/cases/compiler/superCallFromFunction1.ts(3,5): error TS2335: 'super' can only be referenced in a derived class.
tests/cases/compiler/superCallFromFunction1.ts(3,5): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors.
==== tests/cases/compiler/superCallFromFunction1.ts (1 errors) ====
@@ -6,5 +6,5 @@ tests/cases/compiler/superCallFromFunction1.ts(3,5): error TS2335: 'super' can o
function foo() {
super(value => String(value));
~~~~~
!!! error TS2335: 'super' can only be referenced in a derived class.
!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors.
}

View File

@@ -1,15 +1,15 @@
tests/cases/compiler/superErrors.ts(3,13): error TS2335: 'super' can only be referenced in a derived class.
tests/cases/compiler/superErrors.ts(3,13): error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
tests/cases/compiler/superErrors.ts(3,18): error TS1034: 'super' must be followed by an argument list or member access.
tests/cases/compiler/superErrors.ts(4,19): error TS2335: 'super' can only be referenced in a derived class.
tests/cases/compiler/superErrors.ts(4,19): error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
tests/cases/compiler/superErrors.ts(4,24): error TS1034: 'super' must be followed by an argument list or member access.
tests/cases/compiler/superErrors.ts(5,31): error TS2335: 'super' can only be referenced in a derived class.
tests/cases/compiler/superErrors.ts(5,31): error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
tests/cases/compiler/superErrors.ts(5,36): error TS1034: 'super' must be followed by an argument list or member access.
tests/cases/compiler/superErrors.ts(22,13): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class.
tests/cases/compiler/superErrors.ts(27,27): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class.
tests/cases/compiler/superErrors.ts(31,36): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class.
tests/cases/compiler/superErrors.ts(22,13): error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
tests/cases/compiler/superErrors.ts(27,27): error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
tests/cases/compiler/superErrors.ts(31,36): error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
tests/cases/compiler/superErrors.ts(31,41): error TS1034: 'super' must be followed by an argument list or member access.
tests/cases/compiler/superErrors.ts(39,27): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class.
tests/cases/compiler/superErrors.ts(43,36): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class.
tests/cases/compiler/superErrors.ts(39,27): error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
tests/cases/compiler/superErrors.ts(43,36): error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
tests/cases/compiler/superErrors.ts(43,41): error TS1034: 'super' must be followed by an argument list or member access.
tests/cases/compiler/superErrors.ts(47,22): error TS1034: 'super' must be followed by an argument list or member access.
tests/cases/compiler/superErrors.ts(48,28): error TS1034: 'super' must be followed by an argument list or member access.
@@ -21,17 +21,17 @@ tests/cases/compiler/superErrors.ts(49,40): error TS1034: 'super' must be follow
// super in a non class context
var x = super;
~~~~~
!!! error TS2335: 'super' can only be referenced in a derived class.
!!! error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
~
!!! error TS1034: 'super' must be followed by an argument list or member access.
var y = () => super;
~~~~~
!!! error TS2335: 'super' can only be referenced in a derived class.
!!! error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
~
!!! error TS1034: 'super' must be followed by an argument list or member access.
var z = () => () => () => super;
~~~~~
!!! error TS2335: 'super' can only be referenced in a derived class.
!!! error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
~
!!! error TS1034: 'super' must be followed by an argument list or member access.
}
@@ -52,20 +52,20 @@ tests/cases/compiler/superErrors.ts(49,40): error TS1034: 'super' must be follow
function inner() {
super.sayHello();
~~~~~
!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class.
!!! error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
}
// super call in a lambda in an inner function in a constructor
function inner2() {
var x = () => super.sayHello();
~~~~~
!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class.
!!! error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
}
// super call in a lambda in a function expression in a constructor
(function() { return () => super; })();
~~~~~
!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class.
!!! error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
~
!!! error TS1034: 'super' must be followed by an argument list or member access.
}
@@ -77,13 +77,13 @@ tests/cases/compiler/superErrors.ts(49,40): error TS1034: 'super' must be follow
function inner() {
var x = () => super.sayHello();
~~~~~
!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class.
!!! error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
}
// super call in a lambda in a function expression in a constructor
(function() { return () => super; })();
~~~~~
!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class.
!!! error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
~
!!! error TS1034: 'super' must be followed by an argument list or member access.
}

View File

@@ -0,0 +1,95 @@
tests/cases/compiler/superInObjectLiterals_ES5.ts(7,9): error TS2659: 'super' is only allowed in members of object literal expressions when option 'target' is 'ES2015' or higher.
tests/cases/compiler/superInObjectLiterals_ES5.ts(10,9): error TS2659: 'super' is only allowed in members of object literal expressions when option 'target' is 'ES2015' or higher.
tests/cases/compiler/superInObjectLiterals_ES5.ts(14,9): error TS2659: 'super' is only allowed in members of object literal expressions when option 'target' is 'ES2015' or higher.
tests/cases/compiler/superInObjectLiterals_ES5.ts(17,9): error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
tests/cases/compiler/superInObjectLiterals_ES5.ts(20,9): error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
tests/cases/compiler/superInObjectLiterals_ES5.ts(23,9): error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
tests/cases/compiler/superInObjectLiterals_ES5.ts(39,17): error TS2659: 'super' is only allowed in members of object literal expressions when option 'target' is 'ES2015' or higher.
tests/cases/compiler/superInObjectLiterals_ES5.ts(42,17): error TS2659: 'super' is only allowed in members of object literal expressions when option 'target' is 'ES2015' or higher.
tests/cases/compiler/superInObjectLiterals_ES5.ts(46,17): error TS2659: 'super' is only allowed in members of object literal expressions when option 'target' is 'ES2015' or higher.
tests/cases/compiler/superInObjectLiterals_ES5.ts(49,17): error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
tests/cases/compiler/superInObjectLiterals_ES5.ts(52,17): error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
==== tests/cases/compiler/superInObjectLiterals_ES5.ts (11 errors) ====
var obj = {
__proto__: {
method() {
}
},
method() {
super.method();
~~~~~
!!! error TS2659: 'super' is only allowed in members of object literal expressions when option 'target' is 'ES2015' or higher.
},
get prop() {
super.method();
~~~~~
!!! error TS2659: 'super' is only allowed in members of object literal expressions when option 'target' is 'ES2015' or higher.
return 10;
},
set prop(value) {
super.method();
~~~~~
!!! error TS2659: 'super' is only allowed in members of object literal expressions when option 'target' is 'ES2015' or higher.
},
p1: function () {
super.method();
~~~~~
!!! error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
},
p2: function f() {
super.method();
~~~~~
!!! error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
},
p3: () => {
super.method();
~~~~~
!!! error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
}
};
class A {
method() { }
}
class B extends A {
f() {
var obj = {
__proto__: {
method() {
}
},
method() {
super.method();
~~~~~
!!! error TS2659: 'super' is only allowed in members of object literal expressions when option 'target' is 'ES2015' or higher.
},
get prop() {
super.method();
~~~~~
!!! error TS2659: 'super' is only allowed in members of object literal expressions when option 'target' is 'ES2015' or higher.
return 10;
},
set prop(value) {
super.method();
~~~~~
!!! error TS2659: 'super' is only allowed in members of object literal expressions when option 'target' is 'ES2015' or higher.
},
p1: function () {
super.method();
~~~~~
!!! error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
},
p2: function f() {
super.method();
~~~~~
!!! error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
},
p3: () => {
super.method();
}
};
}
}

View File

@@ -0,0 +1,133 @@
//// [superInObjectLiterals_ES5.ts]
var obj = {
__proto__: {
method() {
}
},
method() {
super.method();
},
get prop() {
super.method();
return 10;
},
set prop(value) {
super.method();
},
p1: function () {
super.method();
},
p2: function f() {
super.method();
},
p3: () => {
super.method();
}
};
class A {
method() { }
}
class B extends A {
f() {
var obj = {
__proto__: {
method() {
}
},
method() {
super.method();
},
get prop() {
super.method();
return 10;
},
set prop(value) {
super.method();
},
p1: function () {
super.method();
},
p2: function f() {
super.method();
},
p3: () => {
super.method();
}
};
}
}
//// [superInObjectLiterals_ES5.js]
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var obj = {
__proto__: {
method: function () {
}
},
method: function () {
_super.prototype.method.call(this);
},
get prop() {
_super.prototype.method.call(this);
return 10;
},
set prop(value) {
_super.prototype.method.call(this);
},
p1: function () {
_super.method.call(this);
},
p2: function f() {
_super.method.call(this);
},
p3: function () {
_super.method.call(this);
}
};
var A = (function () {
function A() {
}
A.prototype.method = function () { };
return A;
}());
var B = (function (_super) {
__extends(B, _super);
function B() {
_super.apply(this, arguments);
}
B.prototype.f = function () {
var _this = this;
var obj = {
__proto__: {
method: function () {
}
},
method: function () {
_super.prototype.method.call(this);
},
get prop() {
_super.prototype.method.call(this);
return 10;
},
set prop(value) {
_super.prototype.method.call(this);
},
p1: function () {
_super.method.call(this);
},
p2: function f() {
_super.method.call(this);
},
p3: function () {
_super.prototype.method.call(_this);
}
};
};
return B;
}(A));

View File

@@ -0,0 +1,77 @@
tests/cases/compiler/superInObjectLiterals_ES6.ts(17,9): error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
tests/cases/compiler/superInObjectLiterals_ES6.ts(20,9): error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
tests/cases/compiler/superInObjectLiterals_ES6.ts(23,9): error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
tests/cases/compiler/superInObjectLiterals_ES6.ts(49,17): error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
tests/cases/compiler/superInObjectLiterals_ES6.ts(52,17): error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
==== tests/cases/compiler/superInObjectLiterals_ES6.ts (5 errors) ====
var obj = {
__proto__: {
method() {
}
},
method() {
super.method();
},
get prop() {
super.method();
return 10;
},
set prop(value) {
super.method();
},
p1: function () {
super.method();
~~~~~
!!! error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
},
p2: function f() {
super.method();
~~~~~
!!! error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
},
p3: () => {
super.method();
~~~~~
!!! error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
}
};
class A {
method() { }
}
class B extends A {
f() {
var obj = {
__proto__: {
method() {
}
},
method() {
super.method();
},
get prop() {
super.method();
return 10;
},
set prop(value) {
super.method();
},
p1: function () {
super.method();
~~~~~
!!! error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
},
p2: function f() {
super.method();
~~~~~
!!! error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
},
p3: () => {
super.method();
}
};
}
}

View File

@@ -0,0 +1,119 @@
//// [superInObjectLiterals_ES6.ts]
var obj = {
__proto__: {
method() {
}
},
method() {
super.method();
},
get prop() {
super.method();
return 10;
},
set prop(value) {
super.method();
},
p1: function () {
super.method();
},
p2: function f() {
super.method();
},
p3: () => {
super.method();
}
};
class A {
method() { }
}
class B extends A {
f() {
var obj = {
__proto__: {
method() {
}
},
method() {
super.method();
},
get prop() {
super.method();
return 10;
},
set prop(value) {
super.method();
},
p1: function () {
super.method();
},
p2: function f() {
super.method();
},
p3: () => {
super.method();
}
};
}
}
//// [superInObjectLiterals_ES6.js]
var obj = {
__proto__: {
method() {
}
},
method() {
super.method();
},
get prop() {
super.method();
return 10;
},
set prop(value) {
super.method();
},
p1: function () {
super.method();
},
p2: function f() {
super.method();
},
p3: () => {
super.method();
}
};
class A {
method() { }
}
class B extends A {
f() {
var obj = {
__proto__: {
method() {
}
},
method() {
super.method();
},
get prop() {
super.method();
return 10;
},
set prop(value) {
super.method();
},
p1: function () {
super.method();
},
p2: function f() {
super.method();
},
p3: () => {
super.method();
}
};
}
}

View File

@@ -0,0 +1,46 @@
//// [superPropertyAccessInComputedPropertiesOfNestedType_ES5.ts]
class A {
foo() { return 1; }
}
class B extends A {
foo() { return 2; }
bar() {
return class {
[super.foo()]() {
return 100;
}
}
}
}
//// [superPropertyAccessInComputedPropertiesOfNestedType_ES5.js]
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var A = (function () {
function A() {
}
A.prototype.foo = function () { return 1; };
return A;
}());
var B = (function (_super) {
__extends(B, _super);
function B() {
_super.apply(this, arguments);
}
B.prototype.foo = function () { return 2; };
B.prototype.bar = function () {
return (function () {
function class_1() {
}
class_1.prototype[_super.prototype.foo.call(this)] = function () {
return 100;
};
return class_1;
}());
};
return B;
}(A));

View File

@@ -0,0 +1,29 @@
=== tests/cases/compiler/superPropertyAccessInComputedPropertiesOfNestedType_ES5.ts ===
class A {
>A : Symbol(A, Decl(superPropertyAccessInComputedPropertiesOfNestedType_ES5.ts, 0, 0))
foo() { return 1; }
>foo : Symbol(foo, Decl(superPropertyAccessInComputedPropertiesOfNestedType_ES5.ts, 0, 9))
}
class B extends A {
>B : Symbol(B, Decl(superPropertyAccessInComputedPropertiesOfNestedType_ES5.ts, 2, 1))
>A : Symbol(A, Decl(superPropertyAccessInComputedPropertiesOfNestedType_ES5.ts, 0, 0))
foo() { return 2; }
>foo : Symbol(foo, Decl(superPropertyAccessInComputedPropertiesOfNestedType_ES5.ts, 4, 19))
bar() {
>bar : Symbol(bar, Decl(superPropertyAccessInComputedPropertiesOfNestedType_ES5.ts, 5, 23))
return class {
[super.foo()]() {
>super.foo : Symbol(A.foo, Decl(superPropertyAccessInComputedPropertiesOfNestedType_ES5.ts, 0, 9))
>super : Symbol(A, Decl(superPropertyAccessInComputedPropertiesOfNestedType_ES5.ts, 0, 0))
>foo : Symbol(A.foo, Decl(superPropertyAccessInComputedPropertiesOfNestedType_ES5.ts, 0, 9))
return 100;
}
}
}
}

View File

@@ -0,0 +1,35 @@
=== tests/cases/compiler/superPropertyAccessInComputedPropertiesOfNestedType_ES5.ts ===
class A {
>A : A
foo() { return 1; }
>foo : () => number
>1 : number
}
class B extends A {
>B : B
>A : A
foo() { return 2; }
>foo : () => number
>2 : number
bar() {
>bar : () => typeof (Anonymous class)
return class {
>class { [super.foo()]() { return 100; } } : typeof (Anonymous class)
[super.foo()]() {
>super.foo() : number
>super.foo : () => number
>super : A
>foo : () => number
return 100;
>100 : number
}
}
}
}

View File

@@ -0,0 +1,31 @@
//// [superPropertyAccessInComputedPropertiesOfNestedType_ES6.ts]
class A {
foo() { return 1; }
}
class B extends A {
foo() { return 2; }
bar() {
return class {
[super.foo()]() {
return 100;
}
}
}
}
//// [superPropertyAccessInComputedPropertiesOfNestedType_ES6.js]
class A {
foo() { return 1; }
}
class B extends A {
foo() { return 2; }
bar() {
return class {
[super.foo()]() {
return 100;
}
}
;
}
}

View File

@@ -0,0 +1,29 @@
=== tests/cases/compiler/superPropertyAccessInComputedPropertiesOfNestedType_ES6.ts ===
class A {
>A : Symbol(A, Decl(superPropertyAccessInComputedPropertiesOfNestedType_ES6.ts, 0, 0))
foo() { return 1; }
>foo : Symbol(foo, Decl(superPropertyAccessInComputedPropertiesOfNestedType_ES6.ts, 0, 9))
}
class B extends A {
>B : Symbol(B, Decl(superPropertyAccessInComputedPropertiesOfNestedType_ES6.ts, 2, 1))
>A : Symbol(A, Decl(superPropertyAccessInComputedPropertiesOfNestedType_ES6.ts, 0, 0))
foo() { return 2; }
>foo : Symbol(foo, Decl(superPropertyAccessInComputedPropertiesOfNestedType_ES6.ts, 4, 19))
bar() {
>bar : Symbol(bar, Decl(superPropertyAccessInComputedPropertiesOfNestedType_ES6.ts, 5, 23))
return class {
[super.foo()]() {
>super.foo : Symbol(A.foo, Decl(superPropertyAccessInComputedPropertiesOfNestedType_ES6.ts, 0, 9))
>super : Symbol(A, Decl(superPropertyAccessInComputedPropertiesOfNestedType_ES6.ts, 0, 0))
>foo : Symbol(A.foo, Decl(superPropertyAccessInComputedPropertiesOfNestedType_ES6.ts, 0, 9))
return 100;
}
}
}
}

View File

@@ -0,0 +1,35 @@
=== tests/cases/compiler/superPropertyAccessInComputedPropertiesOfNestedType_ES6.ts ===
class A {
>A : A
foo() { return 1; }
>foo : () => number
>1 : number
}
class B extends A {
>B : B
>A : A
foo() { return 2; }
>foo : () => number
>2 : number
bar() {
>bar : () => typeof (Anonymous class)
return class {
>class { [super.foo()]() { return 100; } } : typeof (Anonymous class)
[super.foo()]() {
>super.foo() : number
>super.foo : () => number
>super : A
>foo : () => number
return 100;
>100 : number
}
}
}
}

View File

@@ -1,10 +1,10 @@
tests/cases/compiler/super_inside-object-literal-getters-and-setters.ts(4,13): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
tests/cases/compiler/super_inside-object-literal-getters-and-setters.ts(5,20): error TS2335: 'super' can only be referenced in a derived class.
tests/cases/compiler/super_inside-object-literal-getters-and-setters.ts(5,20): error TS2659: 'super' is only allowed in members of object literal expressions when option 'target' is 'ES2015' or higher.
tests/cases/compiler/super_inside-object-literal-getters-and-setters.ts(7,13): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
tests/cases/compiler/super_inside-object-literal-getters-and-setters.ts(8,13): error TS2335: 'super' can only be referenced in a derived class.
tests/cases/compiler/super_inside-object-literal-getters-and-setters.ts(11,20): error TS2335: 'super' can only be referenced in a derived class.
tests/cases/compiler/super_inside-object-literal-getters-and-setters.ts(8,13): error TS2659: 'super' is only allowed in members of object literal expressions when option 'target' is 'ES2015' or higher.
tests/cases/compiler/super_inside-object-literal-getters-and-setters.ts(11,20): error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
tests/cases/compiler/super_inside-object-literal-getters-and-setters.ts(20,17): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
tests/cases/compiler/super_inside-object-literal-getters-and-setters.ts(21,24): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class.
tests/cases/compiler/super_inside-object-literal-getters-and-setters.ts(21,24): error TS2659: 'super' is only allowed in members of object literal expressions when option 'target' is 'ES2015' or higher.
==== tests/cases/compiler/super_inside-object-literal-getters-and-setters.ts (7 errors) ====
@@ -16,19 +16,19 @@ tests/cases/compiler/super_inside-object-literal-getters-and-setters.ts(21,24):
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
return super._foo;
~~~~~
!!! error TS2335: 'super' can only be referenced in a derived class.
!!! error TS2659: 'super' is only allowed in members of object literal expressions when option 'target' is 'ES2015' or higher.
},
set foo(value: string) {
~~~
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
super._foo = value;
~~~~~
!!! error TS2335: 'super' can only be referenced in a derived class.
!!! error TS2659: 'super' is only allowed in members of object literal expressions when option 'target' is 'ES2015' or higher.
},
test: function () {
return super._foo;
~~~~~
!!! error TS2335: 'super' can only be referenced in a derived class.
!!! error TS2660: 'super' can only be referenced in members of derived classes or object literal expressions.
}
}
}
@@ -42,7 +42,7 @@ tests/cases/compiler/super_inside-object-literal-getters-and-setters.ts(21,24):
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
return super.test();
~~~~~
!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class.
!!! error TS2659: 'super' is only allowed in members of object literal expressions when option 'target' is 'ES2015' or higher.
}
};
}

View File

@@ -38,10 +38,10 @@ var ObjectLiteral;
var ThisInObjectLiteral = {
_foo: '1',
get foo() {
return _super._foo;
return _super.prototype._foo;
},
set foo(value) {
_super._foo = value;
_super.prototype._foo = value;
},
test: function () {
return _super._foo;
@@ -62,7 +62,7 @@ var SuperObjectTest = (function (_super) {
SuperObjectTest.prototype.testing = function () {
var test = {
get F() {
return _super.test.call(this);
return _super.prototype.test.call(this);
}
};
};

View File

@@ -0,0 +1,60 @@
// @target: ES5
var obj = {
__proto__: {
method() {
}
},
method() {
super.method();
},
get prop() {
super.method();
return 10;
},
set prop(value) {
super.method();
},
p1: function () {
super.method();
},
p2: function f() {
super.method();
},
p3: () => {
super.method();
}
};
class A {
method() { }
}
class B extends A {
f() {
var obj = {
__proto__: {
method() {
}
},
method() {
super.method();
},
get prop() {
super.method();
return 10;
},
set prop(value) {
super.method();
},
p1: function () {
super.method();
},
p2: function f() {
super.method();
},
p3: () => {
super.method();
}
};
}
}

View File

@@ -0,0 +1,60 @@
// @target: ES6
var obj = {
__proto__: {
method() {
}
},
method() {
super.method();
},
get prop() {
super.method();
return 10;
},
set prop(value) {
super.method();
},
p1: function () {
super.method();
},
p2: function f() {
super.method();
},
p3: () => {
super.method();
}
};
class A {
method() { }
}
class B extends A {
f() {
var obj = {
__proto__: {
method() {
}
},
method() {
super.method();
},
get prop() {
super.method();
return 10;
},
set prop(value) {
super.method();
},
p1: function () {
super.method();
},
p2: function f() {
super.method();
},
p3: () => {
super.method();
}
};
}
}

View File

@@ -0,0 +1,15 @@
// @target: ES5
class A {
foo() { return 1; }
}
class B extends A {
foo() { return 2; }
bar() {
return class {
[super.foo()]() {
return 100;
}
}
}
}

View File

@@ -0,0 +1,15 @@
// @target: ES6
class A {
foo() { return 1; }
}
class B extends A {
foo() { return 2; }
bar() {
return class {
[super.foo()]() {
return 100;
}
}
}
}

View File

@@ -0,0 +1,34 @@
/// <reference path='fourslash.ts' />
////let x = {
//// a() {
//// return [|s/**/uper|].b();
//// },
//// b() {
//// return [|super|].a();
//// },
//// c: function () {
//// return [|super|].a();
//// }
//// d: () => [|super|].b();
////}
function checkRange(r: FourSlashInterface.Range, expectedOccurences: FourSlashInterface.Range[]): void {
goTo.position(r.start);
if (expectedOccurences.length) {
for (const expected of expectedOccurences) {
verify.occurrencesAtPositionContains(expected);
}
}
else {
verify.occurrencesAtPositionCount(0);
}
}
let [r0, r1, r2, r3] = test.ranges();
checkRange(r0, [r0, r1]);
checkRange(r1, [r0, r1]);
checkRange(r0, [r0, r1]);
checkRange(r2, []);
checkRange(r3, []);