Implemented GH#3 Abstract keyword cannot be used with private members
parent
b8e512c69e
commit
8a3010c964
|
@ -77,6 +77,15 @@ exports.buildMethod = function(
|
|||
var prev_data = scanMembers( members, name, base ),
|
||||
prev = ( prev_data ) ? prev_data.member : null;
|
||||
|
||||
// do not permit private abstract methods (doesn't make sense, since
|
||||
// they cannot be inherited/overridden)
|
||||
if ( keywords[ 'abstract' ] && keywords[ 'private' ] )
|
||||
{
|
||||
throw TypeError(
|
||||
"Method '" + name + "' cannot be both private and abstract"
|
||||
);
|
||||
}
|
||||
|
||||
// search for any previous instances of this member
|
||||
if ( prev )
|
||||
{
|
||||
|
|
|
@ -276,3 +276,18 @@ mb_common.assertCommon();
|
|||
);
|
||||
} )();
|
||||
|
||||
|
||||
/**
|
||||
* It does not make sense to be able to declare abstract private methods, since
|
||||
* they cannot be inherited and overridden by subtypes.
|
||||
*/
|
||||
( function testCannotDeclareAbstractPrivateMethods()
|
||||
{
|
||||
mb_common.value = function() {};
|
||||
|
||||
assert.throws( function()
|
||||
{
|
||||
mb_common.buildMemberQuick( { 'private': true, 'abstract': true } );
|
||||
}, TypeError, "Cannot declare private abstract method" );
|
||||
} )();
|
||||
|
||||
|
|
Loading…
Reference in New Issue