1
0
Fork 0

Correct Trait#__inst in ES3 environments

The previous commit's test case failed in ES3 environments.  I'd amend that
commit, but Savannah refuses force pushes, and I can't work around that on
`master'.

* lib/Trait.js (tctor): Assign `__inst' to the public visibility object
  rather than `vis'.
master
Mike Gerwitz 2017-11-04 00:34:00 -04:00
parent 5c3b7ab042
commit 55f47a3c5a
Signed by: mikegerwitz
GPG Key ID: 8C917B7F5DC51BA2
1 changed files with 8 additions and 2 deletions

View File

@ -947,10 +947,16 @@ function tctor( tc, base, privsym )
// (but not private); in return, we will use its own protected
// visibility object to gain access to its protected members...quite
// the intimate relationship
this[ f ] = C( base, this[ privsym ].vis )[ privsym ].vis;
var tinst = C( base, this[ privsym ].vis );
this[ f ] = tinst[ privsym ].vis;
// TODO: this should use util.defineSecureProp
this[ f ].__inst = this[ privsym ].inst;
// we set __inst on the trait object itself (public visibility
// object, which is okay, since the trait is encapsulated anyway)
// because otherwise, in the case of an ES3 fallback, `vis' will be
// affected by __inst defined on `base', leading to a fight over
// ownership that I spent too much time trying to figure out
tinst.__inst = this[ privsym ].inst;
// rebind trait's supertype context (if any) to our own, causing us
// to share state