This file is indexed.

/usr/share/perl5/Moo/HandleMoose.pm is in libmoo-perl 1.006001-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
package Moo::HandleMoose;

use strictures 1;
use Moo::_Utils;
use Sub::Quote qw(quotify);

our %TYPE_MAP;

our $SETUP_DONE;

sub import { return if $SETUP_DONE; inject_all(); $SETUP_DONE = 1; }

sub inject_all {
  require Class::MOP;
  inject_fake_metaclass_for($_)
    for grep $_ ne 'Moo::Object', do { no warnings 'once'; keys %Moo::MAKERS };
  inject_fake_metaclass_for($_) for keys %Moo::Role::INFO;
  require Moose::Meta::Method::Constructor;
  @Moo::HandleMoose::FakeConstructor::ISA = 'Moose::Meta::Method::Constructor';
}

sub maybe_reinject_fake_metaclass_for {
  my ($name) = @_;
  our %DID_INJECT;
  if (delete $DID_INJECT{$name}) {
    unless ($Moo::Role::INFO{$name}) {
      Moo->_constructor_maker_for($name)->install_delayed;
    }
    inject_fake_metaclass_for($name);
  }
}

sub inject_fake_metaclass_for {
  my ($name) = @_;
  require Class::MOP;
  require Moo::HandleMoose::FakeMetaClass;
  Class::MOP::store_metaclass_by_name(
    $name, bless({ name => $name }, 'Moo::HandleMoose::FakeMetaClass')
  );
  require Moose::Util::TypeConstraints;
  if ($Moo::Role::INFO{$name}) {
    Moose::Util::TypeConstraints::find_or_create_does_type_constraint($name);
  } else {
    Moose::Util::TypeConstraints::find_or_create_isa_type_constraint($name);
  }
}

{
  package Moo::HandleMoose::FakeConstructor;

  sub _uninlined_body { \&Moose::Object::new }
}

