Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@moritz
Created December 2, 2012 16:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save moritz/4189639 to your computer and use it in GitHub Desktop.
Save moritz/4189639 to your computer and use it in GitHub Desktop.
Trying to fix nqp::can(role { }, "something")
diff --git a/src/Perl6/Metamodel/ParametricRoleGroupHOW.pm b/src/Perl6/Metamodel/ParametricRoleGroupHOW.pm
index 075d5a5..82f1e3f 100644
--- a/src/Perl6/Metamodel/ParametricRoleGroupHOW.pm
+++ b/src/Perl6/Metamodel/ParametricRoleGroupHOW.pm
@@ -115,4 +115,11 @@ class Perl6::Metamodel::ParametricRoleGroupHOW
}
0;
}
+
+ method declares_method($obj, $name) {
+ for @!possibilities {
+ return 1 if $_.HOW.declares_method($obj, $name);
+ }
+ 0;
+ }
}
diff --git a/src/Perl6/Metamodel/RolePunning.pm b/src/Perl6/Metamodel/RolePunning.pm
index fcdab81..2e091f4 100644
--- a/src/Perl6/Metamodel/RolePunning.pm
+++ b/src/Perl6/Metamodel/RolePunning.pm
@@ -39,6 +39,9 @@ role Perl6::Metamodel::RolePunning {
if nqp::existskey(%exceptions, $name) {
return nqp::findmethod(%exceptions{$name}, $name);
}
+ unless self.declares_method($obj, $name) {
+ return nqp::null();
+ }
unless $!made_pun {
$!pun := self.make_pun($obj);
$!made_pun := 1;
make -j4 && ./perl6 -Ilib t/spec/S05-interpolation/regex-in-variable.rakudo
1..33
ok 1 - Simple scalar match 1
ok 2 - Simple scalar match 2
ok 3 - Simple scalar match 3
ok 4 - Nested scalar match 1
ok 5 - Nested scalar match 2
ok 6 - Nested scalar match 3
ok 7 - Rulish scalar match 1
ok 8 - Rulish scalar match 2
ok 9 - Rulish scalar match 3
No such method 'dispatch:<.^>' for invocant of type 'CachedCompiledRegex'
in sub infix:<does> at src/gen/CORE.setting:11980
in sub MAKE_REGEX at src/gen/CORE.setting:10385
in regex at t/spec/S05-interpolation/regex-in-variable.rakudo:43
in method match at src/gen/CORE.setting:4297
in block at t/spec/S05-interpolation/regex-in-variable.rakudo:43
# Looks like you planned 33 tests, but ran 9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment