}
}
-sub has_inlined_type_constraint {
+sub can_be_inlined {
my $self = shift;
if ( $self->has_parent && $self->constraint == $null_constraint ) {
- return $self->parent->has_inlined_type_constraint;
+ return $self->parent->can_be_inlined;
}
return $self->_has_inlined_type_constraint;
sub _inline_check {
my $self = shift;
- unless ( $self->has_inlined_type_constraint ) {
+ unless ( $self->can_be_inlined ) {
require Moose;
Moose->throw_error( 'Cannot inline a type constraint check for ' . $self->name );
}
return $self->_compile_hand_optimized_type_constraint
if $self->has_hand_optimized_type_constraint;
- if ( $self->has_inlined_type_constraint ) {
+ if ( $self->can_be_inlined ) {
return eval_closure(
source => 'sub { ' . $self->_inline_check('$_[0]') . ' }',
environment => $self->inline_environment,
{
ok(
- $inlinable->has_inlined_type_constraint,
- 'Inlinable returns true for has_inlined_type_constraint'
+ $inlinable->can_be_inlined,
+ 'Inlinable returns true for can_be_inlined'
);
is(
);
ok(
- !$not_inlinable->has_inlined_type_constraint,
- 'NotInlinable returns false for has_inlined_type_constraint'
+ !$not_inlinable->can_be_inlined,
+ 'NotInlinable returns false for can_be_inlined'
);
like(
'ArrayRef[Inlinable]');
ok(
- $aofi->has_inlined_type_constraint,
- 'ArrayRef[Inlinable] returns true for has_inlined_type_constraint'
+ $aofi->can_be_inlined,
+ 'ArrayRef[Inlinable] returns true for can_be_inlined'
);
is(
'ArrayRef[NotInlinable]');
ok(
- !$aofni->has_inlined_type_constraint,
- 'ArrayRef[NotInlinable] returns false for has_inlined_type_constraint'
+ !$aofni->can_be_inlined,
+ 'ArrayRef[NotInlinable] returns false for can_be_inlined'
);
}
'ArrayOfInlinable');
ok(
- $aofi->has_inlined_type_constraint,
- 'ArrayOfInlinable returns true for has_inlined_type_constraint'
+ $aofi->can_be_inlined,
+ 'ArrayOfInlinable returns true for can_be_inlined'
);
is(
'ArrayOfNotInlinable');
ok(
- !$aofni->has_inlined_type_constraint,
- 'ArrayOfNotInlinable returns false for has_inlined_type_constraint'
+ !$aofni->can_be_inlined,
+ 'ArrayOfNotInlinable returns false for can_be_inlined'
);
}
'HashRef[ArrayRef[Inlinable]]');
ok(
- $hoaofi->has_inlined_type_constraint,
- 'HashRef[ArrayRef[Inlinable]] returns true for has_inlined_type_constraint'
+ $hoaofi->can_be_inlined,
+ 'HashRef[ArrayRef[Inlinable]] returns true for can_be_inlined'
);
is(
'HashRef[ArrayRef[NotInlinable]]');
ok(
- !$hoaofni->has_inlined_type_constraint,
- 'HashRef[ArrayRef[NotInlinable]] returns false for has_inlined_type_constraint'
+ !$hoaofni->can_be_inlined,
+ 'HashRef[ArrayRef[NotInlinable]] returns false for can_be_inlined'
);
}
'Inlinable | Object');
ok(
- $iunion->has_inlined_type_constraint,
- 'Inlinable | Object returns true for has_inlined_type_constraint'
+ $iunion->can_be_inlined,
+ 'Inlinable | Object returns true for can_be_inlined'
);
is(
'NotInlinable | Object');
ok(
- !$niunion->has_inlined_type_constraint,
- 'NotInlinable | Object returns false for has_inlined_type_constraint'
+ !$niunion->can_be_inlined,
+ 'NotInlinable | Object returns false for can_be_inlined'
);
}
'Object | Inlinable');
ok(
- $iunion->has_inlined_type_constraint,
- 'Object | Inlinable returns true for has_inlined_type_constraint'
+ $iunion->can_be_inlined,
+ 'Object | Inlinable returns true for can_be_inlined'
);
is(
'Object | NotInlinable');
ok(
- !$niunion->has_inlined_type_constraint,
- 'Object | NotInlinable returns false for has_inlined_type_constraint'
+ !$niunion->can_be_inlined,
+ 'Object | NotInlinable returns false for can_be_inlined'
);
}
'Object | Inlinable | CodeRef');
ok(
- $iunion->has_inlined_type_constraint,
- 'Object | Inlinable | CodeRef returns true for has_inlined_type_constraint'
+ $iunion->can_be_inlined,
+ 'Object | Inlinable | CodeRef returns true for can_be_inlined'
);
is(
'Object | NotInlinable | CodeRef');
ok(
- !$niunion->has_inlined_type_constraint,
- 'Object | NotInlinable | CodeRef returns false for has_inlined_type_constraint'
+ !$niunion->can_be_inlined,
+ 'Object | NotInlinable | CodeRef returns false for can_be_inlined'
);
}