make M:M:TC:Parameterized->equals("Unregistered") work
[gitmo/Moose.git] / lib / Moose / Meta / TypeConstraint / Parameterized.pm
index 09c2473..65bf696 100644 (file)
@@ -13,17 +13,19 @@ use base 'Moose::Meta::TypeConstraint';
 __PACKAGE__->meta->add_attribute('type_parameter' => (
     accessor  => 'type_parameter',
     predicate => 'has_type_parameter',
+    Class::MOP::_definition_context(),
 ));
 
 __PACKAGE__->meta->add_attribute('parameterized_from' => (
     accessor   => 'parameterized_from',
     predicate  => 'has_parameterized_from',
+    Class::MOP::_definition_context(),
 ));
 
 sub equals {
     my ( $self, $type_or_name ) = @_;
 
-    my $other = Moose::Util::TypeConstraints::find_type_constraint($type_or_name);
+    my $other = Moose::Util::TypeConstraints::find_or_create_type_constraint($type_or_name) or return;
 
     return unless $other->isa(__PACKAGE__);
 
@@ -72,6 +74,19 @@ sub can_be_inlined {
         && $self->type_parameter->can_be_inlined;
 }
 
+sub inline_environment {
+    my $self = shift;
+
+    return {
+        ($self->has_parameterized_from
+            ? (%{ $self->parameterized_from->inline_environment })
+            : ()),
+        ($self->has_type_parameter
+            ? (%{ $self->type_parameter->inline_environment })
+            : ()),
+    };
+}
+
 sub _inline_check {
     my $self = shift;