__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__);
. $self->parent->name . " doesn't subtype or coerce from a parameterizable type.");
}
-sub has_inlined_type_constraint {
+sub can_be_inlined {
my $self = shift;
return
$self->has_parameterized_from
&& $self->parameterized_from->has_inline_generator
- && $self->type_parameter->has_inlined_type_constraint;
+ && $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;
- return unless $self->has_inlined_type_constraint;
+ return unless $self->can_be_inlined;
return $self->parameterized_from->generate_inline_for( $self->type_parameter, @_ );
}