sub inject_real_metaclass_for {
  my ($name) = @_;
  our %DID_INJECT;
  return Class::MOP::get_metaclass_by_name($name) if $DID_INJECT{$name};
  require Moose; require Moo; require Moo::Role; require Scalar::Util;
  Class::MOP::remove_metaclass_by_name($name);
  my ($am_role, $meta, $attr_specs, $attr_order) = do {
    if (my $info = $Moo::Role::INFO{$name}) {
      my @attr_info = @{$info->{attributes}||[]};
      (1, Moose::Meta::Role->initialize($name),
       { @attr_info },
       [ @attr_info[grep !($_ % 2), 0..$#attr_info] ]
      )
    } elsif ( my $cmaker = Moo->_constructor_maker_for($name) ) {
      my $specs = $cmaker->all_attribute_specs;
      (0, Moose::Meta::Class->initialize($name), $specs,
       [ sort { $specs->{$a}{index} <=> $specs->{$b}{index} } keys %$specs ]
      );
    } else {
       # This codepath is used if $name does not exist in $Moo::MAKERS
       (0, Moose::Meta::Class->initialize($name), {}, [] )
    }
  };

  for my $spec (values %$attr_specs) {
    if (my $inflators = delete $spec->{moosify}) {
      $_->($spec) for @$inflators;
    }
  }

  my %methods
    = %{($am_role ? 'Moo::Role' : 'Moo')->_concrete_methods_of($name)};

  # if stuff gets added afterwards, _maybe_reset_handlemoose should
  # trigger the recreation of the metaclass but we need to ensure the
  # Moo::Role cache is cleared so we don't confuse Moo itself.
  if (my $info = $Moo::Role::INFO{$name}) {
    delete $info->{methods};
  }

  # needed to ensure the method body is stable and get things named
  Sub::Defer::undefer_sub($_) for grep defined, values %methods;
  my @attrs;
  {
    # This local is completely not required for roles but harmless
    local @{_getstash($name)}{keys %methods};
    my %seen_name;
    foreach my $name (@$attr_order) {
      $seen_name{$name} = 1;
      my %spec = %{$attr_specs->{$name}};
      my %spec_map = (
        map { $_->name => $_->init_arg||$_->name }
        (
          (grep { $_->has_init_arg }
             $meta->attribute_metaclass->meta->get_all_attributes),
          grep { exists($_->{init_arg}) ? defined($_->init_arg) : 1 }
          map {
            my $meta = Moose::Util::resolve_metatrait_alias('Attribute', $_)
                         ->meta;
            map $meta->get_attribute($_), $meta->get_attribute_list
          }  @{$spec{traits}||[]}
        )
      );
      # have to hard code this because Moose's role meta-model is lacking
      $spec_map{traits} ||= 'traits';

      $spec{is} = 'ro' if $spec{is} eq 'lazy' or $spec{is} eq 'rwp';
      my $coerce = $spec{coerce};
      if (my $isa = $spec{isa}) {
        my $tc = $spec{isa} = do {
          if (my $mapped = $TYPE_MAP{$isa}) {
            my $type = $mapped->();
            unless ( Scalar::Util::blessed($type)
                && $type->isa("Moose::Meta::TypeConstraint") ) {
              die "error inflating attribute '$name' for package '$_[0]': "
                ."\$TYPE_MAP{$isa} did not return a valid type constraint'";
            }
            $coerce ? $type->create_child_type(name => $type->name) : $type;
          } else {
            Moose::Meta::TypeConstraint->new(
              constraint => sub { eval { &$isa; 1 } }
            );
          }
        };
        if ($coerce) {
          $tc->coercion(Moose::Meta::TypeCoercion->new)
             ->_compiled_type_coercion($coerce);
          $spec{coerce} = 1;
        }
      } elsif ($coerce) {
        my $attr = quotify($name);
        my $tc = Moose::Meta::TypeConstraint->new(
                   constraint => sub { die "This is not going to work" },
                   inlined => sub {
                      'my $r = $_[42]{'.$attr.'}; $_[42]{'.$attr.'} = 1; $r'
                   },
                 );
        $tc->coercion(Moose::Meta::TypeCoercion->new)
           ->_compiled_type_coercion($coerce);
        $spec{isa} = $tc;
        $spec{coerce} = 1;
      }
      %spec =
        map { $spec_map{$_} => $spec{$_} }
        grep { exists $spec_map{$_} }
        keys %spec;
      push @attrs, $meta->add_attribute($name => %spec);
    }
    foreach my $mouse (do { our %MOUSE; @{$MOUSE{$name}||[]} }) {
      foreach my $attr ($mouse->get_all_attributes) {
        my %spec = %{$attr};
        delete @spec{qw(
          associated_class associated_methods __METACLASS__
          provides curries
        )};
        my $name = delete $spec{name};
        next if $seen_name{$name}++;
        push @attrs, $meta->add_attribute($name => %spec);
      }
    }
  }
  for my $meth_name (keys %methods) {
    my $meth_code = $methods{$meth_name};
    $meta->add_method($meth_name, $meth_code) if $meth_code;
  }

  if ($am_role) {
    my $info = $Moo::Role::INFO{$name};
    $meta->add_required_methods(@{$info->{requires}});
    foreach my $modifier (@{$info->{modifiers}}) {
      my ($type, @args) = @$modifier;
      my $code = pop @args;
      $meta->${\"add_${type}_method_modifier"}($_, $code) for @args;
    }
  } else {
    foreach my $attr (@attrs) {
      foreach my $method (@{$attr->associated_methods}) {
        $method->{body} = $name->can($method->name);
      }
    }
    bless(
      $meta->find_method_by_name('new'),
      'Moo::HandleMoose::FakeConstructor',
    );
    # a combination of Moo and Moose may bypass a Moo constructor but still
    # use a Moo DEMOLISHALL.  We need to make sure this is loaded before
    # global destruction.
    require Method::Generate::DemolishAll;
  }
  $meta->add_role(Class::MOP::class_of($_))
    for grep !/\|/ && $_ ne $name, # reject Foo|Bar and same-role-as-self
      do { no warnings 'once'; keys %{$Moo::Role::APPLIED_TO{$name}} };
  $DID_INJECT{$name} = 1;
  $meta;
}

1;