Skip to content

Commit 24bb91f

Browse files
committed
Merge pull request #28 from dagurval/master
test for having a method with the same name as an accessor
2 parents 21c8ec8 + 76a86f7 commit 24bb91f

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

S12-attributes/class.t

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Class Attributes
1111
#L<S12/Class attributes/"Class attributes are declared">
1212
#L<S12/Class methods/Such a metaclass method is always delegated>
1313

14-
plan 23;
14+
plan 25;
1515

1616
class Foo {
1717
our $.bar = 23;
@@ -105,4 +105,19 @@ dies_ok {$test5 = Quux.bar}, 'class attribute accessor hidden by accessor in sub
105105
ok $! ~~ Exception, "bad code: '$bad_code'";
106106
}
107107

108+
{
109+
class A {
110+
has $.b = 1;
111+
method b() { 2; }
112+
};
113+
is A.new.b, 2, "don't create accessor if the class declares an explicit method of that name";
114+
115+
116+
role B {
117+
has $.b = 1;
118+
method b() { 2; }
119+
};
120+
is B.new.b, 2;
121+
}
122+
108123
# vim: ft=perl6

0 commit comments

Comments
 (0)