Skip to content

Instantly share code, notes, and snippets.

@gfldex
Created March 27, 2022 15:52
Show Gist options
  • Save gfldex/eb28b4d6f21acbd62296d9ae699f9a68 to your computer and use it in GitHub Desktop.
Save gfldex/eb28b4d6f21acbd62296d9ae699f9a68 to your computer and use it in GitHub Desktop.
use v6.d;
class A {
has $!a = 'private';
method !a { $!a }
}
multi sub trait_mod:<is>(Mu:U \obj, :$spying!) {
A.^add_trustee(obj);
A.^compose;
}
class B is spying(A) {
has A $.a = A.new;
method m { say $!a!A::a }
}
B.new.m;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment