Subject: | MooseTypes / ClassName is incorrect in perl 5.17 |
In perl 5.17, type "ClassName" in MooseTypes will return always true.
This is because the meaning of UNIVERSAL::can($scalar, 'can') has
changed (see https://rt.perl.org/rt3/Public/Bug/Display.html?id=47113).
I found this because I had a similar problem in Data::Domain and wanted
to see how others solved it.
Moose's solution goes through Class::Load::is_class_loaded, which is
true if the package has a $VERSION, or has an @ISA, or has at least one
method. It makes sense, but doesn't allow for an empty class.
Another way (this is what I chose for Data::Domain) is to test for
$scalar->isa($scalar) : this will be true if $scalar is a package,
false otherwise (and this behaviour is kept consistent in 5.17).