@H_301_6@
我尝试了以下内容:
package Foo; sub new { my ($type) = @_; return bless {},$type; } package Bar; use Moose; package Baz; use Moose; use MooseX::Method::Signatures; method exec1 (Foo $f,Bar $b) { ...; } method exec2 ($f where {$_->isa('Foo')},Bar $b) { ...; }
我发现exec2可以工作,但对于exec1,存在编译时错误.如果Foo是Mouse对象(这些是我无法更改的类),则会发生同样的错误.
'Foo' could not be parsed to a type constraint - maybe you need to pre-declare the type with class_type at C:/strawberry/perl/site/lib/Parse/Method/Signatures/TypeConstraint.pm line 74
但有没有办法可以使用exec1签名?