Subject: | Support inlined packages? |
Hi,
https://metacpan.org/source/PNU/DBIx-Class-Migration-0.040/lib/DBIx/Class/Migration/Types.pm defines some types in an inlined package.
This used to work when MooseX::Types was using Class::MOP. v0.37 throws a runtime error saying it can't find the package.
MooseX::Types::Combine tries to load that package using Module::Runtime. The package doesn't exist in its own file so it fails hence the error.
What do you think about supporting this?
You could use use_package_optimistically() instead of use_module() or check if the module is already loaded.
I can create a pull request if it helps
Subject: | 25_inline_packages.t |
use strict;
use warnings;
use Test::More;
pass("Loaded types from an inlined package");
done_testing();
package Types;
use base 'MooseX::Types::Combine';
__PACKAGE__->provide_types_from('InlinedPackageTypes');
package InlinedPackageTypes;
use MooseX::Types -declare => [ 'InlinedType' ];
1;
Subject: | inline-package-support.diff |
diff --git a/lib/MooseX/Types/Combine.pm b/lib/MooseX/Types/Combine.pm
index cc85815..3d95c84 100644
--- a/lib/MooseX/Types/Combine.pm
+++ b/lib/MooseX/Types/Combine.pm
@@ -88,6 +88,8 @@ sub provide_types_from {
sub _check_type_lib {
my ($class, $lib) = @_;
+ return if $lib->can('type_names'); # already loaded
+
use_module($lib);
die "Cannot use $lib in a combined type library, it does not provide any types"