Revert "Mark ThisExpression and Super as Purish" (#12307)

This commit is contained in:
Nicolò Ribaudo 2020-11-04 11:50:46 +01:00 committed by GitHub
parent 7a8c63d8db
commit dd5a977048
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 2 additions and 17 deletions

View File

@ -232,19 +232,6 @@ describe("scope", () => {
expect( expect(
getPath("String.raw`foo`").get("body")[0].get("expression").isPure(), getPath("String.raw`foo`").get("body")[0].get("expression").isPure(),
).toBeTruthy(); ).toBeTruthy();
expect(getPath("this").get("body.0.expression").isPure()).toBeTruthy();
expect(getPath("this.foo").get("body.0.expression").isPure()).toBeFalsy();
expect(
getPath("({ m() { super.foo } })")
.get("body.0.expression.properties.0.body.body.0.expression")
.isPure(),
).toBeFalsy();
expect(
// This only tests "super", not "super.foo"
getPath("({ m() { super.foo } })")
.get("body.0.expression.properties.0.body.body.0.expression.object")
.isPure(),
).toBeTruthy();
}); });
test("label", function () { test("label", function () {

View File

@ -980,7 +980,7 @@ defineType("SwitchStatement", {
}); });
defineType("ThisExpression", { defineType("ThisExpression", {
aliases: ["Expression", "Pureish"], aliases: ["Expression"],
}); });
defineType("ThrowStatement", { defineType("ThrowStatement", {
@ -1806,7 +1806,7 @@ defineType("SpreadElement", {
}); });
defineType("Super", { defineType("Super", {
aliases: ["Expression", "Pureish"], aliases: ["Expression"],
}); });
defineType("TaggedTemplateExpression", { defineType("TaggedTemplateExpression", {

View File

@ -3965,9 +3965,7 @@ export function isPureish(node: ?Object, opts?: Object): boolean {
"NullLiteral" === nodeType || "NullLiteral" === nodeType ||
"BooleanLiteral" === nodeType || "BooleanLiteral" === nodeType ||
"RegExpLiteral" === nodeType || "RegExpLiteral" === nodeType ||
"ThisExpression" === nodeType ||
"ArrowFunctionExpression" === nodeType || "ArrowFunctionExpression" === nodeType ||
"Super" === nodeType ||
"BigIntLiteral" === nodeType || "BigIntLiteral" === nodeType ||
"DecimalLiteral" === nodeType || "DecimalLiteral" === nodeType ||
(nodeType === "Placeholder" && "StringLiteral" === node.expectedNode) (nodeType === "Placeholder" && "StringLiteral" === node.expectedNode)