You cannot compare types by name.
my \Foo = anon class Foo {}
my \Bar = anon class Foo {}
say Foo.^name eq Bar.^name; # True
say Foo eqv Bar; # False
is , .
is Bar.^lookup( 'Str' ).package, Bar, 'Bar defines Str'
, .
sub defines-method (
Mu:U $class,
Str:D $method,
Str:D $desc = "$class.^name() defines $method"
) {
is $class.^lookup( $method ).?package, $class, $desc
}
defines-method Foo, 'Str';
sub &infix:<defines-method> = &defines-method;
Bar defines-method 'Str';
( , .?package, .^lookup .)
.^lookup Method, ; , , , . , - (, ).
multi, .candidates .
( .^find_method, )
, .can, , , .*Str .+Str, . , .
> class Bar is Str { method Str { 'Hello' } }
> quietly .perl.say for Bar.+Str;
"Hello"
""
""
> .perl.say for Bar.new.+Str
"Hello"
""
"Bar<80122504>"
> quietly .(Bar).perl.say for Bar.can('Str')
"Hello"
""
""
> .(Bar.new).perl.say for Bar.can('Str')
"Hello"
""
"Bar<86744200>"