Skip to content

Commit

Permalink
Fix: PrivateName Identifier should not be isReferenced. (#9861)
Browse files Browse the repository at this point in the history
  • Loading branch information
coreyfarrell authored and existentialism committed Apr 16, 2019
1 parent 66be4aa commit 8ca99b9
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 6 deletions.
Expand Up @@ -3,7 +3,7 @@ var Point =
function () {
"use strict";

function Point(_x2 = 0, _y2 = 0) {
function Point(x = 0, y = 0) {
babelHelpers.classCallCheck(this, Point);
Object.defineProperty(this, _x, {
writable: true,
Expand All @@ -13,8 +13,8 @@ function () {
writable: true,
value: void 0
});
babelHelpers.classPrivateFieldLooseBase(this, _x)[_x] = +_x2;
babelHelpers.classPrivateFieldLooseBase(this, _y)[_y] = +_y2;
babelHelpers.classPrivateFieldLooseBase(this, _x)[_x] = +x;
babelHelpers.classPrivateFieldLooseBase(this, _y)[_y] = +y;
}

babelHelpers.createClass(Point, [{
Expand Down
Expand Up @@ -3,7 +3,7 @@ var Point =
function () {
"use strict";

function Point(_x2 = 0, _y2 = 0) {
function Point(x = 0, y = 0) {
babelHelpers.classCallCheck(this, Point);

_x.set(this, {
Expand All @@ -16,8 +16,8 @@ function () {
value: void 0
});

babelHelpers.classPrivateFieldSet(this, _x, +_x2);
babelHelpers.classPrivateFieldSet(this, _y, +_y2);
babelHelpers.classPrivateFieldSet(this, _x, +x);
babelHelpers.classPrivateFieldSet(this, _y, +y);
}

babelHelpers.createClass(Point, [{
Expand Down
@@ -0,0 +1,14 @@
import {test1, test2, test3, test4, test5, test6, test7, test8, test9} from 'anywhere';

class Example {
#test1 = test1;
test2 = test2;
#test3() { return test3; }
test4() { return test4; }
get #test5() { return test5; }
get test6() { return test6; }

#test7 = this.#test1;
#test8() { return this.#test3(); }
get #test9() { return this.#test5(); }
}
@@ -0,0 +1,35 @@
"use strict";

var _anywhere = require("anywhere");

class Example {
#test1 = _anywhere.test1;
test2 = _anywhere.test2;

#test3() {
return _anywhere.test3;
}

test4() {
return _anywhere.test4;
}

get #test5() {
return _anywhere.test5;
}

get test6() {
return _anywhere.test6;
}

#test7 = this.#test1;

#test8() {
return this.#test3();
}

get #test9() {
return this.#test5();
}

}
7 changes: 7 additions & 0 deletions packages/babel-types/src/validators/isReferenced.js
Expand Up @@ -38,6 +38,13 @@ export default function isReferenced(
}
return parent.local === node;

// no: class { #NODE; }
// no: class { get #NODE() {} }
// no: class { #NODE() {} }
// no: class { fn() { return this.#NODE; } }
case "PrivateName":
return false;

// yes: { [NODE]: "" }
// no: { NODE: "" }
// depends: { NODE }
Expand Down

0 comments on commit 8ca99b9

Please sign in to comment.