chansen / p5-time-moment

Time::Moment represents an exact moment in time.
32 stars 8 forks source link

from_object does not follow inheritance #44

Open Grinnz opened 4 years ago

Grinnz commented 4 years ago

The from_object constructor always constructs an object of class Time::Moment, regardless of what class it was called on, such as a subclass.

use strict;
use warnings;
use Time::Piece 'localtime';
use Time::Moment;
use With::Roles;
use Scalar::Util 'blessed';
print blessed(Time::Moment->with::roles('+TimeZone')->from_object(scalar localtime)); # Time::Moment

I've verified none of the other constructors have this issue.

chansen commented 1 year ago

The XS routine THX_sv_2moment_coerce_sv() could be improved to follow the inheritance.