doy / moosex-nonmoose

easy subclassing of non-Moose classes
http://metacpan.org/release/MooseX-NonMoose
9 stars 11 forks source link

The default add_method constructor in _check_superclass_constructor assumes $class is not blessed #14

Open SineSwiper opened 8 years ago

SineSwiper commented 8 years ago

Within _check_superclass_constructor, the $class variable is assumed to be an actual unblessed class all the time. This isn't always the case. It's perfectly legal to call $object->new to get a new object, and $class would then be a blessed object.

Because of this, it fails with strange error messages like:

The constructor for DBIx::Class::ResultSet returned an object whose class is not a parent of 109394. 

The isa check here relies on $class stringification, which is wrong.

SineSwiper commented 8 years ago

Okay, actually, the resulting object in this case is indeed a different class that would have failed the isa check. So, this is less severe than I thought, and is mostly an error stringification issue.