Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Optim膩s: respect noDocumentAll when transforming
obj?.#p
(#12762)
- Loading branch information
1 parent
90a674b
commit 0b1b012
Showing
12 changed files
with
659 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
122 changes: 122 additions & 0 deletions
122
...operties/test/fixtures/assumption-noDocumentAll/optional-chain-before-member-call/exec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
class Foo { | ||
static #x = 1; | ||
static #m = function() { return this.#x; }; | ||
static #self = Foo; | ||
static self = Foo; | ||
static getSelf() { return this } | ||
|
||
static test() { | ||
const o = { Foo: Foo }; | ||
const deep = { very: { o } }; | ||
function fn() { | ||
return o; | ||
} | ||
function fnDeep() { | ||
return deep; | ||
} | ||
|
||
expect(o?.Foo.#m()).toEqual(1); | ||
expect(o?.Foo.#m().toString).toEqual(1..toString); | ||
expect(o?.Foo.#m().toString()).toEqual('1'); | ||
|
||
expect(deep?.very.o?.Foo.#m()).toEqual(1); | ||
expect(deep?.very.o?.Foo.#m().toString).toEqual(1..toString); | ||
expect(deep?.very.o?.Foo.#m().toString()).toEqual('1'); | ||
|
||
expect(o?.Foo.#self.#m()).toEqual(1); | ||
expect(o?.Foo.#self.self.#m()).toEqual(1); | ||
expect(o?.Foo.#self?.self.#m()).toEqual(1); | ||
expect(o?.Foo.#self.self?.self.#m()).toEqual(1); | ||
expect(o?.Foo.#self?.self?.self.#m()).toEqual(1); | ||
|
||
expect(o?.Foo.#self.getSelf().#m()).toEqual(1); | ||
expect(o?.Foo.#self.getSelf?.().#m()).toEqual(1); | ||
expect(o?.Foo.#self?.getSelf().#m()).toEqual(1); | ||
expect(o?.Foo.#self?.getSelf?.().#m()).toEqual(1); | ||
expect(o?.Foo.#self.getSelf()?.self.#m()).toEqual(1); | ||
expect(o?.Foo.#self.getSelf?.()?.self.#m()).toEqual(1); | ||
expect(o?.Foo.#self?.getSelf()?.self.#m()).toEqual(1); | ||
expect(o?.Foo.#self?.getSelf?.()?.self.#m()).toEqual(1); | ||
|
||
expect(fn?.().Foo.#m()).toEqual(1); | ||
expect(fn?.().Foo.#m().toString).toEqual(1..toString); | ||
expect(fn?.().Foo.#m().toString()).toEqual('1'); | ||
|
||
expect(fnDeep?.().very.o?.Foo.#m()).toEqual(1); | ||
expect(fnDeep?.().very.o?.Foo.#m().toString).toEqual(1..toString); | ||
expect(fnDeep?.().very.o?.Foo.#m().toString()).toEqual('1'); | ||
|
||
expect(fn?.().Foo.#self.#m()).toEqual(1); | ||
expect(fn?.().Foo.#self.self.#m()).toEqual(1); | ||
expect(fn?.().Foo.#self?.self.#m()).toEqual(1); | ||
expect(fn?.().Foo.#self.self?.self.#m()).toEqual(1); | ||
expect(fn?.().Foo.#self?.self?.self.#m()).toEqual(1); | ||
|
||
expect(fn?.().Foo.#self.getSelf().#m()).toEqual(1); | ||
expect(fn?.().Foo.#self.getSelf?.().#m()).toEqual(1); | ||
expect(fn?.().Foo.#self?.getSelf().#m()).toEqual(1); | ||
expect(fn?.().Foo.#self?.getSelf?.().#m()).toEqual(1); | ||
expect(fn?.().Foo.#self.getSelf()?.self.#m()).toEqual(1); | ||
expect(fn?.().Foo.#self.getSelf?.()?.self.#m()).toEqual(1); | ||
expect(fn?.().Foo.#self?.getSelf()?.self.#m()).toEqual(1); | ||
expect(fn?.().Foo.#self?.getSelf?.()?.self.#m()).toEqual(1); | ||
} | ||
|
||
static testNull() { | ||
const o = null;; | ||
const deep = { very: { o } }; | ||
const fn = null; | ||
function fnDeep() { | ||
return deep; | ||
} | ||
|
||
expect(o?.Foo.#m()).toEqual(undefined); | ||
expect(o?.Foo.#m().toString).toEqual(undefined); | ||
expect(o?.Foo.#m().toString()).toEqual(undefined); | ||
|
||
expect(deep?.very.o?.Foo.#m()).toEqual(undefined); | ||
expect(deep?.very.o?.Foo.#m().toString).toEqual(undefined); | ||
expect(deep?.very.o?.Foo.#m().toString()).toEqual(undefined); | ||
|
||
expect(o?.Foo.#self.#m()).toEqual(undefined); | ||
expect(o?.Foo.#self.self.#m()).toEqual(undefined); | ||
expect(o?.Foo.#self?.self.#m()).toEqual(undefined); | ||
expect(o?.Foo.#self.self?.self.#m()).toEqual(undefined); | ||
expect(o?.Foo.#self?.self?.self.#m()).toEqual(undefined); | ||
|
||
expect(o?.Foo.#self.getSelf().#m()).toEqual(undefined); | ||
expect(o?.Foo.#self.getSelf?.().#m()).toEqual(undefined); | ||
expect(o?.Foo.#self?.getSelf().#m()).toEqual(undefined); | ||
expect(o?.Foo.#self?.getSelf?.().#m()).toEqual(undefined); | ||
expect(o?.Foo.#self.getSelf()?.self.#m()).toEqual(undefined); | ||
expect(o?.Foo.#self.getSelf?.()?.self.#m()).toEqual(undefined); | ||
expect(o?.Foo.#self?.getSelf()?.self.#m()).toEqual(undefined); | ||
expect(o?.Foo.#self?.getSelf?.()?.self.#m()).toEqual(undefined); | ||
|
||
expect(fn?.().Foo.#m()).toEqual(undefined); | ||
expect(fn?.().Foo.#m().toString).toEqual(undefined); | ||
expect(fn?.().Foo.#m().toString()).toEqual(undefined); | ||
|
||
expect(fnDeep?.().very.o?.Foo.#m()).toEqual(undefined); | ||
expect(fnDeep?.().very.o?.Foo.#m().toString).toEqual(undefined); | ||
expect(fnDeep?.().very.o?.Foo.#m().toString()).toEqual(undefined); | ||
|
||
expect(fn?.().Foo.#self.#m()).toEqual(undefined); | ||
expect(fn?.().Foo.#self.self.#m()).toEqual(undefined); | ||
expect(fn?.().Foo.#self?.self.#m()).toEqual(undefined); | ||
expect(fn?.().Foo.#self.self?.self.#m()).toEqual(undefined); | ||
expect(fn?.().Foo.#self?.self?.self.#m()).toEqual(undefined); | ||
|
||
expect(fn?.().Foo.#self.getSelf().#m()).toEqual(undefined); | ||
expect(fn?.().Foo.#self.getSelf?.().#m()).toEqual(undefined); | ||
expect(fn?.().Foo.#self?.getSelf().#m()).toEqual(undefined); | ||
expect(fn?.().Foo.#self?.getSelf?.().#m()).toEqual(undefined); | ||
expect(fn?.().Foo.#self.getSelf()?.self.#m()).toEqual(undefined); | ||
expect(fn?.().Foo.#self.getSelf?.()?.self.#m()).toEqual(undefined); | ||
expect(fn?.().Foo.#self?.getSelf()?.self.#m()).toEqual(undefined); | ||
expect(fn?.().Foo.#self?.getSelf?.()?.self.#m()).toEqual(undefined); | ||
} | ||
} | ||
|
||
Foo.test(); | ||
Foo.testNull(); |
66 changes: 66 additions & 0 deletions
66
...perties/test/fixtures/assumption-noDocumentAll/optional-chain-before-member-call/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
class Foo { | ||
static #x = 1; | ||
static #m = function() { return this.#x; }; | ||
static #self = Foo; | ||
static self = Foo; | ||
static getSelf() { return this } | ||
|
||
static test() { | ||
const o = { Foo: Foo }; | ||
const deep = { very: { o } }; | ||
function fn() { | ||
return o; | ||
} | ||
function fnDeep() { | ||
return deep; | ||
} | ||
|
||
o?.Foo.#m(); | ||
o?.Foo.#m().toString; | ||
o?.Foo.#m().toString(); | ||
|
||
deep?.very.o?.Foo.#m(); | ||
deep?.very.o?.Foo.#m().toString; | ||
deep?.very.o?.Foo.#m().toString(); | ||
|
||
o?.Foo.#self.#m(); | ||
o?.Foo.#self.self.#m(); | ||
o?.Foo.#self?.self.#m(); | ||
o?.Foo.#self.self?.self.#m(); | ||
o?.Foo.#self?.self?.self.#m(); | ||
|
||
o?.Foo.#self.getSelf().#m(); | ||
o?.Foo.#self.getSelf?.().#m(); | ||
o?.Foo.#self?.getSelf().#m(); | ||
o?.Foo.#self?.getSelf?.().#m(); | ||
o?.Foo.#self.getSelf()?.self.#m(); | ||
o?.Foo.#self.getSelf?.()?.self.#m(); | ||
o?.Foo.#self?.getSelf()?.self.#m(); | ||
o?.Foo.#self?.getSelf?.()?.self.#m(); | ||
|
||
fn?.().Foo.#m(); | ||
fn?.().Foo.#m().toString; | ||
fn?.().Foo.#m().toString(); | ||
|
||
fnDeep?.().very.o?.Foo.#m(); | ||
fnDeep?.().very.o?.Foo.#m().toString; | ||
fnDeep?.().very.o?.Foo.#m().toString(); | ||
|
||
fn?.().Foo.#self.#m(); | ||
fn?.().Foo.#self.self.#m(); | ||
fn?.().Foo.#self?.self.#m(); | ||
fn?.().Foo.#self.self?.self.#m(); | ||
fn?.().Foo.#self?.self?.self.#m(); | ||
|
||
fn?.().Foo.#self.getSelf().#m(); | ||
fn?.().Foo.#self.getSelf?.().#m(); | ||
fn?.().Foo.#self?.getSelf().#m(); | ||
fn?.().Foo.#self?.getSelf?.().#m(); | ||
fn?.().Foo.#self.getSelf()?.self.#m(); | ||
fn?.().Foo.#self.getSelf?.()?.self.#m(); | ||
fn?.().Foo.#self?.getSelf()?.self.#m(); | ||
fn?.().Foo.#self?.getSelf?.()?.self.#m(); | ||
} | ||
} | ||
|
||
Foo.test(); |
4 changes: 4 additions & 0 deletions
4
...ies/test/fixtures/assumption-noDocumentAll/optional-chain-before-member-call/options.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"plugins": ["proposal-class-properties"], | ||
"minNodeVersion": "14.0.0" | ||
} |
Oops, something went wrong.