- if (Scalar::Util::blessed($a2) and $a2->isa(__PACKAGE__)) {
- Carp::confess('Can\'t compare atoms of different packages')
- if $a1->category ne $a2->category or $a1->name ne $a2->name;
+ my $blessed = Scalar::Util::blessed($a2);
+ unless ($blessed and $a2->isa(__PACKAGE__)) {
+ if ($blessed and $a2->isa('CPANPLUS::Dist::Gentoo::Version')) {
+ $v2 = $a2;
+ $a2 = undef;
+ } else {
+ my $maybe_atom = eval { __PACKAGE__->new(atom => $a2) };
+ if (my $err = $@) {
+ $v2 = eval { CPANPLUS::Dist::Gentoo::Version->new($a2) };
+ Carp::confess("Can't compare an atom against something that's not an atom, an atom string ($err), a version or a version string ($@)") if $@;
+ $a2 = undef;
+ } else {
+ $a2 = $maybe_atom;
+ }
+ }
+ }
+
+ if (defined $a2) {