=begin pod :kind("Type") :subkind("class") :category("exception")

=TITLE class X::Does::TypeObject

=SUBTITLE Error due to mixing into a type object

    class X::Does::TypeObject is Exception {}

When you try to add one or more roles to a type object with C<does> after it
has been composed, an error of type C<X::Does::TypeObject> is thrown:

=for code
Mu does Numeric;    # Cannot use 'does' operator with a type object.

The correct way to apply roles to a type is at declaration time:

=for code :skip-test<compile time error>
class GrassmannNumber does Numeric { ... };
role AlgebraDebugger does IO { ... };
grammar IntegralParser does AlgebraParser { ... };

Roles may only be runtime-mixed into defined object instances:

=for code :skip-test<compile time error>
GrassmannNumber.new does AlgebraDebugger;

(This restriction may be worked around by using
L<augment or supersede|/language/variables#The_augment_Declarator>, or
with dark Metamodel magics, but this will likely result in a
significant performance penalty.)

=head1 Methods

=head2 method type

    method type(X::Does::TypeObject:D: --> Mu:U)

Returns the type object into which the code tried to mix in a role.

=end pod
