Permalink
Browse files

Enable aliased traits to be processed

Conflicts:

	t/lib/TestClassTrait.pm
  • Loading branch information...
1 parent fb2ba40 commit 724eea10583e307070b831c83d9c8ed81c0d4205 @rafl committed Jul 28, 2009
Showing with 20 additions and 7 deletions.
  1. +13 −0 lib/MooseX/Method/Signatures.pm
  2. +7 −7 t/lib/TestClassTrait.pm
@@ -146,6 +146,19 @@ sub strip_traits {
confess "expected traits after 'is', found nothing"
unless scalar(@traits);
+ # Let's check to make sure these traits aren't aliased locally
+ for my $t (@traits) {
+ my $class = $ctx->get_curstash_name;
+ my $meta = Class::MOP::class_of($class) || Moose::Meta::Class->initialize($class);
+ my $func = $meta->get_package_symbol('&' . $t->[0]);
+ next unless $func;
+
+ my $proto = prototype $func;
+ next if !defined $proto || length $proto;
+
+ $t->[0] = $func->();
+ }
+
return \@traits;
}
View
@@ -2,23 +2,23 @@ package TestClassTrait;
use Moose;
use MooseX::Method::Signatures;
-use MXMSMoody;
-use MXMSLabeled;
+use aliased 'MXMSLabeled', 'Label';
+use aliased 'MXMSMoody', 'Moody';
-method method_with_trait (Str :$name!) is MXMSMoody {
+method method_with_trait (Str :$name!) is Moody {
return 1;
}
-method method_with_two_traits () is (MXMSMoody, MXMSLabeled) {
+method method_with_two_traits () is (Moody, Label) {
return 1;
}
-method method_with_two_is_traits () is MXMSMoody is MXMSLabeled {
+method method_with_two_is_traits () is Moody is Label {
return 1;
}
-method method_with_two_is_param_traits () is MXMSMoody
- is MXMSLabeled(label => 'happy') {
+method method_with_two_is_param_traits () is Moody
+ is Label(label => 'happy') {
return 1;
}

0 comments on commit 724eea1

Please sign in to comment.