diff --git a/lib/MemberBuilder.js b/lib/MemberBuilder.js index 547606b..f7891d3 100644 --- a/lib/MemberBuilder.js +++ b/lib/MemberBuilder.js @@ -28,11 +28,8 @@ * @package core */ -var util = require( __dirname + '/util' ), - - Warning = require( __dirname + '/warn' ).Warning, - - fallback = util.definePropertyFallback(), +var util = require( __dirname + '/util' ), + Warning = require( __dirname + '/warn' ).Warning, visibility = [ 'public', 'protected', 'private' ] ; @@ -244,7 +241,9 @@ exports._validateMethod = function( } // do not permit visibility deescalation - if ( prev_data.visibility < this._getVisibilityValue( keywords ) ) + if ( this._getVisibilityValue( prev_keywords ) < + this._getVisibilityValue( keywords ) + ) { throw TypeError( "Cannot de-escalate visibility of method '" + name + "'" @@ -311,7 +310,9 @@ exports.buildProp = function( members, meta, name, value, keywords, base ) // do not permit visibility de-escalation if ( prev && - ( prev_data.visibility < this._getVisibilityValue( keywords ) ) + ( this._getVisibilityValue( prev[ 1 ] ) + < this._getVisibilityValue( keywords ) + ) ) { throw TypeError( @@ -521,7 +522,6 @@ function scanMembers( members, name, base ) get: member.get, set: member.set, member: member.value, - visibility: ( ( fallback ) ? 0 : i ), }; } } @@ -613,12 +613,7 @@ exports._overrideMethod = function( */ exports._getVisibilityValue = function( keywords ) { - if ( fallback ) - { - // if we have to fall back, we don't support levels of visibility - return 0; - } - else if ( keywords[ 'protected' ] ) + if ( keywords[ 'protected' ] ) { return 1; } diff --git a/test/test-class-visibility.js b/test/test-class-visibility.js index e26ef5c..795cda7 100644 --- a/test/test-class-visibility.js +++ b/test/test-class-visibility.js @@ -524,8 +524,6 @@ var common = require( './common' ), }, Error, "Can escalate visibility of subtype members" ); // same level of visibility - assert.doesNotThrow( function() - { Class( { 'protected foo': 'bar', @@ -534,7 +532,6 @@ var common = require( './common' ), 'protected foo': 'bar', 'override protected baz': function() {}, } ); - }, Error, "Can retain level of visibility for subtype members" ); } )();