my $self = shift;
my $attr = $self->associated_attribute;
- return try {
+ my $RuNNeR; return bless sub { if (!defined($RuNNeR)) { $RuNNeR = try {
$self->_compile_code([
'sub {',
'if (@_ > 1) {',
catch {
confess "Could not generate inline accessor because : $_";
};
+ return $RuNNeR if !defined($_[0]) && ref($_[1]) && ref($_[1]) eq 'RuNNeR'}; goto $RuNNeR},'RuNNeR';
}
sub _generate_reader_method {
my $self = shift;
my $attr = $self->associated_attribute;
- return try {
+ my $RuNNeR; return bless sub { if (!defined($RuNNeR)) { $RuNNeR = try {
$self->_compile_code([
'sub {',
'if (@_ > 1) {',
catch {
confess "Could not generate inline reader because : $_";
};
+ return $RuNNeR if !defined($_[0]) && ref($_[1]) && ref($_[1]) eq 'RuNNeR'}; goto $RuNNeR},'RuNNeR';
}
sub _inline_throw_error {
my $self = shift;
my $attr = $self->associated_attribute;
- return try {
+ my $RuNNeR; return bless sub { if (!defined($RuNNeR)) { $RuNNeR = try {
$self->_compile_code([
'sub {',
$attr->_inline_set_value('$_[0]', '$_[1]'),
catch {
confess "Could not generate inline writer because : $_";
};
+ return $RuNNeR if !defined($_[0]) && ref($_[1]) && ref($_[1]) eq 'RuNNeR'}; goto $RuNNeR},'RuNNeR';
}
sub _generate_predicate_method {
my $self = shift;
my $attr = $self->associated_attribute;
- return try {
+ my $RuNNeR; return bless sub { if (!defined($RuNNeR)) { $RuNNeR = try {
$self->_compile_code([
'sub {',
$attr->_inline_has_value('$_[0]'),
catch {
confess "Could not generate inline predicate because : $_";
};
+ return $RuNNeR if !defined($_[0]) && ref($_[1]) && ref($_[1]) eq 'RuNNeR'}; goto $RuNNeR},'RuNNeR';
}
sub _generate_clearer_method {
my $self = shift;
my $attr = $self->associated_attribute;
- return try {
+ my $RuNNeR; return bless sub { if (!defined($RuNNeR)) { $RuNNeR = try {
$self->_compile_code([
'sub {',
$attr->_inline_clear_value('$_[0]'),
catch {
confess "Could not generate inline clearer because : $_";
};
+ return $RuNNeR if !defined($_[0]) && ref($_[1]) && ref($_[1]) eq 'RuNNeR'}; goto $RuNNeR},'RuNNeR';
}
1;
warn join("\n", @source) if $self->options->{debug};
- my $code = try {
+ my $RuNNeR; my $code = bless sub { if (!defined($RuNNeR)) { $RuNNeR = try {
$self->_compile_code(\@source);
}
catch {
my $source = join("\n", @source);
confess "Could not eval the constructor :\n\n$source\n\nbecause :\n\n$_";
};
+ return $RuNNeR if !defined($_[0]) && ref($_[1]) && ref($_[1]) eq 'RuNNeR'}; goto $RuNNeR},'RuNNeR';
return $code;
}
sub _is_okay_to_close_over {
my $self = shift;
my ($thing) = @_;
+ return 1 if ref($thing) eq 'RuNNeR';
match_on_type $thing => (
'RegexpRef' => sub { 1 },
my ($package, $method) = @_;
my $visitor = Test::Visitor->new;
my $code = $package->meta->find_method_by_name($method)->body;
+ $code = $code->(undef, $code) if ref($code) eq 'RuNNeR';
$visitor->visit($code);
if ($visitor->pass) {
pass("${package}::${method} didn't close over anything complicated");