From 8707e537abdf31128b880578fb83c0e322564358 Mon Sep 17 00:00:00 2001 From: Mike Gerwitz Date: Mon, 26 Oct 2015 22:34:43 -0400 Subject: [PATCH] Fix protected mixin override for ES3 fallbacks It's fun when you're about to make a release and find that ES3 fallback tests are failing. That's also what happens when you decide not to run the combined tests until the last minute, because they usually don't fail. --- lib/Trait.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/Trait.js b/lib/Trait.js index 0304a6b..57f338e 100644 --- a/lib/Trait.js +++ b/lib/Trait.js @@ -740,8 +740,18 @@ function mixMethods( src, dest, vis, iname, inparent ) continue; } - var keywords = src[ f ].___$$keywords$$, - vis = keywords['protected'] ? 'protected' : 'public'; + var keywords = src[ f ].___$$keywords$$; + + // TODO: This is a kluge to handle ES3 fallbacks, which will cause + // protected members to appear on the public prototype. A more + // elegant solution is to automatically add the public keyword when + // the class is built, so we can just check if keywords[vis] exists. + if ( ( vis === 'public' ) && keywords[ 'protected' ] ) + { + continue; + } + + vis = keywords[ 'protected' ] ? 'protected' : 'public'; // if abstract, then we are expected to provide the implementation; // otherwise, we proxy to the trait's implementation