Skip to content

Commit

Permalink
Also for brand checks
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolo-ribaudo committed Apr 22, 2021
1 parent 24ed392 commit 6b14bdc
Show file tree
Hide file tree
Showing 18 changed files with 30 additions and 26 deletions.
Expand Up @@ -17,7 +17,7 @@
"babel-plugin"
],
"dependencies": {
"@babel/helper-compilation-targets": "workspace:^7.12.17",
"@babel/helper-annotate-as-pure": "workspace:^7.12.13",
"@babel/helper-create-class-features-plugin": "workspace:^7.13.0",
"@babel/helper-plugin-utils": "workspace:^7.13.0",
"@babel/plugin-syntax-private-property-in-object": "workspace:^7.13.0"
Expand Down
Expand Up @@ -5,6 +5,7 @@ import {
FEATURES,
injectInitialization as injectConstructorInit,
} from "@babel/helper-create-class-features-plugin";
import annotateAsPure from "@babel/helper-annotate-as-pure";

export default declare(({ assertVersion, types: t, template }, { loose }) => {
assertVersion(7);
Expand Down Expand Up @@ -72,7 +73,10 @@ export default declare(({ assertVersion, types: t, template }, { loose }) => {

inject(reference, template.expression.ast`${t.cloneNode(id)}.add(this)`);

outerClass.insertBefore(template.ast`var ${id} = new WeakSet()`);
const newExpr = t.newExpression(t.identifier("WeakSet"), []);
annotateAsPure(newExpr);

outerClass.insertBefore(template.ast`var ${id} = ${newExpr}`);
}

return t.cloneNode(id);
Expand Down
@@ -1,4 +1,4 @@
var _FooBrandCheck = new WeakSet();
var _FooBrandCheck = /*#__PURE__*/new WeakSet();

class Foo {
constructor() {
Expand Down
@@ -1,7 +1,7 @@
(x = (() => {
var _fooBrandCheck;

return _fooBrandCheck = new WeakSet(), class {
return _fooBrandCheck = /*#__PURE__*/new WeakSet(), class {
#foo = void _fooBrandCheck.add(this);

test(other) {
Expand Down
@@ -1,7 +1,7 @@
function fn() {
var _privBrandCheck;

return new (_privBrandCheck = new WeakSet(), class {
return new (_privBrandCheck = /*#__PURE__*/new WeakSet(), class {
#priv = void _privBrandCheck.add(this);

method(obj) {
Expand Down
@@ -1,7 +1,7 @@
function fn() {
var _privBrandCheck;

return new (_privBrandCheck = new WeakSet(), class {
return new (_privBrandCheck = /*#__PURE__*/new WeakSet(), class {
static #priv = void _privBrandCheck.add(this);

method(obj) {
Expand Down
@@ -1,6 +1,6 @@
var _temp;

var _fooBrandCheck = new WeakSet();
var _fooBrandCheck = /*#__PURE__*/new WeakSet();

class Foo {
#foo = (_temp = 1, _fooBrandCheck.add(this), _temp);
Expand Down
@@ -1,10 +1,10 @@
var _temp, _temp2;

var _FBrandCheck = new WeakSet();
var _FBrandCheck = /*#__PURE__*/new WeakSet();

var _xBrandCheck = new WeakSet();
var _xBrandCheck = /*#__PURE__*/new WeakSet();

var _yBrandCheck = new WeakSet();
var _yBrandCheck = /*#__PURE__*/new WeakSet();

class F {
m() {
Expand Down
@@ -1,8 +1,8 @@
var _temp, _temp2;

var _xBrandCheck = new WeakSet();
var _xBrandCheck = /*#__PURE__*/new WeakSet();

var _yBrandCheck = new WeakSet();
var _yBrandCheck = /*#__PURE__*/new WeakSet();

class F {
static m() {
Expand Down
@@ -1,4 +1,4 @@
var _FooBrandCheck = new WeakSet();
var _FooBrandCheck = /*#__PURE__*/new WeakSet();

class Foo {
constructor() {
Expand Down
@@ -1,6 +1,6 @@
var _xBrandCheck = new WeakSet();
var _xBrandCheck = /*#__PURE__*/new WeakSet();

var _ABrandCheck = new WeakSet();
var _ABrandCheck = /*#__PURE__*/new WeakSet();

class A {
#x = (_ABrandCheck.add(this), void _xBrandCheck.add(this));
Expand Down
@@ -1,8 +1,8 @@
var _temp, _temp3;

var _fooBrandCheck = new WeakSet();
var _fooBrandCheck = /*#__PURE__*/new WeakSet();

var _barBrandCheck2 = new WeakSet();
var _barBrandCheck2 = /*#__PURE__*/new WeakSet();

class Foo {
#foo = (_temp = 1, _fooBrandCheck.add(this), _temp);
Expand All @@ -11,7 +11,7 @@ class Foo {
test() {
var _temp2;

var _barBrandCheck = new WeakSet();
var _barBrandCheck = /*#__PURE__*/new WeakSet();

class Nested {
#bar = (_temp2 = 2, _barBrandCheck.add(this), _temp2);
Expand Down
@@ -1,14 +1,14 @@
var _temp2;

var _fooBrandCheck2 = new WeakSet();
var _fooBrandCheck2 = /*#__PURE__*/new WeakSet();

class Foo {
#foo = (_temp2 = 1, _fooBrandCheck2.add(this), _temp2);

test() {
var _temp;

var _fooBrandCheck = new WeakSet();
var _fooBrandCheck = /*#__PURE__*/new WeakSet();

class Nested {
#foo = (_temp = 2, _fooBrandCheck.add(this), _temp);
Expand Down
@@ -1,6 +1,6 @@
var _temp;

var _fooBrandCheck = new WeakSet();
var _fooBrandCheck = /*#__PURE__*/new WeakSet();

class Foo {
#foo = (_temp = 1, _fooBrandCheck.add(this), _temp);
Expand Down
@@ -1,6 +1,6 @@
var _temp;

var _fooBrandCheck = new WeakSet();
var _fooBrandCheck = /*#__PURE__*/new WeakSet();

class Foo {
static #foo = (_temp = 1, _fooBrandCheck.add(this), _temp);
Expand Down
@@ -1,4 +1,4 @@
var _fooBrandCheck = new WeakSet();
var _fooBrandCheck = /*#__PURE__*/new WeakSet();

class A {
static #foo = void _fooBrandCheck.add(this);
Expand Down
@@ -1,4 +1,4 @@
var _fooBrandCheck = new WeakSet();
var _fooBrandCheck = /*#__PURE__*/new WeakSet();

class A {
#foo = void _fooBrandCheck.add(this);
Expand Down
4 changes: 2 additions & 2 deletions yarn.lock
Expand Up @@ -393,7 +393,7 @@ __metadata:
languageName: node
linkType: hard

"@babel/helper-compilation-targets@workspace:^7.12.17, @babel/helper-compilation-targets@workspace:^7.13.13, @babel/helper-compilation-targets@workspace:^7.13.16, @babel/helper-compilation-targets@workspace:^7.13.8, @babel/helper-compilation-targets@workspace:packages/babel-helper-compilation-targets":
"@babel/helper-compilation-targets@workspace:^7.13.13, @babel/helper-compilation-targets@workspace:^7.13.16, @babel/helper-compilation-targets@workspace:^7.13.8, @babel/helper-compilation-targets@workspace:packages/babel-helper-compilation-targets":
version: 0.0.0-use.local
resolution: "@babel/helper-compilation-targets@workspace:packages/babel-helper-compilation-targets"
dependencies:
Expand Down Expand Up @@ -1440,7 +1440,7 @@ __metadata:
resolution: "@babel/plugin-proposal-private-property-in-object@workspace:packages/babel-plugin-proposal-private-property-in-object"
dependencies:
"@babel/core": "workspace:*"
"@babel/helper-compilation-targets": "workspace:^7.12.17"
"@babel/helper-annotate-as-pure": "workspace:^7.12.13"
"@babel/helper-create-class-features-plugin": "workspace:^7.13.0"
"@babel/helper-plugin-test-runner": "workspace:*"
"@babel/helper-plugin-utils": "workspace:^7.13.0"
Expand Down

0 comments on commit 6b14bdc

Please sign in to comment.