Skip Menu |

This queue is for tickets about the Moose CPAN distribution.

Report information
The Basics
Id: 91593
Status: stalled
Priority: 0/
Queue: Moose

People
Owner: Nobody in particular
Requestors: kain.winterheart [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in:
  • 2.0402
  • 2.0604
  • 2.1005
Fixed in: (no value)



Subject: Inheritance is broken when applying metaclass trait to parent class' metaclass
Hello. I have two classes: package C1; use Moose; no Moose; -1; package C2; use Moose; __PACKAGE__ -> meta() -> add_method( asd => sub{ return; } ); __PACKAGE__ -> meta() -> add_attribute( qwe => ( is => 'rw', isa => 'Any' ) ); extends 'C1'; no Moose; -1; ...which are working very well until a following role apprears: package T1; use Moose::Role; no Moose::Role; -1; ...which in it's case is applied to metaclass of C1, which transforms to this: package C1; use Moose -traits => [ 'T1' ]; no Moose; -1; . Having that role applied, I'm getting following error message: Can't fix metaclass incompatibility for C2 because it is not pristine . But if I remove the line __PACKAGE__ -> meta() -> add_attribute( qwe => ( is => 'rw', isa => 'Any' ) ); from C2 - the error goes away. The error also goes away if I move "extends" rigth under "use Moose", like this: package C2; use Moose; extends 'C1'; __PACKAGE__ -> meta() -> add_method( asd => sub{ return; } ); __PACKAGE__ -> meta() -> add_attribute( qwe => ( is => 'rw', isa => 'Any' ) ); no Moose; -1; . This workaround is pretty easy, yes, but in my real case it will lead to modifications of some amount of separate modules, which apparently could be not so easy. Is there anything I can do besides changing a lot of stuff, or is it a bug which will be fixed?
CC: ;
Subject: Re: [rt.cpan.org #91593] Inheritance is broken when applying metaclass trait to parent class' metaclass
Date: Mon, 23 Dec 2013 11:17:50 -0500
To: "https://www.google.com/accounts/o8/id?id=AItOawmNaaaSXM6QuPiIhzjO159qgjtY8HlNP64 via RT" <bug-Moose [...] rt.cpan.org>
From: Jesse Luehrs <doy [...] tozt.net>
'extends' really needs to happen as early as possible, because fixing up metaclass compatibility for classes which already have data in them is not always possible. I think this is probably behaving as intended. -doy
"Not always possible" sounds like there is the possibility sometimes. In example given above, why is this impossible? At first look there are no conflicting things. Пнд Дек 23 11:17:59 2013, doy@tozt.net писал: Show quoted text
> 'extends' really needs to happen as early as possible, because fixing up > metaclass compatibility for classes which already have data in them is > not always possible. I think this is probably behaving as intended. > > -doy
On Tue Dec 24 02:14:04 2013, https://www.google.com/accounts/o8/id?id=AItOawmNaaaSXM6QuPiIhzjO159qgjtY8HlNP64 wrote: Show quoted text
> "Not always possible" sounds like there is the possibility sometimes. > In example given above, why is this impossible? At first look there > are no conflicting things.
Reasonable patches are welcome, but I don't know that anyone on the core team is going to work on this since the fix for you is so simple. This is the way metaclass compatibility has worked for a long time.