(ts) Throw for abstract methods in a non-abstract class (#12686)
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
class Foo {
|
||||
abstract method();
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":34,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
|
||||
"errors": [
|
||||
"SyntaxError: Abstract methods can only appear within an abstract class. (2:2)"
|
||||
],
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":34,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
|
||||
"sourceType": "module",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "ClassDeclaration",
|
||||
"start":0,"end":34,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start":6,"end":9,"loc":{"start":{"line":1,"column":6},"end":{"line":1,"column":9},"identifierName":"Foo"},
|
||||
"name": "Foo"
|
||||
},
|
||||
"superClass": null,
|
||||
"body": {
|
||||
"type": "ClassBody",
|
||||
"start":10,"end":34,"loc":{"start":{"line":1,"column":10},"end":{"line":3,"column":1}},
|
||||
"body": [
|
||||
{
|
||||
"type": "TSDeclareMethod",
|
||||
"start":14,"end":32,"loc":{"start":{"line":2,"column":2},"end":{"line":2,"column":20}},
|
||||
"abstract": true,
|
||||
"static": false,
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start":23,"end":29,"loc":{"start":{"line":2,"column":11},"end":{"line":2,"column":17},"identifierName":"method"},
|
||||
"name": "method"
|
||||
},
|
||||
"computed": false,
|
||||
"kind": "method",
|
||||
"id": null,
|
||||
"generator": false,
|
||||
"async": false,
|
||||
"params": []
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
abstract class Foo {
|
||||
method() {
|
||||
return class {
|
||||
abstract m();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":84,"loc":{"start":{"line":1,"column":0},"end":{"line":7,"column":1}},
|
||||
"errors": [
|
||||
"SyntaxError: Abstract methods can only appear within an abstract class. (4:6)"
|
||||
],
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":84,"loc":{"start":{"line":1,"column":0},"end":{"line":7,"column":1}},
|
||||
"sourceType": "module",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "ClassDeclaration",
|
||||
"start":0,"end":84,"loc":{"start":{"line":1,"column":0},"end":{"line":7,"column":1}},
|
||||
"abstract": true,
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start":15,"end":18,"loc":{"start":{"line":1,"column":15},"end":{"line":1,"column":18},"identifierName":"Foo"},
|
||||
"name": "Foo"
|
||||
},
|
||||
"superClass": null,
|
||||
"body": {
|
||||
"type": "ClassBody",
|
||||
"start":19,"end":84,"loc":{"start":{"line":1,"column":19},"end":{"line":7,"column":1}},
|
||||
"body": [
|
||||
{
|
||||
"type": "ClassMethod",
|
||||
"start":23,"end":82,"loc":{"start":{"line":2,"column":2},"end":{"line":6,"column":3}},
|
||||
"static": false,
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start":23,"end":29,"loc":{"start":{"line":2,"column":2},"end":{"line":2,"column":8},"identifierName":"method"},
|
||||
"name": "method"
|
||||
},
|
||||
"computed": false,
|
||||
"kind": "method",
|
||||
"id": null,
|
||||
"generator": false,
|
||||
"async": false,
|
||||
"params": [],
|
||||
"body": {
|
||||
"type": "BlockStatement",
|
||||
"start":32,"end":82,"loc":{"start":{"line":2,"column":11},"end":{"line":6,"column":3}},
|
||||
"body": [
|
||||
{
|
||||
"type": "ReturnStatement",
|
||||
"start":38,"end":78,"loc":{"start":{"line":3,"column":4},"end":{"line":5,"column":5}},
|
||||
"argument": {
|
||||
"type": "ClassExpression",
|
||||
"start":45,"end":78,"loc":{"start":{"line":3,"column":11},"end":{"line":5,"column":5}},
|
||||
"id": null,
|
||||
"superClass": null,
|
||||
"body": {
|
||||
"type": "ClassBody",
|
||||
"start":51,"end":78,"loc":{"start":{"line":3,"column":17},"end":{"line":5,"column":5}},
|
||||
"body": [
|
||||
{
|
||||
"type": "TSDeclareMethod",
|
||||
"start":59,"end":72,"loc":{"start":{"line":4,"column":6},"end":{"line":4,"column":19}},
|
||||
"abstract": true,
|
||||
"static": false,
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start":68,"end":69,"loc":{"start":{"line":4,"column":15},"end":{"line":4,"column":16},"identifierName":"m"},
|
||||
"name": "m"
|
||||
},
|
||||
"computed": false,
|
||||
"kind": "method",
|
||||
"id": null,
|
||||
"generator": false,
|
||||
"async": false,
|
||||
"params": []
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
abstract class C { p = class { abstract method() } }
|
||||
@@ -0,0 +1,73 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":52,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":52}},
|
||||
"errors": [
|
||||
"SyntaxError: Abstract methods can only appear within an abstract class. (1:31)"
|
||||
],
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":52,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":52}},
|
||||
"sourceType": "module",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "ClassDeclaration",
|
||||
"start":0,"end":52,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":52}},
|
||||
"abstract": true,
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start":15,"end":16,"loc":{"start":{"line":1,"column":15},"end":{"line":1,"column":16},"identifierName":"C"},
|
||||
"name": "C"
|
||||
},
|
||||
"superClass": null,
|
||||
"body": {
|
||||
"type": "ClassBody",
|
||||
"start":17,"end":52,"loc":{"start":{"line":1,"column":17},"end":{"line":1,"column":52}},
|
||||
"body": [
|
||||
{
|
||||
"type": "ClassProperty",
|
||||
"start":19,"end":50,"loc":{"start":{"line":1,"column":19},"end":{"line":1,"column":50}},
|
||||
"static": false,
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start":19,"end":20,"loc":{"start":{"line":1,"column":19},"end":{"line":1,"column":20},"identifierName":"p"},
|
||||
"name": "p"
|
||||
},
|
||||
"computed": false,
|
||||
"value": {
|
||||
"type": "ClassExpression",
|
||||
"start":23,"end":50,"loc":{"start":{"line":1,"column":23},"end":{"line":1,"column":50}},
|
||||
"id": null,
|
||||
"superClass": null,
|
||||
"body": {
|
||||
"type": "ClassBody",
|
||||
"start":29,"end":50,"loc":{"start":{"line":1,"column":29},"end":{"line":1,"column":50}},
|
||||
"body": [
|
||||
{
|
||||
"type": "TSDeclareMethod",
|
||||
"start":31,"end":48,"loc":{"start":{"line":1,"column":31},"end":{"line":1,"column":48}},
|
||||
"abstract": true,
|
||||
"static": false,
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start":40,"end":46,"loc":{"start":{"line":1,"column":40},"end":{"line":1,"column":46},"identifierName":"method"},
|
||||
"name": "method"
|
||||
},
|
||||
"computed": false,
|
||||
"kind": "method",
|
||||
"id": null,
|
||||
"generator": false,
|
||||
"async": false,
|
||||
"params": []
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,9 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":139,"loc":{"start":{"line":1,"column":0},"end":{"line":9,"column":1}},
|
||||
"errors": [
|
||||
"SyntaxError: Abstract methods can only appear within an abstract class. (5:2)"
|
||||
],
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":139,"loc":{"start":{"line":1,"column":0},"end":{"line":9,"column":1}},
|
||||
|
||||
Reference in New Issue
Block a user