<commit_before>my class Pair does Associative {
    has $.key is default(Nil);
    has $.value is rw is default(Nil);
    has ObjAt $!WHICH;

    proto method new(|) {*}
    # This candidate is needed because it currently JITs better
    multi method new(Pair: Str:D $key, Mu \value) {
        my \p := nqp::p6bindattrinvres(
          nqp::create(self),Pair,'$!key',$key);
        nqp::bindattr(p,Pair,'$!value',value);
        p
    }
    multi method new(Pair: Mu \key, Mu \value) {
        my \p := nqp::p6bindattrinvres(
          nqp::create(self),Pair,'$!key',nqp::decont(key));
        nqp::bindattr(p,Pair,'$!value',value);
        p
    }
    multi method new(Pair: Mu :$key!, Mu :$value!) {
        my \p := nqp::p6bindattrinvres(
          nqp::create(self),Pair,'$!key',$key);
        nqp::bindattr(p,Pair,'$!value',$value);
        p
    }

    multi method clone(Pair:D:) {
        nqp::p6bindattrinvres(self.Mu::clone, Pair, '$!WHICH', nqp::null)
    }
    multi method WHICH(Pair:D: --> ObjAt:D) {
        nqp::isconcrete($!WHICH) ?? $!WHICH !! self!WHICH
    }

    method !WHICH() {
        $!WHICH := nqp::if(
          nqp::iscont($!value)
            || nqp::not_i(nqp::istype((my $VALUE := $!value.WHICH),ValueObjAt)),
          self.Mu::WHICH,
          nqp::box_s(
            nqp::concat(
              nqp::if(
                nqp::eqaddr(self.WHAT,Pair),
                'Pair|',
                nqp::concat(self.^name,'|')
              ),
              nqp::sha1(nqp::concat(nqp::concat($!key.WHICH,"\0"),$VALUE))
            ),
            ValueObjAt
          )
        )
    }

    multi method ACCEPTS(Pair:D: %h) {
        $!value.ACCEPTS(%h.AT-KEY($!key));
    }
    multi method ACCEPTS(Pair:D: Pair:D $p) {
        $!value.ACCEPTS(nqp::getattr($p,Pair,'$!value'));
    }
    multi method ACCEPTS(Pair:D: Mu $other) {
        nqp::can($other,(my $method := $!key.Str))
          ?? ($other."$method"().Bool === $!value.Bool)
          !! X::Method::NotFound.new(<commit_msg>Fix the behaviour of Pair ~~ Pair (#4671)<commit_after>my class Pair does Associative {
    has $.key is default(Nil);
    has $.value is rw is default(Nil);
    has ObjAt $!WHICH;

    proto method new(|) {*}
    # This candidate is needed because it currently JITs better
    multi method new(Pair: Str:D $key, Mu \value) {
        my \p := nqp::p6bindattrinvres(
          nqp::create(self),Pair,'$!key',$key);
        nqp::bindattr(p,Pair,'$!value',value);
        p
    }
    multi method new(Pair: Mu \key, Mu \value) {
        my \p := nqp::p6bindattrinvres(
          nqp::create(self),Pair,'$!key',nqp::decont(key));
        nqp::bindattr(p,Pair,'$!value',value);
        p
    }
    multi method new(Pair: Mu :$key!, Mu :$value!) {
        my \p := nqp::p6bindattrinvres(
          nqp::create(self),Pair,'$!key',$key);
        nqp::bindattr(p,Pair,'$!value',$value);
        p
    }

    multi method clone(Pair:D:) {
        nqp::p6bindattrinvres(self.Mu::clone, Pair, '$!WHICH', nqp::null)
    }
    multi method WHICH(Pair:D: --> ObjAt:D) {
        nqp::isconcrete($!WHICH) ?? $!WHICH !! self!WHICH
    }

    method !WHICH() {
        $!WHICH := nqp::if(
          nqp::iscont($!value)
            || nqp::not_i(nqp::istype((my $VALUE := $!value.WHICH),ValueObjAt)),
          self.Mu::WHICH,
          nqp::box_s(
            nqp::concat(
              nqp::if(
                nqp::eqaddr(self.WHAT,Pair),
                'Pair|',
                nqp::concat(self.^name,'|')
              ),
              nqp::sha1(nqp::concat(nqp::concat($!key.WHICH,"\0"),$VALUE))
            ),
            ValueObjAt
          )
        )
    }

    multi method ACCEPTS(Pair:D: %h) {
        $!value.ACCEPTS(%h.AT-KEY($!key));
    }
    multi method ACCEPTS(Pair:D: Pair:D $p) {
        $!key.ACCEPTS(nqp::getattr($p,Pair,'$!key'))
          && $!value.ACCEPTS(nqp::getattr($p,Pair,'$!value'))
    }
    multi method ACCEPTS(Pair:D: Mu $other) {
        nqp::can($other,(my $method := $!key.Str))
          ?? ($other."$method"().Bool === $!value.Bool)
          !! X::Method::NotFound.new(
{'fraction_non_alphanumeric': 0.19430241051862673, 'fraction_numerical': 0.0038957876795714633, 'mean_word_length': 2.196887159533074, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7016067', 'n_tokens_mistral': 1535, 'n_tokens_neox': 1486, 'n_words': 250}